Friday, April 24, 2015

Battery Operated Temperature Sensor: OK, Let's Build This Thing

The previous post in this series is here <link>.

Well, I've been testing, trying new ideas and even added a button to this thing for the last several weeks. I don't think I'm going to learn anything new in the short term, so I decided to solder everything down and turn it into a package that I can actually use.

I got some of these:

Those of you that have been following this project understand now why I wanted to confine the parts to half a breadboard. I can put all the parts on this and then have something I can put in some kind of enclosure. I stripped all the parts off the breadboard and put them on the new board.

Yep, I got the regulator, XBee, Arduino Mini Pro, sensor, and a push button on there. I mounted the active components in sockets so they'd be easy to change if I needed to. I also put a plug on the battery pack so I can unplug it if needed. I still have the monitor circuit for watching the battery level, that way I can tell when the batteries are starting to go flat.

It's a nice little package, even if I do have to say so myself. If I put the battery underneath the board, it is pretty compact as well:

I think I'll put it in a travel container for a bar of soap to play with it around the house for a few months. Here's the schematic for the final result:

I'm going to the 3V version of the MCP1700 as soon as they come in from Mouser. Those little devices are perfect for battery applications. The 3V version (opposed to the 3.3V) worked well with this combination of components because the battery drops to just under 2.9V before it shuts off. That way I've dropped the batteries down to a volt each, and there's essentially nothing left in there.

Notice the voltage divider on the battery input? That combination of values works well to monitor the battery voltage, but I had to calibrate it in the code. It's pretty easy, get your meter, measure the battery voltage and then adjust the code until you get the same reading ... done. This will hold essentially forever, but if you want to check it yearly or so, it's easy.

This particular device (there WILL be others) is going beside my bed. I'll have the temperature of my bedroom as well as a button to turn the light off eliminating the X10 controller I have there now. Remember, this is a smart device, I can program it to do other things over time, and probably will. I think having one in the guest room with a door sensor attached would be fun. I may put one in the attic to monitor the heat up there, and one hooked to a moisture sensor out in the garage would be great for keeping track of the water heater.

How long will the batteries last? I don't know exactly, but it should be many months, a little less than a year. I can't measure the power usage, it's too low for anything I have. I removed the led from the Arduino board and feed the power behind the power regulator, so I have no losses there. I suspect it's using around 10 micro amps when asleep and not much when it's running. I'm going to set it to 5 seconds awake and 115 seconds asleep which will cut the drain in half compared to the level I ran it at in testing. If it runs down too soon, there's still several things I can do, but they won't actually gain me very much. Slower clock speed, mosfet switch for the power to the sensor and XBee, that kind of thing. The one thing that will really increase the time between battery changes is to simply use four batteries. The regulator I used can take it and it's not much more space. I'll try the three battery setup for as long as it runs to get a feel for what's going on.

My new NAS came in and is installed, so I guess I'll move on to something on it now. I'll build more of these as time permits, I have enough XBees for a bunch.

The next entry on this project is here <link>


  1. Hot damn, your so close to what I want to do. You have a couple posts that just tease and wet my appetite, but like you I have searched high and low for zigbee full stack protocol examples and have come up dry. Unfortunately you like just about everyone else I can find want to do the opposite side of zigbee that I'm looking for.

    I want to make a device, or rather a gateway for multiple devices (I don't believe I can have it masquerade as multiple devices, but I think it allows for multiple Endpoints, which hopefully will do what I'm looking for), that interfaces with a standardized zigbee controller. Not a home brewed one, but one of the many already made. I know manufactures haven't been perfect with the implementation of the protocol, and there are some interoperability issues, but for the most part if you have a decent off the shelf controller you can have a good chance of grabbing a random zigbee device and get them to place nice together.

    I'm just searching for an example of making that zigbee device with XBee, and having it play nicely with a public profile.

    Did I miss a project where you did this? Please tell me you have some remote notion of turning this temperature sensor into one.

    The general idea is having an off the shelf controller that has a nice GUI, which the other people in my house can use and not curse my name because I built it myself and got it half baked before I went chasing after a different shinny object.

    1. What you want to do is create your very own ZigBee end device, then hook it to an off the shelf controller like the Casa Verde? Not a bad idea, if you have a Casa Verde or are looking for an excuse to get one.

      I've hooked into two "ZigBee" devices: the Iris switch from Lowes, and the Centralab switch. This Iris switch is Zigbee in name only, it doesn't follow the protocol well enough. The Centralab is really close.

      The reason I'm on the other side of the implementation is that I don't want someone else's controller. That's where the limits are in implementation.The reason I build the end devices and sensors is because it's fun to learn about these things. That and the fact that most of them are too darn expensive for me.

      I, like you, would have started off with something that I just bought, and I guess I sort of did with X10, but quickly got tired of things not working as advertised and being restricted in what they could do.

      It's certainly possible to build a ZigBee switch or light control, but the code would be huge and wouldn't fit on an arduino. If you have the bucks, you can buy a ZigBee stack, but I'm not going to waste money on software I can't share because of some licensing agreement.

      But, someday, when my heirs want to sell this house, nothing will match products they can buy from some home automation store. That will be my last dig at them.

    2. I am looking at the same route you are Miles. I have an Almond+ (while still very rough and very beta... I like it) that I want to continue to use as my controller. I already have a few Arduino's I placed around that report to (I coded to their API to send data to them) every 10min. But I would prefer to have it send to both... Almond+ for active use and house decisions and Weathercloud for long-term storage and data analysis. Although I have been debating about rolling my own cloud data site for that also...

  2. Dave, did you look at putting rechargeable batteries and a charging circuit into this (and if you wrote about that, sorry I somehow missed it)? Just wondering if that would be easier for the outdoor ones so you could have a simple solar circuit to keep them topped off and the indoor ones could be powered by a wall-wart with battery backup.

    1. No, I haven't looked into that ... yet. It's a really good idea for devices that need to be outside, why not use the sun for a power supply? I bet I get to that kind of project at some point; lots of sun here in Arizona.

      I wanted a device that didn't have a cord hooking it to the wall. I've built a few devices that have a wall wart hooked to them and they work fine, but it would be really cool to be able to put something anywhere I wanted. Sure, I have to buy batteries for it, but already have to do that for the other things around the house.

  3. My next device will probably be a replacement for my existing doorbell. I need a radio mid house to relay packets from outside and my doorbell sucks ass anyhow. Along with being a doorbell, it can announce house events (doors opening and such) or anything else I'd like to do. Great thing is I've already got a source of power (16VAC) that can be converted to what I need at the location. Screw the store bought, ready made solutions....

    1. That's a good idea. You can also set up something to totally customize the doorbell. Play Christmas songs, fireworks in July, screams around Halloween.

      You do realize that I'm totally going to steal that idea ... right?