Nick was kind enough to send me one of these little Ikea cupboard lights that he had the great idea of adding one of my TinyTX sensors to. These motion controlled LED lights are only £5 for two and are available in a range of colours, they are only 7.5 x 6.5 x 1.8 cm with 4 LEDs, a PIR detector and run from 3 x AAA batteries.
This is an excellent find and the size is spot on for the TinyTX, by removing the four LEDs (or just three of them) the TinyTX 2 or 3 will fit in nicely (with the ATtiny84 soldered directly to the board for a reduced profile) and the PIR control board will happily run on only two AAA batteries so we can bridge the third one leaving space for the antenna and maybe a sensor or two. It makes for a much neater and more compact occupancy sensor or room node than the Airwick iMotion Freshmatic that is commonly hacked for this purpose.
To get a trigger from the PIR we can just connect an I/O pin from the TinyTX to one of the LED outputs, the positive to the LEDs is constant with the ground being switched from the controller so we just need to connect the ground from one of the LEDs to a pin on the TinyTX, this allow us to use exactly the same sketch as I have previously used for reed switches. This uses a pin change interrupt to wake the TinyTX when the PIR senses movement so the TinyTX stays in deep sleep at all other times. Power just needs connecting to the positive and negative terminals on the main Ikea board and I soldered a wire across the middle battery space to bypass it.
With the LEDs and reflector removed the original lens has nothing to hold it in place so a few of dabs of superglue were necessary to hold it in position along with a bit of paper to screen the TinyTX on the other side from view. With that done it is just a case of reassembling it. Easy.
Out of the box the Ikea board will turn the output on for 30 seconds and while this works it would be better to reduce it for lower power usage, like most cheap PIR devices the Ikea device uses the BISS0001 “Infrared-Sensor Signal Processor” which the datasheet tells us has a configurable output time that is set with a resistor and capacitor connected across the RR1 and RC1 pins, labelled R13 and C7 on the Ikea board. There are a few variations of the datasheet out there for this chip, some say the formula for the time is 24756 x R x C, some say 49152 x R x C. The reality on this board seems to be midway between the two.
The resistor for R13 is 8K2 and I popped the capacitor C7 off to find it was a 100nF which if we take the above values give us an on time of 20 or 40 seconds depending which constant you use where as in reality it is 30 seconds. Still, we can definitely play with the values of these components to change the trigger time, I put a 22nF in place of the 100nF (just what I had to hand) which reduced the time down to around 6 seconds (should be 4 or 8 seconds according to the above formulas), certainly much better and could be improved upon with the right components to hand.
It is also possible to change the “trigger inhibit” – how long motion will be ignored for after a trigger and whether it is in retriggering (output active for preset time period after motion stops) or non-retriggering mode (output active as long as there is motion), the default on this is non-retriggering which is what we want so no need to mess with this.
For the moment I just have this running as a motion sensor but adding a temperature or temperature/humidity sensor and an LDR would be easy enough. For now I’ve left one of the original LEDs in as a visual indicator of a trigger which helps while testing but that might not suit all uses and as it’s duller than originally due to running from two batteries instead of three it is really only useful as an indicator.
Other PIR devices
The BISS0001 PIR driver is the same chip used in the very cheap PIR modules that are commonly available on ebay and in hobbyist electronics stores (HC-SR501 and similar) which you can pick up for around £2.60 from UK sellers on ebay or as little as £1.39 from China. These modules all say they will run on 4.5V up to (usually) 20V but as it is essentially the same circuit as the Ikea light it is no surprise that they will run fine on 3V and surprisingly you don’t even need to bypass the voltage regulator, in fact I tested one with a Tiny328 on a variable supply and it worked right down to 2.1V where the RFM12B starts to become flaky with no perceived loss of detection range. There is some code for using these with a TinyTX or Tiny328 here, based on the interrupt driven reed switch sketch again.
Felix at Low Power Labs has been playing with these PIRs recently too and has made a very nice laser cut case for it. When I eventually get my RigidBot 3D printer I’ll be making some custom cases for things like this too but for now the Ikea light with its nice compact case and built in battery holder is a great choice.