Inspired by msfujino, I was wondering if the consumption of the peripheral could be further reduced.
Attached are two quick sketches modified from Adafruit examples. The peripheral broadcasts a new set of data every 10s. The central scanner uses the uuid to filter the packets coming from the peripheral. No connection phase between the 2 devices are involved, only advertise and scan. As a result duplicated packets will be picked up by the central. The average current of the peripheral gets lower as the data exchange becomes 1-way instead of 2-way and no interrupt routines are needed. The peripheral advertises for 5s and then sleeps for 5s. Sleep time can be extended by changing the delay value in the loop.
NRF52840.zip (2.6 KB)
I also use the NRFconnect mobile app to scan the packets from the peripheral. It is a good tool and helps me understand the construction of the packets.
The attachment is only a simple demo. An advertising packet carries up to 31 bytes. If user wants to advertise more data bytes, he can enable active scan on the central. The extra data bytes can be transmitted by the peripheral as a scan response packet. This should suffice most sensor applications.
1 Like