What is the DelimiterByte in Bluetooth?
What clock interval do you use?
To test, receive the data as text, set a slower Arduino delay, delay(1000).
Check in this Community topics about Bluetooth.
From the experience of others with this problem, the recommended solution is to replace the delay() call with an extra variable, Last_Time_Transmitted_ms, which would hold the last System Time in Milliseconds from 1970 (default 0) when the Arduino issued a BlueTooth println(). In the loop(), each cycle you should check if (Current SystemTime in ms) - Last_Time_Transmitted_ms > 25 (whatever your delay was) .
If the difference > 25, do your println and reset the Last_Time_Transmitted_ms to (Current SystemTime in ms), else do nothing.
P.S. 25 ms might be too frequently for AI2 to handle.
However, we feel a (I don't know how to translate this word in English... in French: "à-coup", in English maybe "jerk", it's a slight delay, as if the code stops a few millis ) in the rotation of the motor every 100 millis.
I think (not sure) it came from the line: messageBT = (String) pasMotorZ + ", […]
Because for example when I write a single String (pasMoteurZ), the jerk is weak, and the more Strings I add (like pasMoteurY, pasMoteurX, …), the jerk is stronger and stronger…
I don't know if I was very clear in my explanations, don't hesitate to ask me for more information
Maybe - strings should not be assembled at the microcontroller end, just send values to the App directly. If the values are arriving in the App and are as expected, comment-out the data send to the Arduino Serial Monitor, that alone will make a difference.
If the values are floats, use Serial to limit the decimal places.
I always recommend using the bar "|" as the value separator as it is most unlikely to be within a value and it's simply easier to see in the code, especially App Inventor code.
You can tweak the Sketch time interval and the App time Interval, maintaining the 20% difference - For example, try 60 milliseconds in the Sketch and 48 milliseconds in the App.
Salut @Jon1 ,
si le délai est vraiment chaque 100 ms et la cause racine est vraiment le débit vers le BT, je te sugère d' accelerer la connexion de ton Arduino vers la carte HC05 (ou HC06?). Normalement j'utilise le baudrate @115200. Cette vitesse ne peut pas etre rejointe par la librairie Softwareserial, mais comme tu n'utilises plus le serial monitor tu peux utiliser la ligne Tx et Rx hardware (pins 0,1) qui peuvent etre utilisés à ce débit. N'oublie pas qu'il faut aussi coder le HC05 à la meme vitesse. Si tu regarde le site de @Juan_Antonio il y a beaucopu d'examples sur le sujet. Dans cette façon la vitesse de communication est 10 fois plus rapide (si maintenant ton débit est à 9600 bps). Tu peux essayer ça.
Bonne chance !
(je suis italien mais je parle un petit peux le français, mais si je n'ai pas été clair, je vais l'écrire en anglais )
That's a good idea Ugo, I already recommended shedding the burden of the Serial Monitor. Baud rate already is 115200 in the Sketch for Serial, possibly the HC05/06 has not been programmed to run @ 115200.
Hi @Chris,
Sorry I didn't reckon that the baudrate was already @115200. I just saw that Jon was using the SoftwareSerial library. As far as I know (i.e. in my experience) that library is working erratically over 38400 bps. Moreover, probably the library is waiting for the complete buffer flush before freeing the foreground code. Maybe the HW serial is using an interrupt sequence so it is less time consuming, but, anyway, the problem is really "interesting" and "challenging"...
Best, Ugo.