Building An NRF52840 And Battery-Powered Zigbee Gate Sensor

Recently [Glen Akins] reported on Bluesky that the Zigbee-based sensor he had made for his garden’s rear gate was still going strong after a Summer and Winter on the original 2450 lithium coin cell. The construction plans and design for the unit are detailed in a blog post. At the core is the MS88SF2 SoM by Minew, which features a Nordic Semiconductor nRF52840 SoC that provides the Zigbee RF feature as well as the usual MCU shenanigans.

Previously [Glen] had created a similar system that featured buttons to turn the garden lights on or off, as nobody likes stumbling blindly through a dark garden after returning home. Rather than having to fumble around for a button, the system should detect when said rear gate is opened. This would send a notification to [Glen]’s phone as well as activate the garden lights if it’s dark outside.

Although using a reed relay switch seemed like an obvious solution to replace the buttons, holding it closed turned out to require too much power. After looking at a few commercial examples, he settled for a Hall effect sensor solution with the Ti DRV5032FB in a TO-92 package.

Whereas the average person would just have put in a PIR sensor-based solution, this Zigbee solution does come with a lot more smart home creds, and does not require fumbling around with a smartphone or yelling at a voice assistant to turn the garden lights on.

13 thoughts on “Building An NRF52840 And Battery-Powered Zigbee Gate Sensor

  1. Makes me almost wonder if he could have put a solar cell and energy harvesting chip in there and use a rechargeable battery. Of course his design and power profiling in the in-depth article is pure genius. I just think if you are that skilled, you could go beyond 1-2 year coin cell lifetime with some good ole sun energy.

    (Wish I could design anything that energy conserving myself.)

  2. The capacity of a 2450 is 620mAh to 2.0V, so say (average 2.5V) 1.55Wh which is about 4.2mWh/day.

    A small garden light 60x60mm solar panel is typically 0,25W, and I find figures of solar panel efficiency going to 10% on a cloudy day. So say a winter day of 8 hours, this cell would still produce 0,2wH/day, which is still about 45 times the daily energy consumption, so I guess that would be very doable.

    1. Thanks for sharing your knowledge on the subject! I saved your post to a text-file so I can evaluate how much margin I have if I attempt something similar. I like to stay humble about my limited skills, but this makes me want to purchase some cells off Ali and try myself. I have a very illuminated balcony and I want to put some sensors out there for UV-index, temp, humidity and more. All low powered IC/ASIC ones. Realistically speaking I will still have to go the NRF route I assume. They are more or less market leader in low energy wireless. Regular 433 MHz transmitters off Ali are too power hungry.

      I am always very happy when people inspire me or reply with calculations or conservative estimates.

        1. You need about 175 µW on average, so the panel should be sized at 2 mW or greater (10x) and something that size from the usual reliable sources (not Aliexpress) costs between $1-3 in single quantities.

          If you can find a garden light in that price range, you might get something but you don’t know the voltage or power of the panel, so it might not work for you, or you need to go through extra steps (more components, more $$) to make it work.

    2. I find figures of solar panel efficiency going to 10% on a cloudy day.

      It’s easier to estimate using the average year-round capacity factor for your location. About 5% in Sweden and 15% in Spain. This accounts for seasonal variation and overcast days.

      The only other thing you have to mind is having enough batteries to account for the seasonal variation. In Sweden you need 4-6 months worth – much more than theoretically necessary because of the cold temperatures – while in Spain you pretty much need nothing because the length of the day hardly changes. A big capacitor would probably work.

    1. The issue was that reading the sensor requires a pull-up resistor, so one of the logic states will always draw extra current whether it’s a normally open or a normally closed switch. The door can remain open or closed for long periods of time, so it’s possible to drain the battery by forgetting to close the door.

      Since the change in logic level is probably what drives the wake-up interrupt for the MCU, you can’t leave the logic state undefined or else it would trigger the wake-up event from random noise. I.e. you can’t use clever tricks to poll the input to detect whether the switch is open or closed without a pull-up resistor.

      The Hall sensor has a push-pull output, meaning that the logic state is always defined as either high or low, which means the MCU doesn’t need to enable its pull-up resistor on the input and there’s no variable current draw depending on the state of the switch.

      1. You can poll using a switched pull up very easily, so the pull up only dissipates power for a brief pulse of a few ms rise time. This would give a negligible draw compared to the ZigBee operations. If you are responding to a switch close event a capacitor can limit this to a brief pulse also

  3. using a reed relay switch seemed like an obvious solution to replace the buttons, holding it closed turned out to require too much power

    Solution: two reed switches, one normally open and another normally closed. No pull-up required and zero quiescent current. Just needs a resistor to prevent shoot-through if both happen to remain on at the same time.

Leave a Reply to DudeCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.