App inventor Nano BLE 33

Here are my device properties. I am sorry i didnt understand do you want me to change the block "RegisterForBytes" to ReadBytes? and for my labels I don't have 'Do it'.

Connect your device to Companion, right mouse click on Label1.Text, "Do it".

See also here (point 4): How to ask a question (open new topic)

Okey and replace "RegisterForBytes'' with Read Bytes?


I did exactly what you said.

What about trying it first instead of asking more questions and posting the same blocks over and over again. Incidentally, the RegisterForBytes & ReadBytes blocks do not necessarily have to be mutually exclusive.

No.

Why are you getting angry. If you don't want to help then don't as simple as that. I am still learning and If i were an expert in App Inventor I wouldn't ask for help. So take it easy.

I'm not angry at all. I just asked you to try something yourself first. :upside_down_face:

Okey You have showed two blocks. i used them just like what you have showed in your image. I can't scan the app, it catches. So I built an apk file and installed it. It's not working i can't receive data.

It's one more time. Were you able to connect to your bluetooth device? I understand that the problem is in the write/read communication itself?

Yes the connection with my app is great. I have showed images iof the scan and the connection.

Try this one:

and post screenshots before & after "Read bytes" button is clicked (of course after scanning & connecting). If you get an error, please post it as well.


PS: UUIDs are saved in TinyDB, so you must enter them only once.

First, download a universal app from the play store to receive ble data. Check in this app if your arduino is sending data correctly.

Yes I use BlueLight, It works perfect. But My app inventor no.

So, show us what your example data looks like?

I guess the solution may be, as Anke mentioned, to use bytes instead of floats. try it. I also see that she has prepared a test app, try it too.

Yes I will try it immediately and show you my results. Thank you so much for your interest in my problem.


I don't know why I see a list of 48, 46, But in my monitor serie it's 0.000( And that is the value i am sending , Maybe it's my arduino code, I don't know
""
#include <ArduinoBLE.h>
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
BLECharacteristic dataCharacteristic("19B10001-E8F2-537E-4F6C-D104768A1214", BLERead, 20); // 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();
NbTopsFan = 0;
delay(1000);
Q = (NbTopsFan / 9.5);
Calc = (Q / 60) + Calc;
String To_App = String(Calc, 3);
Serial.println(To_App);
dataCharacteristic.writeValue(To_App.c_str(), To_App.length());
delay(200);
}
""

I have corrected my Arduino code and here is what i am seeing still odd, does anyone please have an idea how i can correct it?
#include <ArduinoBLE.h>
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
BLEByteCharacteristic 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
dataCharacteristic.writeValue(0);
BLE.advertise(); // Démarrez la publicité BLE
Serial.println("En attente de connexion BLE...");}

void loop() {
BLEDevice central = BLE.central();
NbTopsFan = 0;
delay(1000);
Q = (NbTopsFan / 9.5);
Calc = (Q / 60) + Calc;
Serial.println(Calc);
// dataCharacteristic.writeValue(To_App.c_str(), To_App.length());
delay(200);}

If the app from Anke reads the data correctly and your app reads the data wrong, then correct your app, not the arduino code. Use RegisterForBytes and read the bytes in the BytesReceived event.

Anke's app receives the ASCII byte representation of your string. 48 is "0", 46 is "."

I don't know the ble extension well. Is there a block for receiving strings?

Hello @Patryk_F THe anke app sends 48, 46 instead of 0.00 so i am going to use her app for the moment just to see if i can see 0.00 in her app. Yes there is a block receiving strings. @Anke please can you tell me if in your blocks you are reading Bytes?