Dear ChrisWard,
thanks you for your fast reply, below the Arduino code:
/*
ARDUINO_BLE___send float data
*/
//includo le librerie
#include <ArduinoBLE.h> // library bluetooth
#include <Arduino_LSM9DS1.h> // library accellerometer
//dichiaro servizio bluetooth
BLEService TotalService ("19B10000-E8F2-537E-4F6C-D104768A1214"); // BLE TotalService
// BLE - custom 128-bit UUID, read/write central
BLEFloatCharacteristic ComandAccY1("19B10012-E8F2-537E-4F6C-D104768A1214", BLERead);
//variable
float AccX = 0;
float AccY = 0;
float AccZ = 0;
//variable for millis
unsigned long time3;
unsigned long deltatime3;
//---___------***---___------***---___------***
void setup()
{
//open serial comunication
Serial.begin(9600);
//open serial comunication: ok
while (!Serial);
//Nano 33 BLE and sensors: ok
if (!BLE.begin())
{
Serial.println("starting BLE failed!");
while(1);
}
if (!IMU.begin())
{
Serial.println("Failed to initialize IMU!");
while (1);
}
// set advertised local name and service UUID:
BLE.setLocalName("FLOAT DATA");
BLE.setAdvertisedService(TotalService);
// add the characteristic to the service
TotalService.addCharacteristic(ComandAccY1);
// add service
BLE.addService(TotalService);
// set the initial value for the characeristic:
ComandAccY1.writeValue(0.00);
// start advertising
BLE.advertise();
Serial.println("Ready to start");
}
//---___------***---___------***---___------***
void loop() {
//list central
BLEDevice central = BLE.central();
//central is connected
if (central)
{
Serial.print("Connected to central: ");
//print MAC of central
Serial.println(central.address());
//while central is connected
while (central.connected())
{
//call function
FUNZAccelerometer1 ();
}
//print note when central is disconnected
Serial.print(F("Disconnected from central: "));
Serial.println(central.address());
}
}
//---___------***---___------***---___------***
void FUNZAccelerometer1 ()
{
//make 'delay' with millis
deltatime3 = millis() - time3;
if (deltatime3 >= 1000)
{
time3 = millis();
//read values if IMU: ok
if (IMU.accelerationAvailable())
{
IMU.readAcceleration(AccX, AccY, AccZ);
Serial.print(AccY);
Serial.print('\t');
AccY = AccY * 100;
ComandAccY1.writeValue(AccY);
Serial.println(AccY);
}
}
}
//---___------***---___------***---___------***
And here App Inventor app: BLE_float_data.aia (246.4 KB)
Do it possible make a PNG file of all code with just one click? Because, I know make a PNG one block for time.