Gordon, how far should I expect a Puck to Rpi to be able to communicate?
In my house I manage around 10M including two floors and a brick wall pretty reliably. You can get more in free air, but it's the brick walls that really impact the transmission.
Isn't that going to burn up the battery? I would like to get a couple of months battery out of a once a day event advert.
Surprisingly not that much. The Puck has to keep broadcasting so it can be connected to - so you're not adding more power usage over what it's doing already.
If you leave it as-is you should get at least 6 months out of it. You might want to increase the transmit power with NRF.setTxPower(4) but maybe just decrease the advertising interval - make it 1000ms instead of the default 375ms and you'll instantly bump the battery life up a load.
While you can use NRF.sleep() and NRF.wake() to start/stop advertising, personally I'd just lower the advertising interval - it's easier, and you can always also do stuff like advertising battery level so you can keep an eye on it.
It might be worth doing digitalRead(LED1) before you check the light level too. The LED is used for light sensing, and if it was an output then Puck.js has to wait for 50ms for it to discharge/charge each reading - which adds quite a lot of power usage :)
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
In my house I manage around 10M including two floors and a brick wall pretty reliably. You can get more in free air, but it's the brick walls that really impact the transmission.
Surprisingly not that much. The Puck has to keep broadcasting so it can be connected to - so you're not adding more power usage over what it's doing already.
If you leave it as-is you should get at least 6 months out of it. You might want to increase the transmit power with
NRF.setTxPower(4)
but maybe just decrease the advertising interval - make it 1000ms instead of the default 375ms and you'll instantly bump the battery life up a load.While you can use
NRF.sleep()
andNRF.wake()
to start/stop advertising, personally I'd just lower the advertising interval - it's easier, and you can always also do stuff like advertising battery level so you can keep an eye on it.It might be worth doing
digitalRead(LED1)
before you check the light level too. The LED is used for light sensing, and if it was an output then Puck.js has to wait for 50ms for it to discharge/charge each reading - which adds quite a lot of power usage :)