I have an ESP32-C3 coded using the Arduino IDE which is coded to send sensor data every 25ms which is then handled using react-native-ble-plx by my react native app to create a live plot. The live plot I have is generally fine except for the fact that once or maybe a few times a second it stalls very slightly, just enough to be annoying.
I have used Serial.print() with millis() within Arduino to test whether it appears there is a discrepancy there, it appears to have consistent timing to within 1ms which isn’t enough to cause this issue.
Another issue I faced is that the base64 format that gets sent over bluetooth appears to be read backwards somehow by react native. I have to use the following code to reverse the hexadecimal of the base64 value to decipher the sensor data:
BLE sensor value decipher code
One might think that this is the cause of the stuttering but actually it gets worse when the sensor data is sent at a lower frequency. The reason I can’t just ramp up the frequency is that then the graph rendering becomes too slow causing latencies of >1s which is unacceptable. To clarify, it is not the data capture that is too slow, if I just print the value at a higher frequency it works great, the graph just can’t re-render that quickly.
Anyone know where this intermittent pausing is coming from? Any help would be greatly appreciated.
blahblah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.