First MIT App Inventor Project - Arduino BLE

Hi everyone.

I'm quite new to MIT App Inventor and BLE connection in general.

I have begun creating an app that is to be used to connect to my Arduino Nano 33 IOT and then receive data from said Arduino to be then graphed. The data will be a weight between 0 and 50kg. However I have little understanding as to how BLE works and am unsure how to use the Bluetooth on the Arduino. I have looked all over the internet (granted maybe not in the correct places) but I have spent a few days on this and am struggling still. Here is the app, blocks and my code so far. But I have little to no understanding as to where to find the service or characteristics UUID.

Any help is appreciated, even if it's a link to something else, be a previously made similar project, another thread or web page.

I'm happy to answer any questions. Thanks!

#include <ArduinoBLE.h>

BLEService weightService("?"); // BLE weight Service

// BLE weight Switch Characteristic - custom 128-bit UUID, read and writable by central
BLEByteCharacteristic switchCharacteristic("?", BLERead);

// Arduino With Load Cell
long time = 0; // Set time to 0
int interval = 100; // Take a reading every 100 ms

void setup() {
Serial.begin(9600);

while (!Serial);

// begin initialization
if (!BLE.begin()) {
Serial.println("starting BLE failed!");

while (1);

}

// set advertised local name and service UUID:
BLE.setLocalName("Arduino");
BLE.setAdvertisedService(weightService);

// add the characteristic to the service
weightService.addCharacteristic(switchCharacteristic);

// add service
BLE.addService(weightService);

// set the initial value for the characeristic:
switchCharacteristic.writeValue(0);

// start advertising
BLE.advertise();

Serial.println("BLE Active");

}

void loop() {
float curReading = analogRead(0); // Take reading of analog pin 0 of Arduino

// using serial.print, we can send the data in a 'text' format
Serial.print(curReading);
delay(100);
}

1 Like

Hi! I suggest to read this: https://www.settorezero.com/wordpress/arduino-nano-33-iot-wifi-ble-e-imu/
easily readable with google translator Italian to English ... All the necessary steps are well explained. In particular the GUUID question ... Good luck

2 Likes

Hello, I am doing a similar project at MIT app inventor, I have an Arduino "bluno beetle" but I cannot make a Bluetooth connection between the Arduino (bluno) and my application, however with the Arduino (bluno) demo application it does connect . Do you have any information that can help me?