After years of using Home Assistant with power hungry ESP’s and the desire to create battery powered sensor modules, I started thinking about alternatives. I had one ATtiny85 laying around and after a quick look in the datasheet I figured this microcontroller would be perfect!
First of all, I started thinking about functionalities; that’s always the first thing I do. I want the sensor to at least be able to measure temperature, humidity and motion. When looking at a multisensor like the Aeotec Multisensor 6, I thought it would be cool if it would also be possible to measure illuminance. However, the LDR’s use quite a bit of current so I’ll let that pass for now. An AM312 Passive Infrared Sensor and BME280 it is!
Soon, I started programming; the code is visible on GitHub. I’m using a Watchdog timer of 8 seconds and an interrupt for the PIR (Passive Infrared Sensor) to be able to let the ATtiny85 sleep when not in use. In combination with my Forced BME280 Library it only consumes 33uA. Yes, microamperes! With a CR2032 battery this results in rougly 290 days!
After letting it run for approximately 10 days, it stopped functioning… In that period I was very busy at school, so I didn’t have time to look into it; the project was put on hold for quite a long time. This was partially because I was Student-Assistent; takes a lot of time but is very fun!
During some weekends and at the beginning of the vacation I started to spend some more time on it. This was partially possible since I bought my first oscilloscope; the Hantek 2D72! Soon I saw that it was probably the Brownout detector. When transmitting, the FS1000A draws 34mA resulting in a voltage drop and pushing the ATtiny in brownout… After knowing this, an ATtiny85V (with a minimum voltage of 1.7V) was ordered. This functioned perfectly for several weeks!
In the first week of vacation I decided to design a PCB! This was done with Fusion360 and man… What a nice program to use! For anyone interested in the Gerber Files; feel free to contact me! When the PCB’s arrived, I noticed a small mistake with the negative SMD-Connector of the battery holder which overlaps with the Vcc of the BME280 and thus, all other devices. This has been solved in a not so nice way but hey, it works. It has been working ever since. This has been the case for over 2 weeks now.
The first PCB was functional but pretty amateuristic; all kinds of drawings, a short and not really made to be a final product. Since the project has proven itself and that it’s really able to be put to good use for longer periods of time, I decided to spend a couple of days finishing it.
I found a chip called BH1750 and wrote a library for it and added a Reed Switch so the state of a window/door can be monitored. However, since I’m planning on giving back to the Home Assistant community for the first time, and there are a lot of tinkerers on there, I decided to expose the pins for the Reed Switch with a JST-Connector. That way, for example a button can be wired to it! Maybe in the future I’ll even expose the GND, VCC and PIN_B3 pins via a JST-Connector so 1-Wire devices can be added and all kinds of possibilities open up.
Since the current draw went up to 50 microamperes, I decided to use a CR123A battery; it could then last for over 5 years! Furthermore, it also creates a nice form factor. This PCB has now been ordered.