Help me with sending Data to App Inventor

Hello EveryOne, Can please someone Help me with sending Data to App Inventor. Please I have tried so many things and I can't seem to make it work. I am sending Float (2 Floats : Q and Calc) . Here is my arduino Code and my App inventor.

int NbTopsFan;         // Nombre de tours d'hélices
float Calc;            // Calculer du volume
float Q;              // Calculer du débit
int hallsensor = 2;  // PIN DIGITALE 2
BLEService dataService("19B10000-E8F2-537E-4F6C-D104768A1214"); // Random 128-bit UUID for the service
BLEFloatCharacteristic dataCharacteristic("19B10001-E8F2-537E-4F6C-D104768A1214", BLERead | BLENotify); // Random 128-bit UUID for the characteristic

void rpm() { NbTopsFan++;}

void setup() {
  Serial.begin(9600);
  pinMode(hallsensor, INPUT);
  attachInterrupt(digitalPinToInterrupt(hallsensor), rpm, RISING);
  if (!BLE.begin()) {
  Serial.println("Erreur BLE");
  while (1);}
  BLE.setLocalName("NanoBLE");
  BLE.setAdvertisedService(dataService); // Annoncez le service personnalisé
  dataService.addCharacteristic(dataCharacteristic); // Ajouter la caractéristique personnalisée au service
  BLE.addService(dataService); // Ajouter le service personnalisé
  // Add the BLE connection event handler here
  BLE.advertise(); // Démarrez la publicité BLE
  Serial.println("En attente de connexion BLE...");}

void loop() {
  BLEDevice central = BLE.central();
  if (central) {
    Serial.print("Connecté à : ");
    Serial.println(central.address());
    while (central.connected()) {
      NbTopsFan = 0;
      delay(1000);
      Q = (NbTopsFan / 9.5);
      Calc = (Q / 60) + Calc;
      String To_App = String(Calc, 3) + "," + String(Q, 3);
      Serial.println(To_App);
      float value = atof(To_App.c_str());
     dataCharacteristic.writeValue(value);
      delay(200);
    }
  
}


In case it might provide context that will be useful to the forum helpers, I'll add a link to @lanadelrey123d's previous topic:

Please explain line to line what are you trying to achieve in this snippet:

If you already converted a two floats to the text string in the first line - why do you try to convert it back to the float at the end of the code?

Good point. I did remove it after, because I wanted to have float just to match my App inventor blocks. But i remored it.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.