I have several sensors running on coin batteries, which are supposed to send data to a central device periodically. The data size is small: the meaningful data should be a few bytes excluding the BLE packet overhead. The transmission period is long: it can be once per hour or even per several hours. I am using a Bluetooth Low Energy (BLE) module (BL600 from Laird) which has a nRF51822 SoC inside. The goal is to minimize the average power consumption since the sensors are supposed to run from battery for a long time (a year or so?). Obviously the BLE peripheral can send data either by advertizing or connection. I am not sure which is the way to go, and what factors I should consider in making the choice. Could anyone please advice?
If you data will fit into an advertising packet payload, then that is the lowest power possible way to get that data delivered to a receiver (or receivers). To send an atomic data set via advertising, you only need to send a single packet. A connection at very least would require a send followed by a receive.
You also indicate that you could go hours between data packets. With advertising, you can send your packets spontaneously as you like- as long as the receiver gets the packet when you do send it then the transfer is good.
Advertising packets are also much simpler to create. You could save processor cycles by laying out all the static parts of the packet in memory one and then very quickly updating only the dynamic data fields before a send.
Normally, for such long intervals between data transmission (once per hour), you would not hold a connection (as the max CON interval is much smaller - I think around 20 seconds).
So the strategy might be to turn off bluetooth on the sensor by default and activate it only when there's data to transmit - this should save a lot of power.
When waking up (with data), you need to start with advertising anyway; if you don't need any acknowledge nor special security, you can just send the data a few times in the ADV packets.
If you want to ensure that the data was received, you should enter a connection.
Also if you want to encrypt the data, you should connect, receive an encryption nonce from the central device, transmit the encrypted data (using common secret and nonce), receive the acknowledge, disconnect and turn off again.