A Wireless Motion Sensor Array – Part 4

POWER!

Yea, I thought the hard part of making these sensors was over too. Boy was I wrong. Prototyping on a board I could plug in to the wall was pretty easy. Going from zero to a working transmitter/receiver took a few hours over a couple of days and that was mostly because I’m a newbie. It all works but now it is time to make it practical.

One of the requirements I have for the remote sensors is portability. That means low weight, small size and battery powered.

Using a Duemilanove for the “real” sensors is pretty much out of the question. First, it has too much stuff on it. I don’t need the USB connection or barrel power supply and the voltage regulator on the Duemilanove isn’t a terribly good one.

Side Step – Voltage Regulation

I knew about voltage regulators before I started playing with Arduinos but I never understood how or why they worked. Voltage regulation is essential for anyelectrical device since all electronics are sensitive to voltage and most have an optimal operating voltage. Keep in mind that ALL devices have a tolerance. Just because the datasheet says 3 volts doesn’t mean it won’t work at 2.7, it just means it works less reliably. The Duemilanove data sheet says it needs 6-20 volts of input. That’s misleading. It NEEDS 5 volts, but you can plug anything from a 6 volt to 20 volt power supply into it because it has a voltage regulator on it rated to regulate anything from as much as 20 volts down to the 5 volts needed. Voltage regulators ALWAYS regulate DOWN. The voltage regulator on my Duemilanove is a 269-5G made by On Semiconductor. It has a 1 volt dropout, which means that voltage drops 1 volt from input to output. If you want 5V on the business side of the regulator you better feed it at least 6V (more is better, to an extent) on the input side. Voltage regulators convert excess voltage to heat which is why voltage regulators have that nifty looking heat sink attached to them. The more regulation, the more heat. It’s a wasteful but necessary thing sometimes.

The two most important things you want to look at when shopping for low power a voltage regulator is dropout (the voltage drop between input and output) and the quiescent current rating. I never knew about quiescent current until tackling this project. It’s the minimum amount of current that a voltage regulator will draw all the time, even if whatever is connected to the back end doesn’t need any power. The 269-5G regulator has a 5-20mA quiescent rating. Holy crap – that means the voltage regulator itself could draw 5 to 20 mA without the Arduino doing anything. As I’m fond of saying “Well there’s your problem!”.

It’s worth saying (so someone doesn’t point it out), that the current rating of a voltage regulator is also very important. That the maximum amount of current that it can provide. The 269-5G is rated at 800mA of current (uh, that’s a lot ;-)).

It’s time to find a new Arduino compatible board that I can more easily power with a battery but first I checked the voltage requirements for all of my components. I wanted to keep things as simple as possible so I would like to run everything off the same battery and voltage if possible. The 315MHz transmitter datasheet says it will work with 2-12 volts and the PIR sensor I’m using operates at 3.3 volts as well – that’s good news. Is there an Arduino out there that runs at less than 5 volts? There is! Sparkfun has the Arduino Pro and Arduino Pro Mini running with 3.3 volts at 8MHz. PERFECT! I bought some and I’ll pretend like I did that between this paragraph and the next.

Wow this thing is cool! It’s TINY!

I read in the Sparkfun description when I bought it that I’d also need an FTDI Cable for programming, so I picked one of those up too.

The first thing I did was to solder some headers on where the FTDI cable attaches, and then went crazy and soldered headers to the rest of the pins too. You don’t have to solder them on as holding the headers through the holes with the cable attached will work but I wanted to play with this thing some so I went ahead and attached headers to all the pins (I sort of regret that now, I should have just soldered the FTDI cable connector!):

Arduino Pro Mini 3.3v with headers

Believe it or not, these little things have the same IO pin configuration as the Duemilanove which makes hooking all the stuff up very easy. Just transfer everything over to the mini – same pins.

The biggest difference moving to the “Pro” version is the lack of output power pins. The Pro Mini has 2 power inputs, one for already-regulated power (that’s VCC), and one for “raw” power, that is anything over 3 volts for this little thing. If you plug power into the VCC pin that means it will run through the voltage regulator. The regulator on the mini is labeled KB33, which is an MIC5205 linear voltage regulator from Micrel (datasheet here). It is a very low dropout (17mv at 150mA) and very low quiescent current (1-5 uA, that’s MICRO amps). Perfect for low power devices. It looks like this mini is going to fit the bill quite nicely.

The same sketch will work with the Mini but only if you’re using the Arduino version 0019 (released in September of 2010). I have absolutely no idea why it wouldn’t work before (everyone said it should) but as soon as I tried 0019 and selected the Pro 3.3 volt board from the Boards menu, everything “just worked”. I’m not complaining though – no one I asked could tell me why it didn’t work with the mini but worked with the Duemilanove.

The Battery

At first I wanted to use 2 AA batteries to power the remote sensor but after some experimentation I found that it just won’t work reliably. 2 1.5v batteries will give 4ish volts under no load but as soon as I wired it up and tried it the device performance went to hell. The PIR sensor would randomly trip and the whole thing was just unreliable. Since both the Arduino and the PIR sensor have voltage regulators on board and the transmitter will work with up to 12 volts, I was free to use a 4AA pack but that was too heavy, I want these things to weigh as little as possible.

Enter LiPo (lithium polymer) batteries. Before I go further I’d like to say BE VERY CAREFUL WITH THESETHEY CAN EXPLODE if they are charged or discharged improperly. Typically an IC is used for discharge/charge protection so don’t go willy-nilly and yank the battery out of the nearest cell phone and try to use it. Sparkfun sells a few LiPo battery packs with the appropriate IC in place for discharge protection and a LiPo charger that won’t turn the thing into a grenade when you charge it up.

I’m using the LiPo 900 mAH battery pack from Sparkfun. Unfortunately those are out of stock as of this writing so if I can find them somewhere else I’ll edit this post.

I ended up powering the Arduino with the RAW power pin. The voltage from this battery pack fully charged was about 4.5 volts with no load and the built-in IC will cut all power if the pack drops to 2.7 volts – all of that is within the tolerance listed on the Mini’s datasheet. If you’re using a battery pack that is more than 4.5 volts I recommend you use the VCC power pin (which will regulate the voltage to the Arduino). By recommend, I mean you’ll blow the thing up if you don’t 😉

Still too much power?

Yep. Even with this tiny little thing I’m still pulling 10mA or so when it is sitting idle. That might not sound like much but my 900 mAH battery pack is only going to last 90 hours or so like that and I don’t want to charge the battery every 3 days.

The solution? Put the Arduino to sleep and use an interrupt to wake it up. In sleep mode the Arduino will only draw a few microamps of current and we can make the PIR sensor trip signal the Arduino to wake up and send the alarm (then sleep again).

Here is the code came up with, largely adapted from the above link and a few others.

Upload this sketch to the remote sensor Mini :

The idle power requirement now is a fraction of what it was before – around 200 microamps. That’s still more than it probably could be but I think the voltage regulator on the PIR sensor is partially to blame and I don’t want to take it off the board right now.

Here is the finished product using an enclosure I built from a Sparkfun box. By built I mean I cut a hole in the front of it and poked the PIR sensor through, then stuffed the rest in the box 😉

Remote sensor wired up and powered in a Sparkfun parts box.

If you kept the receiver build from the first step then you can use this thing now. Put the sensor box somewhere and the receiver will beep every time someone walks by it!

This is as far as I’ve taken the project so far. I didn’t write these articles as I was doing all of this (as is pretty obvious) so everything isn’t exactly the way I want it.

On my to-do list is :

Come up with a finished receiver or two. I’ll probably use a buzzer, a switch to mute the buzzer, then a groups of LEDs that I’ll label with the sensor number (or more likely, “kitchen”, “back room”, “porch”, etc). I’ll post the finished product and finished receiver code once I get it all done. For now, this has been in my house running non-stop for 6 days now and the beeping is driving me crazy (hence the mute button idea). I have a feeling I’ll be finishing the real receiver tonight 😉

Questions and comments always welcome!

* A follow-up from 6 weeks later. The li-po battery I used hadn’t been charged for well over a month when I first plugged it in but I decided to use it anyway to see how long it would last. It registered 4.2 volts with a multimeter under no load initially. Just this evening the sensor powered by that first battery started acting strange. It started tripping somewhat randomly. I checked the battery again with a multimeter and it registered 3.8 volts under no load. Since the whole board needs at least 3.3V to function properly I’d say the load is dropping the voltage and the battery needs charged. Still, 6 weeks with a battery that wasn’t even fully charged when I first started using it isn’t bad! It’s worth noting that this sensor is in the busiest part of the house and since I work from home, it was *constantly* being tripped. I swapped out the old battery for a newly charged one and will re-visit it again in 6 weeks.

2 comments to A Wireless Motion Sensor Array – Part 4

  • Kasey Riggs

    I want to build this project for a class. I am a second year electronics student. We have a $50 or so limit. Approximately how much did you spend on all of you components? Also, do you have an updated list of everything you used in the working model? Thank you.
    Kasey Riggs

    • The Arduino Mini is around $19 from Sparkfun, the Duemilanove (or new Uno) is around $30, the PIR sensor is around $10 from Adafruit (read the article, my code only works with the Adafruit-types, not the Sparkfun ones!). The RF link is something like $8-10 and you can get them from Sparkfun or order from China (seeedstudio) at a lower price (you can use virtually any RF device with the Virtualwire Arduino library). The li-po battery I used was pretty expensive at around $9 (not to mention the charger you need). The enclosures I used were expensive, too, but I don’t remember exactly what I paid for them (you can use cheap-o ones from RadioShack).

      You can make different design choices and cut the price significantly. My best-guess head math is putting the receiver and 1 sensor at around $90. I ended up finishing the receiver (I need to post a picture) but I used stuff I had laying around (LEDs, a buzzer, a switch, a wall wart power supply and a case) so I’m not sure on the final cost there.

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">