Bluetooth communication between Gpy & ESP
I'd rather post this under Bluetooth but that seems closed.
I have the following setup: a Gpy is used to send data with LTE & MQTT to a server. The data comes from several (<10) ESP32 clients (also running Micropython). The data is very infrequent (about every 10m) and low volume (temperature, humidity, weight). Everything has to be battery & solar driven. My idea for the communication between the controllers was to use BLE.
The clients would deep-sleep between the measurements and advertise their data after wakeup & measurements.
After reading through the documentation that seems doable. :)
Has someone done something similar and would share some example code? I'm pretty new to BLE and couldn't find a tutorial apart from what is in the pycom documentation.
Yes, everything is battery powered. I will have to synchronize the wakeup cycles. I guess there won't be much of a time difference after 10 minutes. It will probably be necessary to set and synchronize the time every now and then.
Would it make sense for the ESPs to advertise the availability of data and provide the data as characteristic? The Gpy could then advertise 'data read' and send the ESPs back to sleep.
Similar for setting the time on the ESPs. The Gpy advertises its availability and provides the current time as characteristic.
@poesel is the GPy also going to be battery-powered? This may be an issue, as the two devices in a communication need to be awake at the same time (ESP32s are, at least currently, not very good at sleeping with BLE advertising/listening for connections).
This means you will need to either have the GPy awake at all times, or somehow synchronise when the devices send so the GPy is awake at the same time.
Note that there are two ways for the data to be sent: you could just advertise it, but then there’s no acknowledgment, so you need to make sure you have several advertisements, or you could connect and share the data via a characteristic. In the latter case, you need to decide which of the devices connects to the other. I would probably have the sensors connect to the GPy, but it depends a lot on your setup.