This is my second project using the ATtiny85. I have previously made, and use, these PIR sensors with "power hungry" Arduino Pro Minis. I usually have to replace the batteries in these devices every 2 months. It depends on how much we move in the rooms they are located. They use 1000mAh CR2477 coin cells. These batteries are quite "big", compared with other coin cell batteries.
I thougt it was time to "upgrade". These new devices use more or less the same code as the those explained above. I had to adapt the code to run on the ATtiny85. After a lot of trouble and and frustration with my experiments, I finally made it. More on the problems and challenges I encountered may be found further down.
How it works
The ATtiny85 sleeps until the PIR sensor is triggered by a person moving. A STX88 433MHz transmitter then sends a signal to my RFXCOM RFXtrx433E USB 433.92MHz Transceiver. This again is picked up by my Raspberry Pi 2 running DomotiGa. From here I can create rules, scripts and actions.
I use the X10rf protocol for the transmission from all my PIR sensors and there are two reason for this. The protocol is designed for PIR sensors (among other things) and the RFXCOM RFXtrx433E Transceiver can receive it. The Arduino library I use can be found here: https://github.com/p2baron/x10rf.
I have made two varieties. The first one uses a CR2032 (240mAh) coin cell battery and this will have a theoretical life of about 3.1 month. I have also build one using the bigger CR2450 coin cell battery. This is a 550/600mAh battery and will theoretically work for 7.1 month. The ATtiny85 only use about 5µA when sleeping, but the PIR sensor obviously need to be awake all the time, but use as little as 70µA (0.075mA). So, a total of 75µA when sleeping. That's not bad.
The CR2032 (240mAh) coin cell battery turned out to die after about 3 weeks. I guess that has to do with voltage drop and that the sensor need 3V to run. The ATtiny should work fine down to 1.8V.
The one using the bigger CR2450 coin cell is still going on its third month now.
Size does matter
Compared to the ones I made about a year ago or so with Arduino Pro Minis, these are a lot smaller and use both a smaller PIR sensor and a smaller battery. These PIR sensors cost a bit more than the standard Arduino PIR sensors, but I think they are worth it. You can find these sensors here.
I have always wanted something better than the standard "electronic project boxes". They are dull, and they all looks the same. And then we have the WAF (wife acceptance factor)... This factor applies even when not married. A house full of gray, white or black project boxes isn't excactly pretty.
I have spent countless hours online trying to find cool, different and fancy project boxes, but I never found them... Since this project is smaller than my previous ones I had the idea to use empty "snus boxes". My Norwegian and Swedish readers will instantly know what these are. They are plasticboxes containing smokeless tobaco, calles snus. As far as I know, they are sold and used only in Norway and Sweden. Correct me if I'm wrong.
Problems and challenges
When creating this small device I had to jump a few hoops to get it to work. The "attachInterrupt(0, trigger, RISING);" used on the ATmega328 (Arduino and Arduino Pro Mini), can't be used on the ATtiny85. That's where my previously mentioned frustrations began. After some time I found a library that saved me. The EnableInterrupt library (https://github.com/GreyGnome/EnableInterrupt). This works more or less as the Arduinos attachInterrupt. Check out my code to see how it works.
(May change without notice)
1 x ATtiny85V-10PU w/IC holder
1 x STX88 433MHz transmitter w/antenna
1 x Small PIR sensor
1 x 100R resistor
1 x 10K resistor
1 x 10-100 uF electrolytic capasitor (Optional)
1 x 3mm LED (I use red)
1 x cut out vero board to fit the box
Some wires and headers for the LED and component connections.
All parts available at eBay.com and/or Aliexpress.com