Idle Hands
For some reason, every once in a while I get the feeling that I don't have enough to do. I should realize I have many projects going on at once and should finish one before starting another; but I don't. Recently I heard about an issue my father has with a setup he has where he needs to take a temperature wirelessly and I thought "I'm not doing anything else, let me start a new project." And so started my long journey into the world of micro-controllers and Arduinos.
Like Father Like Son
I'm going to give just a little background about why my father needs to take a temperature wirelessly. You see my father is like me (or rather I'm like him) in that when we are idle we make up projects to do. One such project for him was to setup a wood boiler in the garage, to heat water, and send the hot water underground to his home. Where he could use it to heat his house, and be used as hot water for showers and faucets. He lives in a somewhat secluded place, surrounded by wooded areas. Every year a few big storms will go through and knock down a some trees. He will split it up, stack it for drying, and burn it during the winter to help cut down on the gas bill for heating the house. As an added bonus the extra heat put off by the boiler helps keep his garage warm in the winter, making it easier to work on the cars. When controlling this system it's important to know what the temperature is of the water inside the boiler, to help him know when to add more wood, and to adjust the amount of oxygen in the mix. There is also an automatic blower in the system that helps stoke the flame, and help the boiler burn more efficiently.
Originally my father used a car thermostat to tell him the temperature of the boiler, from inside his house. He took the temperature sensor from a car, and put it in the boiler in the garage. He then ran the signal wires underground to the house, where he hooked it up to a temperature gauge from a car. This worked all right but the gauge's range was not too wide, and the gauge is too small to get a accurate reading. Also the wires underground are about 60 feet long. Much longer than the intended length of 5-10 feet that you have from the engine to your car dash, which gives an even more inaccurate reading.
New Design
So I set out to try to find him a wireless solution. A way for him to tell the temperature of some water from about 50 feet away. The temperature may get as high as 230F, but will likely be between 150F and 200F. I couldn't find an off-the-shelf product that was cheap and gave the ranges we needed. There are several weather devices that also tell humidity and forecast, but the temperature range only goes up to 150F. I realized the perfect solution would be either a Thermocouple or and RTD. The easiest way I knew of taking a thermocouple reading was with a level shifter and a DAQ card, but that would require 2 PCs talking over WiFi, and I didn't have 2 PCs and didn't want all the extra hardware. The perfect solution was something I had heard about but never used. Arduino.
I knew that there were LCD displays, Wireless modules, and thermocouple devices for Arduinos, so I knew technically it was possible. But I wanted to do it as cheaply as possible. It also seemed a little overkill to use two Arduinos just to send one temperature signal. So I figured I could add a few features for a little more cost. Like the ability to read the temperature in the garage, or to know when the blower turns on.
Initial Development
I bought 2 Arduino Unos for development, and intended on making my own out of raw parts when I was done. I also bought a 16x2 LCD display, a MAX6675 Thermocouple reader, an LM35 ambient temperature device, a few bread boards for development, a perforated board for final build, a cheap wireless transmitting device, and a few other small odds and ends. I'll get to total cost later but my goal was less than $100 after shipping. If you plan on making your own feel free to use a different LCD and possibly LM36. Alot of these parts can be swapped out with minor (if any) changes to the software.
My first experience with Arduino was a good one. For first time users there are tons of examples with the development software. I've used some other text based programming environments that are easier to use but for the most part it was good enough. I started by trying to interface with the LCD, and the MAX6675 thermocouple. Both had examples and libraries so it didn't take long to display the temperature on the LCD. I also allowed the back-light to turn on and off on the LCD by reading an analog in pin looking for a button press. Next I wired up the LM35 which takes an ambient temperature reading, which isn't as accurate, or as large of range as the MAX6675, but it is cheap and only takes one analog pin, where the MAX6675 takes at least 3 digital pins. The last thing to interface with was the blower. The blower it self is powered by a 120VAC relay which is controlled with its own temperature sensor. The easiest way I thought of detecting when the blower was turned on, was to tap into the 120VAC signal that powers the blower, and put that into a voltage adapter, which would output a low voltage DC signal that can go to another analog in pin on the Arduino. So when the blower turns on the Arduino will see a voltage greater than zero volts.
Wireless Issues
All this worked just fine, so the next step was the wireless module. Wanting to go cheap I choose a Superregeneration transmitter and receiver pair with two Arduinos. The devices them selves are getting harder to find and I ended up getting the pair on ebay. I went with them instead of one Arduino and two Xbees wireless devices because of cost. Two Xbees definitely have a longer range, and better reliability than the cheap wireless modules. But I only needed to send about 4 bytes of data a second, nothing very high speed, and nothing system critical. If we lost half the messages the only repercussion would be that the LCD would only be updated every two seconds. For this system getting one update a minute would be sufficient. The cost of two Arduinos, and the wireless module is about $60 if I buy the Arduino Unos pre-built, but only about $30 if I build them from scratch. The cost of an Arduino and two Xbees is $75 if I buy the Arduino Uno pre-build, and $60 if I build it from scratch.
I did have issues with the cheap wireless devices. The first issue was finding some. There are plenty of posts people have made, explaining how to use these cheap wireless modules for simple communication, but almost all of them say to buy them from SparkFun. Unfortunetally SparkFun no longer caries the Receiver, they do have the Transmitters at the moment for some reason. So I Googled and found a few places in Europe but I was hoping for some thing closer. I ended up going to Ebay and found a pair that seemed the same but they weren't. Even so the vendor said that they would work with an Arduino Uno.
After receiving the transmitter receiver pair I had issues getting it to work. Eventually I convinced the vendor that it was broken and they send a new transmitter and receiver. After I still couldn't get it to work I realized that the transmitter and receiver were backwards. No where in their documentation do they say which is which. They just show which pins are Data, they don't say Data In or Data Out. In either case I got two transmitters and two receivers for $6 with free shipping.
Prototyping
Like most engineering challenges, it's a good idea to work your way up, proving out design as you go. So for me the first thing was to interface with the LCD. I figured I would use it to display debug information and it would help prove out the rest. I soon realized that the Arduino has a simple Serial Port monitor so performing debug information is simple. After that I hooked up the MAX6675 thermocouple, the LM35, and a switch to turn on and off the LCD display. I put all of this on one Arduino, but in the final build one Arduino will display the other will read data. Because of this it meant that all of the IO I needed to send and receive data could be on one Arduino. So in the future if I wanted to add an LCD to the transmitter I could without needing more IO, or any much code changes. Here are some pictures of the build at this point.
After the basics were working with the Unos I bought the parts to make my own Arduinos on a bread board or perfboard. It costs about $20 in parts for both Arduinos after shipping cost. After a few tutorials, and burning the boot-loader to the blank ATMega328s I had it working. I put them in a few nice boxes, added a few voltage adapters, and put the transmitter on a tether so we could get it as close to the receiver as possible. The two would be about 50 feet away, going through two exterior walls, which in my tests is about the limit of them so I wanted to improve my chances of getting valid data. I added some code to clear the display if an update isn't received within one minute. This means as long as there are numbers on the display, the data must be one minute or less old. I also added some code to average the last 4 valid data points, and to allow the display to be in degrees C or F.
Here are a few photos, of the breadboard arduino and the perforated board for the receiver.
Cost
MAX6675: $21.13
LM35, Protoboard, Button, POT: $4.13
Parts for 2 Arduinos, ATMEGA328, Sockets, Caps, Voltage regulators, Crystals: $17.69
Wireless Module (ebay): $6
LCD 16 X 2: 15.94
Total (including shipping): $64.89
Now this total is a little deceiving for a few reasons. For this project I also bought two Arduino Unos for development, and some breadboards. I also had some parts just sitting around. Here are a few things that I had that didn't cost me anything for the build, but would cost me if I needed to make more.
2 Voltage regulators, 6V-12V 400mA each.
Voltage regulator, 3V 100mA
2 1KOhm resistors 1/4 Watt
2 Resistors of same size >500KOhm
One small project box
One medium project box
One large project box
2 DB9 solider cup female
2 DB9 solider cup male
2 DB9 hoods
Ethernet cable, about 5 feet
Other assorted wires, total around 8 feet
It's hard to say that if I had to buy all of these that the project would still be under $100. Voltage regulators new are over priced but any decent garage sale has them in the free box, or usually less than a dollar.
In any case, here are some final images and video of the transmitter and receiver in action.
Functionality Video
Internals Video
DIY
If your interested in making your own wireless temperature device, or you are just curious about how I did it, take a look at my source. As usual there is no warranty or any type of support with this source. The source has two libraries that are needed in addition to the ones that come with the Arduino development environment, one for interfacing with the MAX6675, and one for performing the wireless communication using the VirtualWire. Also included with the source is a text file that explains the pinout for the receiver and transmitter.
Download: Source Code
For some reason, every once in a while I get the feeling that I don't have enough to do. I should realize I have many projects going on at once and should finish one before starting another; but I don't. Recently I heard about an issue my father has with a setup he has where he needs to take a temperature wirelessly and I thought "I'm not doing anything else, let me start a new project." And so started my long journey into the world of micro-controllers and Arduinos.
Like Father Like Son
I'm going to give just a little background about why my father needs to take a temperature wirelessly. You see my father is like me (or rather I'm like him) in that when we are idle we make up projects to do. One such project for him was to setup a wood boiler in the garage, to heat water, and send the hot water underground to his home. Where he could use it to heat his house, and be used as hot water for showers and faucets. He lives in a somewhat secluded place, surrounded by wooded areas. Every year a few big storms will go through and knock down a some trees. He will split it up, stack it for drying, and burn it during the winter to help cut down on the gas bill for heating the house. As an added bonus the extra heat put off by the boiler helps keep his garage warm in the winter, making it easier to work on the cars. When controlling this system it's important to know what the temperature is of the water inside the boiler, to help him know when to add more wood, and to adjust the amount of oxygen in the mix. There is also an automatic blower in the system that helps stoke the flame, and help the boiler burn more efficiently.
Originally my father used a car thermostat to tell him the temperature of the boiler, from inside his house. He took the temperature sensor from a car, and put it in the boiler in the garage. He then ran the signal wires underground to the house, where he hooked it up to a temperature gauge from a car. This worked all right but the gauge's range was not too wide, and the gauge is too small to get a accurate reading. Also the wires underground are about 60 feet long. Much longer than the intended length of 5-10 feet that you have from the engine to your car dash, which gives an even more inaccurate reading.
New Design
So I set out to try to find him a wireless solution. A way for him to tell the temperature of some water from about 50 feet away. The temperature may get as high as 230F, but will likely be between 150F and 200F. I couldn't find an off-the-shelf product that was cheap and gave the ranges we needed. There are several weather devices that also tell humidity and forecast, but the temperature range only goes up to 150F. I realized the perfect solution would be either a Thermocouple or and RTD. The easiest way I knew of taking a thermocouple reading was with a level shifter and a DAQ card, but that would require 2 PCs talking over WiFi, and I didn't have 2 PCs and didn't want all the extra hardware. The perfect solution was something I had heard about but never used. Arduino.
I knew that there were LCD displays, Wireless modules, and thermocouple devices for Arduinos, so I knew technically it was possible. But I wanted to do it as cheaply as possible. It also seemed a little overkill to use two Arduinos just to send one temperature signal. So I figured I could add a few features for a little more cost. Like the ability to read the temperature in the garage, or to know when the blower turns on.
Initial Development
I bought 2 Arduino Unos for development, and intended on making my own out of raw parts when I was done. I also bought a 16x2 LCD display, a MAX6675 Thermocouple reader, an LM35 ambient temperature device, a few bread boards for development, a perforated board for final build, a cheap wireless transmitting device, and a few other small odds and ends. I'll get to total cost later but my goal was less than $100 after shipping. If you plan on making your own feel free to use a different LCD and possibly LM36. Alot of these parts can be swapped out with minor (if any) changes to the software.
My first experience with Arduino was a good one. For first time users there are tons of examples with the development software. I've used some other text based programming environments that are easier to use but for the most part it was good enough. I started by trying to interface with the LCD, and the MAX6675 thermocouple. Both had examples and libraries so it didn't take long to display the temperature on the LCD. I also allowed the back-light to turn on and off on the LCD by reading an analog in pin looking for a button press. Next I wired up the LM35 which takes an ambient temperature reading, which isn't as accurate, or as large of range as the MAX6675, but it is cheap and only takes one analog pin, where the MAX6675 takes at least 3 digital pins. The last thing to interface with was the blower. The blower it self is powered by a 120VAC relay which is controlled with its own temperature sensor. The easiest way I thought of detecting when the blower was turned on, was to tap into the 120VAC signal that powers the blower, and put that into a voltage adapter, which would output a low voltage DC signal that can go to another analog in pin on the Arduino. So when the blower turns on the Arduino will see a voltage greater than zero volts.
Wireless Issues
All this worked just fine, so the next step was the wireless module. Wanting to go cheap I choose a Superregeneration transmitter and receiver pair with two Arduinos. The devices them selves are getting harder to find and I ended up getting the pair on ebay. I went with them instead of one Arduino and two Xbees wireless devices because of cost. Two Xbees definitely have a longer range, and better reliability than the cheap wireless modules. But I only needed to send about 4 bytes of data a second, nothing very high speed, and nothing system critical. If we lost half the messages the only repercussion would be that the LCD would only be updated every two seconds. For this system getting one update a minute would be sufficient. The cost of two Arduinos, and the wireless module is about $60 if I buy the Arduino Unos pre-built, but only about $30 if I build them from scratch. The cost of an Arduino and two Xbees is $75 if I buy the Arduino Uno pre-build, and $60 if I build it from scratch.
I did have issues with the cheap wireless devices. The first issue was finding some. There are plenty of posts people have made, explaining how to use these cheap wireless modules for simple communication, but almost all of them say to buy them from SparkFun. Unfortunetally SparkFun no longer caries the Receiver, they do have the Transmitters at the moment for some reason. So I Googled and found a few places in Europe but I was hoping for some thing closer. I ended up going to Ebay and found a pair that seemed the same but they weren't. Even so the vendor said that they would work with an Arduino Uno.
After receiving the transmitter receiver pair I had issues getting it to work. Eventually I convinced the vendor that it was broken and they send a new transmitter and receiver. After I still couldn't get it to work I realized that the transmitter and receiver were backwards. No where in their documentation do they say which is which. They just show which pins are Data, they don't say Data In or Data Out. In either case I got two transmitters and two receivers for $6 with free shipping.
Prototyping
Like most engineering challenges, it's a good idea to work your way up, proving out design as you go. So for me the first thing was to interface with the LCD. I figured I would use it to display debug information and it would help prove out the rest. I soon realized that the Arduino has a simple Serial Port monitor so performing debug information is simple. After that I hooked up the MAX6675 thermocouple, the LM35, and a switch to turn on and off the LCD display. I put all of this on one Arduino, but in the final build one Arduino will display the other will read data. Because of this it meant that all of the IO I needed to send and receive data could be on one Arduino. So in the future if I wanted to add an LCD to the transmitter I could without needing more IO, or any much code changes. Here are some pictures of the build at this point.
After the basics were working with the Unos I bought the parts to make my own Arduinos on a bread board or perfboard. It costs about $20 in parts for both Arduinos after shipping cost. After a few tutorials, and burning the boot-loader to the blank ATMega328s I had it working. I put them in a few nice boxes, added a few voltage adapters, and put the transmitter on a tether so we could get it as close to the receiver as possible. The two would be about 50 feet away, going through two exterior walls, which in my tests is about the limit of them so I wanted to improve my chances of getting valid data. I added some code to clear the display if an update isn't received within one minute. This means as long as there are numbers on the display, the data must be one minute or less old. I also added some code to average the last 4 valid data points, and to allow the display to be in degrees C or F.
Here are a few photos, of the breadboard arduino and the perforated board for the receiver.
Cost
MAX6675: $21.13
LM35, Protoboard, Button, POT: $4.13
Parts for 2 Arduinos, ATMEGA328, Sockets, Caps, Voltage regulators, Crystals: $17.69
Wireless Module (ebay): $6
LCD 16 X 2: 15.94
Total (including shipping): $64.89
Now this total is a little deceiving for a few reasons. For this project I also bought two Arduino Unos for development, and some breadboards. I also had some parts just sitting around. Here are a few things that I had that didn't cost me anything for the build, but would cost me if I needed to make more.
2 Voltage regulators, 6V-12V 400mA each.
Voltage regulator, 3V 100mA
2 1KOhm resistors 1/4 Watt
2 Resistors of same size >500KOhm
One small project box
One medium project box
One large project box
2 DB9 solider cup female
2 DB9 solider cup male
2 DB9 hoods
Ethernet cable, about 5 feet
Other assorted wires, total around 8 feet
It's hard to say that if I had to buy all of these that the project would still be under $100. Voltage regulators new are over priced but any decent garage sale has them in the free box, or usually less than a dollar.
In any case, here are some final images and video of the transmitter and receiver in action.
Functionality Video
Internals Video
DIY
If your interested in making your own wireless temperature device, or you are just curious about how I did it, take a look at my source. As usual there is no warranty or any type of support with this source. The source has two libraries that are needed in addition to the ones that come with the Arduino development environment, one for interfacing with the MAX6675, and one for performing the wireless communication using the VirtualWire. Also included with the source is a text file that explains the pinout for the receiver and transmitter.
Download: Source Code