It has become cold in these parts -- below zero (fahrenheit) all day. My mini-root cellar (instructable) is no longer able to keep the temperature above freezing. So I had to put in a heater. Do you know how hard it is to find a heater that just keeps things from freezing?
To solve the problem I made a generic, arduino controlled, smart extension cord, then added a temperature sensor and plugged in a heater. I am sure others will find many ways to use a generic arduino smart extension cord.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Parts List
First the parts list:
An extension cord. I chose a 3 prong model I had lying around.
A 12 volt DC power adapter. This runs the arduino, and switches the relay.
An arduino. Ok, in this case its a funduino.
A power relay. I used the SLA-12VDC-SL-A which I purchase from DX for about $2 This thing has a 30A rating!
Components required to switch a relay with an Arduino, as illustrated in the instructable: "Use Arduino with TIP120 transistor to control motors and high power devices."
- TIP 120 darlington transister
- 1K resistor.
- 1N4004 diode.
I didn't bother with the capacitor, as relays don't have a whole lot of back emf.
I used an LM 35 temperature sensor because I wanted a temperature sensing extension cord.
I used 1 large zip tie to hold things together.
I put the whole thing into a yogurt container. I know its a chinsy solution, but I didn't need anything fancy for my root cellar application.
There were a few other parts and tools I used: Connecting wire, solder, soldering iron, wire strippers etc.
Step 2: Working the High Power Side.
Second, I cut the black (power) wire, and stripped both ends back by about 1/4".
Then, I removed about 1/3" of coating off of the white wire. I left the green (ground) wire untouched.
I then mounted my relay onto the plug-in side of the adaptor. I organized the two ends of the power cord as pictured, and I held the whole thing together with a zip tie. Take careful note that the high voltage (switch) end of the relay were placed near to the prongs of the power adaptor.
I soldered the white (neutral) wire to one of the prongs of my power adapter. (On my adapter, both were the same size, but if one were wider than the other, I'd solder the white to the wider one.
I soldered the black wire, the end on the plug in the wall side, to the other prong. I also ran a heavy jumper wire from this connection to one of the switch ends on the relay. The wire used here should be at least as thick as the wires in the extension cord.
The black wire at the outlet end of the power cord were soldered to the other switch end of the relay.
- The plug end of the extension cord connects to the power adapter -- white on one side, black on the other.
- The black wire from the plug end of the cord also goes into the switch of the relay.
- The black wire from the outlet end of the cord is soldered to the other side of the relay switch.
Step 3: Adapting the Relay to the Arduino.
I like to think of adapting the relay to the arduino, rather than the other way around. I am doing this all in place because it is so simple that I hardly think it needs a circuit board.
(This process is illustrated very nicely at: "Use Arduino with TIP120 transistor to control motors and high power devices." In their case a motor is used where the relay is used here.
This method of using the TIP 120 switches the ground side, not the more intuitive power side.
- The positive side of my adapter was connected to one side of the coil on my relay.
- The emitter (right hand lead) of the TIP 120 was attached to the power adapter's "ground" (negative lead).
- The other side of the relay's coil was attached to the center pin of the TIP 120 (collector).
- The diode was attached between these two pins on the TIP 120. The white band on the collector (middle pin) side.
- The resistor was attached to the base (left pin of the TIP 120).
- I now attached 3 jumper wires which connect to the arduino. I color coded them as follows (just to make it easier to keep track.)
- The red jumper was connected to the positive of the adapter where it joins the relay's coil. This will contain 12vdc, totally adequate for arduino power.
- The white jumper was connected to the negative of the adapter where it joins the TIP 120's right lead. This provides the universal ground for the low power side.
- The green jumper was connected to the resistor. This is the signal line from the arduino telling the relay when to switch.
Step 4: Connecting the Arduino to the Relay, and Testing.
Connecting the Arduino is quite simple. To mount it, I just used a large rubber band. (Chincy, I know.)
- The red jumper plugged into the Arduino's vcc pin.
- The white jumper plugged into one of the Arduino's ground pins.
- The green jumper plugged into D1. (I never use D0 because it seems to be involved in some other functioning, but exactly what escapes me at the moment. Unless you are desperate, just never use D0.)
- I programmed the Arduino with the sketch attached, (modified from the standard "blink" sketch.)
- I put on ear muffs, rubber gloves, and flack jacket, then plugged the extension cord into the wall. It didn't go boom or blow out my house wiring -- phew.)
- I plugged in a lamp, and videoed the result.
You notice in the video that the lamp turns on and off opposite to LED 13, the on board test light. You will also notice that the automatic light control in the video camera try to counter the effect of the light -- which looks kinda weird.
Step 5: Adding Temperature Control.
I wanted my extension cord to respond to temperature, so I did the following:
- I soldered three jumper wires to my LM 35 temperature sensor (pictured with the flat part facing up.)
- I soldered a red (power) lead to the left pin.
- I soldered a green (control) lead to the center pin.
- I soldered a white (ground) lead to the right pin.
- I encased the whole thing in electrician's tape.
- I plugged the red lead into the 5v on my arduino.
- I plugged the white lead into a ground on my arduino.
- I plugged the green lead into the A2 pin -- because it matches my script.
- I programmed the arduino with the above script, and stuck the whole thing into the fridge to see what happened. Low and behold, there was a tight correlation between temperature and the numbers that show on my computer (using the arduino serial monitor.) In fact, the numbers pretty closely lined up to 1/4 degree celsius per unit. So 1 degree C about equals 4.
Step 6: Putting It Together.
I cut a slit and hole in a yogurt container, and slipped the power wire in. I know that this is a painfully chincy container for my project, but I hate spending too much time building fancy boxes. My shortcoming, I'm sure.
I wrote and loaded the script provided above. This script maintains the temperature between about 2C and 4C (34F and 39F). The script is pretty simple, please feel free to adapt it to your needs.