Making a video takes too much time; I do have a DV cam, but in my opinion it takes to long to rewind, connect the firewire cable, transfer the clip to the PC etc. etc. My Nikon D90 also has video capabilities, but I’ve used it maybe once or twice in the beginning. The D90 can shoot 1280×720@24 fps MJPEG movies. I used it a couple of times again while we were on holiday and the results were quite good; although i still prefer my DV cam: focusing is slow and a bit difficult with the D90.

Here’s a small clip of my test with a JeeNode and 4 LED strip remainders i still had from my kitchen LED adventure.

A boxed PIR13

Two PIR13’s arrived yesterday. I immediately unpacked them to see if they would fit in the enclosure I want to use for them. It fits, but there’s not much room for error.

The lens is larger than the one on the previous PIR I used; this one requires a 13 mm hole, the previous was 10 mm. And the PIR13 lens sticks out more then the Panasonic version. But still, i prefer this much more than the X10-RF motion sensors i used in my former life ๐Ÿ™‚

The PIR13 PCB is glued to the top plate with hot glue. As you can see there’s not much tolerance along the long sides of the PCB; if the hole through the top plate is a bit excentric, you’ll have a hard time to make it all fit right. So pay attention there!

One nasty thing happened to me while preparing the 1st PIR13 to fit in the box; i decided it was wise to get rid of the 3 headers that are sticking out of the PCB; they were much to long! So i took my soldering iron and tried to get those things out. Normally, when you remove the plastic piece of the header and hold the soldering iron against a pin, they automatically fall out, sometimes with a bit of help, or they stick to the soldering iron. This time it was different; as if the pins were rammed into the PCB with a hammer! So i used a pair of pliers to gently pull the pin out; and while doing that, i damaged the PCB in a way that can’t be repaired anymore; aarggh!! First a voltage regulator blown up, now this.. what is this??

With the 2nd PIR13, i just cut off half of the pin length…

I foresee a “battle” for my spare time, between the LED strips and this new motion sensor… ๐Ÿ™‚

JeeNode+12V = Oops!!!

Last weekend i was working on one of those things where i started collecting components a long time ago but that still wasn’t finished. Time to finally use these 4 meters of LED strip!

Warm white LED strip

With this warm white LED strip i want to create my own lighting in the corner where our TV is mounted to the wall. The strips will be put on the back side of the TV, shining on the (white) wall. I’m not really into RGB strips; it’s nice to see (for a while), but it’s to colorful for my taste.

I’m going to use a JeeNode with 2 MOSFET plugs to control the 4 segments:

JeeNode and MOSFET plugs

All wirelessly controllable by the use of an XBee module of course; a new page on my Pronto TSU 9600 with a couple of sliders (like on the picture below) to control these 4 segments individually will do the rest:

Pronto sliders

But while i was trying to create some sort of experimental setup with 4 small pieces of LED strip on a piece of cardboard, something wentย  terribly wrong; somehow the wires of the 12V LED adapter made contact with something that couldn’t handle this amount of power: Poofff !! One voltage regulator blown to pieces. I don’t know how this could go wrong, cause I didn’t do this, it just happened!

VR fried

Well, this JeeNode doesn’t work anymore…

OK. Fortunately I had another unused JeeNode laying around so i could finish the test (it works brilliantly), but what to do with this JeeNode? Replace the VR (the only component with visual damage) or discard the whole JeeNode cause there will probably be more components that suffered from this? I don’t know; I’m the type of guy that didn’t even know what a pull-up resistor was a year ago, so I’ve got no clue ๐Ÿ™

First I’ll finish this TV LED project and when I’m almost running out of JeeNodes in the future, I’ll give this damaged one a try…

Going down even more

Now that i have no more PIR sensors in stock, I had to find me an alternative. The requirements: low power of course, it should be able to fit in the PIR enclosure i already have in use and not too expensive, cause I’ll need a lot of them. The ELV PIR13 seems to be the right candidate for the job; this would bring down the PIR power usage from 170 ยตA to 40 ยตA. I don’t have to tell you what that will do to battery life ๐Ÿ™‚

ELV PIR13: PCB 25 x 37 mm, 13 mm PIR

I’ve ordered a couple of these ELV PIR13’s and will build a 3rd motion sensor with one of these. In the meantime I also changed some things in the code to reduce the JeeNode power usage in power down mode even more: it went down from 20 ยตA to 6.5 ยตA. Calculations show a theoretical battery life of 200 weeks… well, i think the internal discharge will have screwed up the battery before that…

BTW, the 2 motion sensors that are currently being used, are still running fine on their first set of batteries.

Adding Light and Temperature

Since i removed a bunch of MS13 sensors recently, i am missing some input on what is going on at several places in our home. So while i was making a list of things i need in the near future, i realized i should extend the motion sensors a bit more, or otherwise i would lose the dark/light sensor the MS13 provided. And why not add temperature as well; cause that would mean i could do without the Oregon sensors also. I mean, why use 2 sensor devices (one only for temperature and another one for motion and light) when you can combine it all into one? Let’s have a look at temperature…

I still have 10 DS1820 1-Wire sensors somewhere from the days when i started with Domotica, but i never used them; maybe now i finally found a purpose for them? Let’s connect a few to an Arduino and see ifย  i can get a temperature reading:

Arduino with 3 x DS1820

Arduino with 3 x DS1820

And of course, there’s a library to use 1-Wire devices with an Arduino.. so before i knew it, i was polling the temperature of 3 DS1820s ๐Ÿ™‚

Addr:10 6C 5 CA 0 8 0 C3ย  Temp=25.50 grC
Addr:10 33 EC 3 1 8 0 E1ย  Temp=25.50 grC
Addr:10 FB 90 C9 0 8 0 1Aย  Temp=25.50 grC

Addr:10 6C 5 CA 0 8 0 C3ย  Temp=25.50 grC
Addr:10 33 EC 3 1 8 0 E1ย  Temp=25.50 grC
Addr:10 FB 90 C9 0 8 0 1Aย  Temp=25.50 grC

Addr:10 6C 5 CA 0 8 0 C3ย  Temp=25.50 grC
Addr:10 33 EC 3 1 8 0 E1ย  Temp=25.50 grC
Addr:10 FB 90 C9 0 8 0 1Aย  Temp=25.50 grC

Add an additional LDR and I’m done; ready to replace a large part of all my sensors: all remaining MS13s and most of my Oregon Scientific Temperature & Humidity sensors with my own ๐Ÿ™‚

Motion sensor v2 built and in use

Two motion sensors v2 are in use right now, yippee!

I upgraded an existing v1 sensor to a v2 and built a new one. The v2 sensor specs are very different from the v1 but much more promising, yet all i needed to do to was soldering the digital output of the PIR to another JeeNode port (namely ATmega INT1) and use a different digital port for serial I/O with the XBee. Oh, and upload a new sketch of course. Now i have 2 identical v2 sensors:

v1 upgraded to v2

Looking back at how this motion sensor evolved i am wondering, why didn’t i think of interrupts in the first place… not very smart actually..

Or maybe i did think about interrupts but unconsciously thought it would be to hard for me to handle already, cause that’s what you read all the time: interrupts are a tough subject! Maybe it is, but i didn’t notice that yet! ๐Ÿ™‚

So now I’ve got 2 motion sensors with the following features:

  • powered by 3 * 1.2V, 2000 mAh rechargeable batteries;
  • PIR with digital output, 100ยตA standby power usage and 5m detection range;
  • a JeeNode that’s effectively running only a total of about 180 seconds per day (0.2 %), even with 350-400 motion reports and lots of heartbeats. The rest of the time the JeeNode is in power down mode;
  • it’s ZigBee based which is better than 433 MHz in my opinion, especially when you’ve got a lot of sensors;
  • relatively small sensor housing compared to commercial (mostly big and ugly) products;
  • completely DIY so everything is how i want it to be;
  • interrupt-based, the best you can get I’d say;
  • need i go on?ย  ๐Ÿ™‚

I’m gonna monitor this sensor very closely in the coming months and learn from it. Here you see one of the sensors being used in the kitchen:

Motion v2 in the kitchen

Finished? Almost; some loose ends in the sketch. Maybe it can be made even smaller/faster/less energy consuming. But I’ll look into that when the 3rd sensor is built.

Update 2010-09-16:

The sketch that’s currently running on these sensors can be found here; the Sleep library i currently use can be found here .

Motion Sensor v2

Here it is, Motion Sensor v2. Not much different from v1 really, the only thing that has changed is that the PIR output has moved to an interrupt pin. And the sketch looks somewhat different here and there. Later this week i’ll build my 2nd motion sensor and start using it right away; i’m very curious about the results! I’ll also change my 1st motion sensor that’s already in use, to an interrupt driven model. Don’t want to wait for what will happen with those batteries…

The JeeNode is completely powered down most of the time. It only gets woken up by the Watchdog timer every 8 seconds or when motion is detected. But even when motion is detected, it’s powered down most of the time, cause a ‘blip’ sent to my Domotica System every 4 seconds during continuous motion is more than enough.

When the motion interrupt is triggered, the ‘blip’ is sent to my system, followed by a power down for 4 seconds without interrupt trigger set. When those 4 seconds have passed (wake up is done by the watchdog timer) a power down is done with interrupt trigger and the whole loop starts all over again. Capice? It doesn’t get much easier than this ๐Ÿ™‚

And of course there’s a heartbeat sent every 64 (8 times 8 ) seconds.

Adding Sense Control

While i was quite happy yesterday with the new way i’m going to handle things on the JeeNode regarding the motion sensor (PIR), i already knew i wasn’t finished yet; this was nice, but only a first step.

Cause what i had created was an IRQ being fired when the input becomes low. Well, the PIR output becomes high when there’s motion detected, so this is unusable, actually. For a brief moment i considered using a transistor as a NOT gate to invert the PIR output, but there had to be an easier way. Why would you only be able to activate an External Interrupt when a pin becomes low?? I read some topics on various forums, but those were very contradictory; some said i could, some said otherwise. OK, in that case, i’ll sort it out myself .. cause i really need interrupts based on a rise or a change!

Page 71 of the ATmega datasheet learned me that INT0 and INT1 indeed have Interrupt Sense Control and it’s only a matter of setting the right bits in the External Interrupt Control Register A, aka EICRA:

Bit 3 and 2 of EICRA

So it can be done, only thing is to figure out how…

The Arduino attachInterrupt() function has a 2nd parameter with which you can control what triggers an interrupt; the values are the constants LOW, CHANGE, RISING and FALLING (found in wiring.h). So why didn’t that nice Sleep library i found earlier have this feature? All i can do is call this function:

void SleepClass::powerDownAndWakeupExternalEvent(uint8_t interruptNumber)
 attachInterrupt(interruptNumber, SleepClass::external_event_handler, LOW);

OK; changing things in the library depending on the kind of Sense Control i need for a specific sensor type is not an option of course, so i added a 2nd parameter to that function:

void SleepClass::powerDownAnd...Event(uint8_t interruptNumber, int mode)
 attachInterrupt(interruptNumber, SleepClass::external_event_handler, mode);


That’s better; now i can choose whatever Sense Control I want; I’ve checked all of them right away:

Sleep.powerDownAndWakeupExternalEvent(0, RISING);

What a surprise, its working, all of them! RISING is just what i need right now for the PIR; CHANGE is what i would need for a door sensor.

Now i’m already modifying libraries and I can even understand what

EICRA = (EICRA & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);

does… i wonder where or when (if ever) this will end…

But I’m still not finished! Cause with all this powering down going on, it has become increasingly hard to keep a notion of time; millis() has become useless cause how can i determine the time that has passed since the last power down? On the other hand, do i really need to know that? Time will tell ๐Ÿ™‚

Really powering down this time

Having a first set of batteries empty wasn’tย  funny.. they lasted only 7 weeks! Way to short. And i kept on thinking that it might not have been caused by a bad battery.. what could i do next? Wait another 7 weeks to find out that I’m wrong? Neh.. that didn’t feel the right thing to do; Power down as much as possible and use an external interrupt would possibly give the best results anyway, so why not start with that right now!

I started with attaching a push-button to an Arduino, using a pull-up resistor to keep the input high when the button isn’t pressed:

Arduino with push-button

After that i started reading about interrupts. Here’s a table that shows the Wake-up sources that are available in the various sleep modes:

ATmega48PA/88PA/168PA/328P Wake-up sources

Both things i need are available: INT0 and/or INT1 and the Watchdog Timer, so it was time to start sketching ๐Ÿ™‚

After 5 different sketches with all the same miserable results (freezing Arduino), i finally found a sleep library that did exactly what i wanted. I combined this library with code i had found earlier regarding setting up and using the Watchdog Timer, and what i have now, is just what i need. Below a sample of the Serial Monitor output and here is the sketch that produced it.

39171 I'm awake, caused by the WDT
39205 Sleeping...
39327 I'm awake, caused by the WDT
39362 Sleeping...
39484 I'm awake, caused by the WDT
39519 Sleeping...
39640 I'm awake, caused by the WDT
39674 Sleeping...
39796 I'm awake, caused by INT0
Doing some work...finished!
40257 Sleeping...
40377 I'm awake, caused by INT0
Doing some work...finished!
40839 Sleeping...
40960 I'm awake, caused by INT0
Doing some work...finished!
41421 Sleeping...
41542 I'm awake, caused by the WDT
41577 Sleeping...
41698 I'm awake, caused by INT0
Doing some work...finished!
42160 Sleeping...
42280 I'm awake, caused by the WDT
42315 Sleeping...
42437 I'm awake, caused by the WDT
42472 Sleeping...
42593 I'm awake, caused by the WDT
42628 Sleeping...

etc. etc.

Cool stuff! ๐Ÿ™‚ Let’s see how we can change the motion sensor to make use of this!

Dropping fast…

XBee Supply Voltage dropping fast!

Oops… the Supply Voltage on my motion sensor is already down to 3060 millivolts. Suddenly it’s dropping very fast; this sensor has been operational for more then 7 weeks now, with IIRC 2 new and 1 older rechargeable battery of a brand with which i’ve had bad experiences before. I hope that’s what is causing this, cause if not, i have some work to do ๐Ÿ™

The other 2 battery powered sensors are still doing fine, BTW:

Supply Voltages (click to view the realtime values)