05/27/2017 at 10:38 •
I designed the circuit with the idea to use batteries without a voltage regulator, because they use current every time. The sensor board should stay in low power mode most of the time, so a voltage regulator (even the ultra low power ones) could be responsible to a significant amount of power drain.
Not long ago, Espressif updated their datasheet of the ESP8266. Now they state the operating voltage is between 2.5 V and 3.6 V (in the past, they only guaranteed a minimum voltage of 3.0 V).
By my own experiments, I found a working minimum voltage of 2.3 V using different modules. This allows to use different battery technologies directly. Sadly, the wide known LiPo batteries are no candidates, because their voltage ranges from 3.0 V (drained, better go not lower than that) to 4.2 V fully charged.
For microcontroller circuits there is another interesting alternative: LiFePO4. The nominal voltage of one cell is 3.2 V, which is near the 3.3 V of modern electronics. They are fully charged at 3.6 V (perfect) and can be discharged to 2.5 V – 2.0 V (depends on the manufacturer). I managed to get cells in the AA-battery size with 700 mAh capacity and used two in parallel.
The next possibility are NiMH-cells. You have to use two cells in series because their nominal voltage is 1.2 V per cell. Fully charged they are near 3 V, then they have a long plateau around their nominal voltage and at 2.3 V they are over 90 % drained. Sounds good. I used Eneloops which have a low self-discharge rate. Their capacity is araound 2000 mAh.
As alternative you could also use alkaline batteries. If they last long enough, they could be an option because they are way cheaper than the rechargable NiMH-cells. 1.5 V is their nominal voltage, which is slightly higher if they are new. They can be drained until no voltage remaines, but they are quite dead at 2.3 V (or 1.15 V per cell). The capacitiy is a bit higher than the Eneloops at around 2500 mAh.
I programmed a test procedure to get battery life results in time-lapse: The sensor board wakes up, connects to my Wifi, reads the sensors, reports the states to my MQTT broker, sleeps for 5 seconds an repeats everything. At every wakeup it increments the reboot number and stores it in the RTC memory to last between the wakeups.
I got the following results:
Battery Voltage Range Reboots Lifetime (10 reboots/h) LiFePO4 (2P) 3.5 V – 2,26 V 53706 223 days Eneloop (2S) 2.9 V – 2.27 V 82883 345 days Alkaline (2S) 3.3 V – 2.26 V 91652 381 days
At a wakeup rate of 10 wakes per hour or every 6 minutes, every battery technology can achieve the desired goal of 6 months of operation. Of course the lifetime will be lower in the real usecase, because the test didn’t acount for the standby currents. The winners are clearly the alkaline cells, followed by the Eneloops. For environemntal reasons, I will choose the NiMH, because they are rechargable.
05/09/2017 at 18:31 •
This is the first and unexpectedly working (!) prototype:
It has a dimension of 80 mm x 80 mm. The strange shape is because a had a case in mind. Therefore, I had to align the batteries this way because there are studs in the corners.
The board is populated with ready-made modules which take a lot of space. The light sensor module was even bigger, so I had to cut it brutally with my pliers into shape.
Beneath the Wemos D1 module, there resides a ATTiny85 for the PIR sensor interaction.
The PIR sensor is connected via cable, so I can interchange it.
It turns out that the PIR sensor is very sensitive to voltage variations on the power rail.
Every time the ESP connected to the network, the PIR sensor was triggered.
Finally I was able to get rid of it with a bigger capacitor on the ESP power input and a 33 pF capacitor directly on the pins of the PIR sensor for fast spikes.
05/05/2017 at 14:08 •
I made my first IOT experiences with the ESP8266 with the ESP-Easy firmware. Therefore, I wanted to keep the hardware compatible. For performance reasons, I later switched to my own code (which I will publish in the future after an extensive code review ;)). ESP-Easy supports a variety of sensors. I chose the following:
- Bosch BME280:
For measuring temperature, humidity and air pressure. This sensor combines the most important data sources in one tiny package. In fact, it’s so small you can hardly solder it yourself but there are some small breakout boards which costs about $5. It can communicate over I2C und SPI.
- Röhm BH1750FVI:
To acquire information about the current light level, I use a BH1750 or the newer variant BH1751. It gives me a lux-reading according to the human eye response for about $1. Communication over I2C.
- Panasonic EKMA 1101111:
After a long research phase, I found a good deal for a bunch of these PIR sensors. There are many small chinese PIR sensors as well. And they work alright. But their current draw is about 60 µA. For them to work, they have to be active all the time, so they make a big mark on the power bill. Over a period of one year (which is the design goal for the battery life) this would sum up to 525 mAh. The power consumption of the Panasonic EKMA 1101111 is negligible 1 µA! Unfortunately, I haven’t found a good source yet to get them for a reasonable price from a major supplier. For my PCB design, I will include an alternative.
The output of the PIR sensor is easy. As long as it detects movement, it will give a HIGH on its output pin. Since the ESP8266 consumes about 80 mA at normal operation, there is no way that it can monitor the PIR state itself. The battery would be empty in no time. So I chose a second microcontroller to do that job. A ATTINY25 (which will be in deep sleep and will woken via a pin change interrupt from the PIR) reports the state of the PIR sensor and wakes the ESP from deep sleep, if there’s new movement or no movement anymore. To minimise the wakeups, not every movement is reported. Because I want to use it as some kind of presence detection, an initial motion will trigger the ESP and if there’s no motion for 5 minutes (of course you can change it) it will be triggered again to report the LOW state. If during this period motion occurs, the time to report the LOW state will be extended by another 5 minutes.
04/14/2017 at 17:34 •
I like home automation a lot. For automation purposes data must be collected. I also like open software. But mostly I do like my own data not being on any strange servers outside my home.
So my goal is to design a sensor node to gather mostly useful data, that can be used to automate everything in my home (like lights, heating, blinds, media etc). They should speak MQTT, so I can easily integrate them in my home automation server (I use home assistant).
For my first tries I used NRF24l01-modules, they are cheap and have low power consumption, but you need an extra controller and a gateway to the host system. In the last years the ESP8266s showed up. Cheap, with Wifi, own microcontroller and a growing software environment and community. Great! But they are power hungry and bad for battery applications. But there are ways to deal with it - more of that later ;)
Let’s summarize my objectives for this project.
- Battery powered (battery life better than 6 months)
- PIR sensor
- Ambient light sensor
- Temperature and humidity
- Not that expensive
- Small form factor