Hello!
I am working on a project that requires realtime, wireless communication between a micro-controller (currently an ESP8266 but we plan to scale down later) and a mobile device. I have selected Bluetooth because it is cheap and integrated with pretty much every modern mobile device.
"Realtime". Once an event has been triggered (from a sensor or any other input) we need a "signal" to be sent to the mobile device as fast as possible. The events may be several seconds apart, or may be several times per second.
I have been playing with the HC05 and implemented a mechanism to calculate the time between sending and receiving a single byte of data; the micro-controller logs just before each send, the receiving device logs immediately after each receive and I process both logs after a test-run to calculate the latency of each event.
Generally, the transmission time is between 1 and 2 milliseconds (which is acceptable), but every few seconds I see a lag of anything up to 1000 milliseconds. This lag is what I am trying to eliminate. We need a constant latency of 1 to 2 milliseconds.
I have also been reading about packet sizes, which seems like a promising solution, but I cannot find how to play with packets/sizes on the HC05 (AT commands or Sketch libraries).
I am not tied to Bluetooth and have started researching WiFi direct, but I would prefer to use Bluetooth if we can achieve what we need. So this post is my final stand against Bluetooth before I take a different approach.
I also welcome any information about WiFi direct for this use case. So, can anybody offer any suggestions to help us?
Many thanks
Edit: Adding a code example for completeness
The HC05 is currently setup at 115200 baud, and I am using SoftwareSerial to read/write to it.
#include <SoftwareSerial.h>
SoftwareSerial bluetooth(13, 15); // RX, TX
void setup() {
bluetooth.begin(115200);
}
void loop() {
// Wait for connection...
if (isConnected) {
byte event = readSensor();
if (event > 0) {
// Log send-time
bluetooth.write(event);
}
}
}