How to make a grow box controller
11.6 years ago cheap, LEDs, Uncategorized, vegetables
While my existing system was working I decided to make an upgrade to the electronics on my old grow box controller specifically to have a much more industrial strength version that will run without problems for decades to come. This version also is much safer…still probably not quite to a building code but much less worries to burning my garage down in the middle of the night. Finally it is modular if there are problems in the future I can easily switch out electronics or sensors.
Well now I have attempted to justify my reasons this is what I used to put the whole thing together:
Parts List
- Enclosure big enough to fit four Solid State Relays (SSR)
- Breadboard or custom PCB
- soldering iron and solder (optional if using breadboard)
- Arduino
- 4 – solid state relays
- 4 — 1K resistor
- 4 — 2N2222 transistor
- 4 — 1N4004 diode
- DS18S20 (1Wire temperature sensor)
- 4.7K resistor
- 10K resistor and homemade soil sensor
- 18 gauge triple stranded solid copper wire (5 feet)
- Industrial grade sockets (1 male/4 female)
- Old Ethernet cable
If we had lawyers, they probably would want us to say this:
WARNING: I am not an electrician and do not pretend to be one. I do not know the specific building electrical codes of your area, so please be sure your wiring is completed under the proper safety code for your area. As always, using high voltage electricity can result in self-electrocution or burn down your house if not done safely so if you are not comfortable doing this wiring please contact a qualified professional.
Putting it all together
On the electronics side overall the circuits are actually pretty simple and if using a breadboard definitely something that could be tackled by a beginner. Though on the other side since this project is dealing with AC current I definitely would recommend caution (no hands unless power is unplugged) or have someone a little more comfortable with 120/220V help you out.
The Brains
I will be the first to admit that using an Arduino for this application is complete overkill for this application but it gives plenty of room for additions in the future. For all intents and purpose you could have your grow box completely controlled from the Arduino own processing power though on my case the software and UI is more interesting part to me. For this reason the Arduino code is actually very “dumb” basically just taking commands via the build in serial through USB and setting digital outputs to HIGH/LOW or reading analog inputs.
Here is the code for your grow box controller:
1: /*
2: * GrowBox Arduino Interface
3: *
4: * Descriptions: Simple interface to digital and analog controls by passing serial inputs
5: * For example:
6: * "A1" to read analog value on pin 1
7: * "D1H" to set digital pin 1 to HIGH
8: */
9: #include <OneWire.h>
10:
11: //1-wire
12: OneWire ds(8); // on pin 8
13: #define BADTEMP -1000
14:
15: //define unique sensor serial code
16: byte temperature[8];
17:
19: #define PIN_VALUE 1 // numeric pin value (0 through 9) for digital output or analog input
18: #define ACTION_TYPE 0 // 'D' for digtal write, 'A' for analog read
20: #define DIGITAL_SET_VALUE 2 // Value to write (only used for digital, ignored for analog)
21:
22: int NUM_OF_ANALOG_READS = 2;
23: char commandString[20];
24:
25: void setup()
26: {
27: Serial.begin(9600);
28:
29: setOneWireHex();
30:
31: // Power control
32: for(int i=0; i<=7; i++)
33: {
34: pinMode(i, OUTPUT); // sets the digital pins as output
35: digitalWrite(i, LOW); // turn everything off
36: }
37: }
38:
39: void loop()
40: {
41: readStringFromSerial();
42:
43: if (commandString[ACTION_TYPE] != 0) {
44: int pinValue = commandString[PIN_VALUE] - '0'; // Convert char to int
45:
46: if(commandString[ACTION_TYPE] == 'A')
47: Serial.println(analogRead(pinValue));
48: else if(commandString[ACTION_TYPE] == 'D') {
49: if(commandString[DIGITAL_SET_VALUE] == 'H')
50: digitalWrite(pinValue, HIGH);
51: else if(commandString[DIGITAL_SET_VALUE] == 'L')
52: digitalWrite(pinValue, LOW);
53:
54: Serial.println("OK");
55: }
56: else if(commandString[ACTION_TYPE] == 'T') {
57: float temp = get_temp(temperature);
58:
59: Serial.print(temp);
60: Serial.println("C");
61: }
62: else if(commandString[ACTION_TYPE] == '1') {
63: printOneWireHex();
64: }
65: else if(commandString[ACTION_TYPE] == 'V') {
66: Serial.println("VERSION_1_0_0_0");
67: }
68: else if(commandString[ACTION_TYPE] == 'P') {
69: Serial.println("PONG");
70: }
71:
72: // Clean Array
73: for (int i=0; i <= 20; i++)
74: commandString[i]=0;
75: }
76:
77: delay(100); // wait a little time
78: }
79:
80:
81: void readStringFromSerial() {
82: int i = 0;
83: if(Serial.available()) {
84: while (Serial.available()) {
85: commandString[i] = Serial.read();
86: i++;
87: }
88: }
89: }
90:
91: void setOneWireHex() {
92: ds.reset_search();
93: ds.search(temperature);
94: }
95:
96: void printOneWireHex() {
97: ds.reset_search();
98: if ( !ds.search(temperature)) {
99: Serial.print("NONE\n");
100: }
101: else {
102: ds.reset_search();
103:
104: int sensor = 0;
105: while(ds.search(temperature))
106: {
107: Serial.print("S");
108: Serial.print(sensor);
109: Serial.print("=");
110: for(int i = 0; i < 8; i++) {
111: Serial.print(temperature[i], HEX);
112: Serial.print(".");
113: }
114: Serial.println();
115: }
116: }
117:
118: ds.reset_search();
119: }
120:
121: float get_temp(byte* addr)
122: {
123: byte present = 0;
124: byte i;
125: byte data[12];
126:
127: ds.reset();
128: ds.select(addr);
129: ds.write(0x44,1); // start conversion, with parasite power on at the end
130:
131: delay(1000); // maybe 750ms is enough, maybe not
132: // we might do a ds.depower() here, but the reset will take care of it.
133:
134: present = ds.reset();
135: ds.select(addr);
136: ds.write(0xBE); // Read Scratchpad
137:
138: for ( i = 0; i < 9; i++) { // we need 9 bytes
139: data[i] = ds.read();
140: }
141:
142: int temp;
143: float ftemp;
144: temp = data[0]; // load all 8 bits of the LSB
145:
146: if (data[1] > 0x80){ // sign bit set, temp is negative
147: temp = !temp + 1; //two's complement adjustment
148: temp = temp * -1; //flip value negative.
149: }
150:
151: //get hi-rez data
152: int cpc;
153: int cr = data[6];
154: cpc = data[7];
155:
156: if (cpc == 0)
157: return BADTEMP;
158:
159: temp = temp >> 1; // Truncate by dropping bit zero for hi-rez forumua
160: ftemp = temp - (float)0.25 + (cpc - cr)/(float)cpc;
161: //end hi-rez data
162: // ftemp = ((ftemp * 9) / 5.0) + 32; //C -> F
163:
164: return ftemp;
165: }
Copy and paste the above code into your Arduino software. For the code above I used the OneHire.h library which is free to use and can be downloaded from here. To be able to use this library simply copy the contents to C:\arduino\hardware\libraries\OneWire. Now you should be able to Compile (CTRL+R) and upload the code to the board (CTRL+U)
Now with the software uploaded you can send some simple serial commands via its built in USB to serial adapter to interact with it. The interface is are broken up into 1 to 4 character commands, which I will detail below
Command | Description |
T | Returns temperature from One Wire component |
D4H | Sets digital pin 4 to HIGH (ON) (replace 4 for alternate pin) |
D4L | Sets digital pin 4 to LOW (OFF) (replace 4 for alternate pin) |
A1 | Reads analog value from pin 1 (replace 1 for alternate pin) |
PING | Returns PONG which is used to confirmed controller is online |
V | Returns version which is some forethought into the PC application being able to support different versions of controller software |
Using the build in serial monitor tool in Arduino.exe, my application, or you should be able to control your Arduino with this very simple command based interface
Now you can hook up some LEDs and watch them blink which is fun for a little while but if you want to add some grow box components read on….
Temperature Sensor
As you can see I have fully embraced the circuit schema on the back of a napkin idea. These are the actual diagrams I crumpled up and stuffed in my pocket with several trips to the garage for some final soldering of various joints until everything was solid.
Below is the simple circuit required to get your 1Wire temperature sensor working. I would recommend checking your documentation (if not labels on the chip) for the orientation to have 1 and 3 correct, if you have it wrong you should get some complete unrealistic number. Hook ground up to pin1 on the DS18S20 and pin 2 hooked up to the digital input pin 8 on the Arduino with 5V with a 4.7K resister in between to step down the voltage.
If everything is hooked up correctly you should get the current room temperature in Celsius by sending command “T” to your Arduino. If you prefer Fahrenheit uncomment line 162 and recompile and upload your changes, though if using my software I support both degree types and do the conversion in the the software. To make sure everything working (or just to play with your new toy) put your fingers on the chip for a couple seconds and take another measurement unless you keep your house very warm the temperature should go up a couple of degrees
Turning things on and off (Relays)
If you were smart enough to check the current requirements of your Solid State Relays (SSR) before you bought them you may be able to skip this whole circuit and simply hook the digital outputs to the 5V positive side and ground to the negative side of the SSR.
Unfortunately if you are like me and bought some SSRs that require more current draw than the Arduino (or any other IC chip) of 40mA then you will need to create the simple circuit below.
Basic idea is pretty simple, you are using the output from the digital pins to switch of the transistor which then allows the ground to complete the circuit with the thus turning on the relay. As you can see there is a 1K resistor between the base (middle pin) of the transistor. If you are not using a SSR relay (though recommend you do) you should add a 1N4004 diode between the positive/negative which protects the transistor from being damaged in case of a high voltage spike which can occur for a fraction of a second when the transistor switched off, this is also known as a back-EMF diode or fly back diode.
Now here you have a couple options. If you are confident of our wiring skills you can do like I did and take a couple of sockets and hook up the neutral and ground in parallel. Two save space and since I really didn’t need two separate plug-ins (nor its own plug) for each relay I removed the little metal bar between the two sockets so they could be switched on independently. Now simply hook up hot to the left side of all your relays in parallel and then connect a wire from the right side of the relay to its own plug on the two sockets.
Now a less wiring intensive method is to simply take a 6 foot (small if you can find them) and cut the hot wire (usually the one with non-smooth wire) and attach each end of the wire to both sides of the relay.
Moisture Sensor
When it comes to a moisture sensor there are a few options. First is the classic two galvanized nails, second is the cheap gypsum soil moisture sensor which I have written up in the provided link.
If you are using the other options you will need the simple circuit below. Technically it is a voltage divider, but that doesn’t really matter. Just hook up one end of your sensor to 5V and other sensor to ground with 10K resistor and also connected to analog pin 0.
My custom PCB solution
I actually started the work to create my own PCB at least a few years back. Played with if it off and on and finally pulled the trigger to get some boards printed up which I must say was very rewarding and pretty fun experience for just $20-30 of out of pocket cost. This provides all the circuits I mention above with a bonus circuit to let me know when my water reservoir is running low. I also installed a Ethernet socket not
I designed this to be an Ardunio which plugs directly on top of the Arduino. In theory I could stack more functionality on top of if but haven’t though of anything cool to do here yet.
Don’t want to spend 10-20 hours creating your own PCB and then wait 2-3 weeks for it to arrive from Hong Kong? Well you can do the same thing with a bread board which I show below.
Virtual breadboard layout
If you are new to soldering or have no interest in learning I would definitely recommend this option. Simply place the components in the holes and make connections with 18 gauge solid copper wire. You should be able to pick a small breadboard for less than $7.
Various applications
Of course for my application, I am using this to integrate with my custom software solution to control my grow box. Specifically soil sensor, temperature measurement, heater, lights, exhaust fan, and water pump. So using the circuit mentioned above I ran the hot wire through each SSR with the remaining wires connected to the plug and eventually gets plugged into the wall. Then simply hooked up the wire from the Ethernet cables to the low voltage side to turn the switches on/off. So I would say this is a bit of an improvement over my last attempt…
Before
After
Last I hooked the arduino up to my PC and used my custom software to control the temperature, water, and provide cool graphs as you can see below.
Sometimes life can get busy and you have limited time to keep an eye on your plants, for these times I also integrated with a custom Windows Phone 8 application which allows me to check the current state of the grow box using life tiles, water remotely (turn on/off lights/heater/fan as well), or even check out a current feed inside the grow box.
Looks at the actual actual grow box…
Tags: arduino, cheap, coffee grounds, grow lights, growbox, led, vegetables
Robotic Wheel Barrow
14.7 years ago arduino
If you ever have spent a day hauling soil/gravel you know this can cause some serious pains in your back. Now with the Lawnbot 400 you can save some pain and let the evil robots do the hard labor for you.
The project started as an arduino powered lawn mower with a custom PCB motor driver powered by a couple of wheel chair motors, which mike many projects he just couldn’t stop improving. Great work…
Tags: arduino, cheap, vegetables
How to make a grow box controller (Original)
14.7 years ago arduino, cheap, LEDs, vegetables
While my existing system was working I decided to make an upgrade to the electronics on my old system for several reasons:
- I needed to add more automated external controls (heater, fans, water pump) with my existing design this was entirely possible though was starting to get a little clunky.
- The existing controller (PS2 Controller, parallel port with various wires to control relays) worked but was not exactly compact.
- Wanted a modular design so if I needed to debug some issue I could simply unplug the USB and power and bring it out of the box in the garage for needed work
- Ability for others to create so I can share my software without forcing people to hack PS2 controllers to get to work
- Ability to use components like 1Wire temperature sensors (others to come) and Arduino
- Just for the fun of it
Well now I have attempted to justify my reasons this is what I used to put the whole thing together:
Parts List
- Black plastic project case (8”X6”X3”)
- Breadboard or multipurpose PC board
- soldering iron and solder (optional if using breadboard)
- Arduino
- 4 – solid state relays
- 4 — 1K resistor
- 4 — 2N2222 transistor
- 4 — 1N4004 diode
- DS18S20 (1Wire temperature sensor)
- 4.7K resistor
- (10K resistor and homemade soil sensor) or Vegetronix soil sensor
- 20 gauge solid copper wire (recommend multiple colors)
- Heavy duty extension cord
- 2 — outlet sockets
- 2 — socket faceplate (optional)
- hot glue gun and glue
If we had lawyers, they probably would want us to say this:
WARNING: I am not an electrician and do not pretend to be one. I do not know the specific building electrical codes of your area, so please be sure your wiring is completed under the proper safety code for your area. As always, using high voltage electricity can result in self-electrocution or burn down your house if not done safely so if you are not comfortable doing this wiring please contact a qualified professional.
Putting it all together
On the electronics side overall the circuits are actually pretty simple and if using a breadboard definitely something that could be tackled by a beginner. Though on the other side since this project is dealing with AC current I definitely would recommend caution (no hands unless power is unplugged) or have someone a little more comfortable with 120/220V help you out.
The Brains
I will be the first to admit that using an Arduino for this application is complete overkill for this application but it gives plenty of room for additions in the future. For all intensive purposes you could have your grow box completely controlled from the Arduino own processing power though on my case the software and UI is more interesting part to me. For this reason the Arduino code is actually very “dumb” basically just taking commands via the build in serial through USB and setting digital outputs to HIGH/LOW or reading analog inputs.
Here is the code for your grow box controller:
1: /*
2: * GrowBox Arduino Interface
3: *
4: * Descriptions: Simple interface to digital and analog controls by passing serial inputs
5: * For example:
6: * "A1" to read analog value on pin 1
7: * "D1H" to set digital pin 1 to HIGH
8: */
9: #include <OneWire.h>
10:
11: //1-wire
12: OneWire ds(8); // on pin 8
13: #define BADTEMP -1000
14:
15: //define unique sensor serial code
16: byte temperature[8];
17:
19: #define PIN_VALUE 1 // numeric pin value (0 through 9) for digital output or analog input
18: #define ACTION_TYPE 0 // 'D' for digtal write, 'A' for analog read
20: #define DIGITAL_SET_VALUE 2 // Value to write (only used for digital, ignored for analog)
21:
22: int NUM_OF_ANALOG_READS = 2;
23: char commandString[20];
24:
25: void setup()
26: {
27: Serial.begin(9600);
28:
29: setOneWireHex();
30:
31: // Power control
32: for(int i=0; i<=7; i++)
33: {
34: pinMode(i, OUTPUT); // sets the digital pins as output
35: digitalWrite(i, LOW); // turn everything off
36: }
37: }
38:
39: void loop()
40: {
41: readStringFromSerial();
42:
43: if (commandString[ACTION_TYPE] != 0) {
44: int pinValue = commandString[PIN_VALUE] - '0'; // Convert char to int
45:
46: if(commandString[ACTION_TYPE] == 'A')
47: Serial.println(analogRead(pinValue));
48: else if(commandString[ACTION_TYPE] == 'D') {
49: if(commandString[DIGITAL_SET_VALUE] == 'H')
50: digitalWrite(pinValue, HIGH);
51: else if(commandString[DIGITAL_SET_VALUE] == 'L')
52: digitalWrite(pinValue, LOW);
53:
54: Serial.println("OK");
55: }
56: else if(commandString[ACTION_TYPE] == 'T') {
57: float temp = get_temp(temperature);
58:
59: Serial.print(temp);
60: Serial.println("C");
61: }
62: else if(commandString[ACTION_TYPE] == '1') {
63: printOneWireHex();
64: }
65: else if(commandString[ACTION_TYPE] == 'V') {
66: Serial.println("VERSION_1_0_0_0");
67: }
68: else if(commandString[ACTION_TYPE] == 'P') {
69: Serial.println("PONG");
70: }
71:
72: // Clean Array
73: for (int i=0; i <= 20; i++)
74: commandString[i]=0;
75: }
76:
77: delay(100); // wait a little time
78: }
79:
80:
81: void readStringFromSerial() {
82: int i = 0;
83: if(Serial.available()) {
84: while (Serial.available()) {
85: commandString[i] = Serial.read();
86: i++;
87: }
88: }
89: }
90:
91: void setOneWireHex() {
92: ds.reset_search();
93: ds.search(temperature);
94: }
95:
96: void printOneWireHex() {
97: ds.reset_search();
98: if ( !ds.search(temperature)) {
99: Serial.print("NONE\n");
100: }
101: else {
102: ds.reset_search();
103:
104: int sensor = 0;
105: while(ds.search(temperature))
106: {
107: Serial.print("S");
108: Serial.print(sensor);
109: Serial.print("=");
110: for(int i = 0; i < 8; i++) {
111: Serial.print(temperature[i], HEX);
112: Serial.print(".");
113: }
114: Serial.println();
115: }
116: }
117:
118: ds.reset_search();
119: }
120:
121: float get_temp(byte* addr)
122: {
123: byte present = 0;
124: byte i;
125: byte data[12];
126:
127: ds.reset();
128: ds.select(addr);
129: ds.write(0x44,1); // start conversion, with parasite power on at the end
130:
131: delay(1000); // maybe 750ms is enough, maybe not
132: // we might do a ds.depower() here, but the reset will take care of it.
133:
134: present = ds.reset();
135: ds.select(addr);
136: ds.write(0xBE); // Read Scratchpad
137:
138: for ( i = 0; i < 9; i++) { // we need 9 bytes
139: data[i] = ds.read();
140: }
141:
142: int temp;
143: float ftemp;
144: temp = data[0]; // load all 8 bits of the LSB
145:
146: if (data[1] > 0x80){ // sign bit set, temp is negative
147: temp = !temp + 1; //two's complement adjustment
148: temp = temp * -1; //flip value negative.
149: }
150:
151: //get hi-rez data
152: int cpc;
153: int cr = data[6];
154: cpc = data[7];
155:
156: if (cpc == 0)
157: return BADTEMP;
158:
159: temp = temp >> 1; // Truncate by dropping bit zero for hi-rez forumua
160: ftemp = temp - (float)0.25 + (cpc - cr)/(float)cpc;
161: //end hi-rez data
162: // ftemp = ((ftemp * 9) / 5.0) + 32; //C -> F
163:
164: return ftemp;
165: }
Copy and paste the above code into your Arduino software. For the code above I used the OneHire.h library which is free to use and can be downloaded from here. To be able to use this library simply copy the contents to C:\arduino\hardware\libraries\OneWire. Now you should be able to Compile (CTRL+R) and upload the code to the board (CTRL+U)
Now with the software uploaded you can send some simple serial commands via its built in USB to serial adapter to interact with it. The interface is are broken up into 1 to 4 character commands, which I will detail below
Command | Description |
T | Returns temperature from One Wire component |
D4H | Sets digital pin 4 to HIGH (ON) (replace 4 for alternate pin) |
D4L | Sets digital pin 4 to LOW (OFF) (replace 4 for alternate pin) |
A1 | Reads analog value from pin 1 (replace 1 for alternate pin) |
PING | Returns PONG which is used to confirmed controller is online |
V | Returns version which is some forethought into the PC application being able to support different versions of controller software |
Using the build in serial monitor tool in Arduino.exe, my application, or you should be able to control your Arduino with this very simple command based interface
Now you can hook up some LEDs and watch them blink which is fun for a little while but if you want to add some grow box components read on….
Temperature Sensor
As you can see I have fully embraced the circuit schema on the back of a napkin idea. These are the actual diagrams I crumpled up and stuffed in my pocket with several trips to the garage for some final soldering of various joints until everything was solid.
Below is the simple circuit required to get your 1Wire temperature sensor working. I would recommend checking your documentation (if not labels on the chip) for the orientation to have 1 and 3 correct, if you have it wrong you should get some complete unrealistic number. Hook ground up to pin1 on the DS18S20 and pin 2 hooked up to the digital input pin 8 on the Arduino with 5V with a 4.7K resister in between to step down the voltage.
If everything is hooked up correctly you should get the current room temperature in Celsius by sending command “T” to your Arduino. If you prefer Fahrenheit uncomment line 162 and recompile and upload your changes, though if using my software I support both degree types and do the conversion in the the software. To make sure everything working (or just to play with your new toy) put your fingers on the chip for a couple seconds and take another measurement unless you keep your house very warm the temperature should go up a couple of degrees
Turning things on and off (Relays)
If you were smart enough to check the current requirements of your Solid State Relays (SSR) before you bought them you may be able to skip this whole circuit and simply hook the digital outputs to the 5V positive side and ground to the negative side of the SSR.
Unfortunately if you are like me and bought some SSRs that require more current draw than the Arduino (or any other IC chip) of 40mA then you will need to create the simple circuit below.
Basic idea is pretty simple, you are using the output from the digital pins to switch of the transistor which then allows the ground to complete the circuit with the thus turning on the relay. As you can see there is a 1K resistor between the base (middle pin) of the transistor. If you are not using a SSR relay (though recommend you do) you should add a 1N4004 diode between the positive/negative which protects the transistor from being damaged in case of a high voltage spike which can occur for a fraction of a second when the transistor switched off, this is also known as a back-EMF diode or fly back diode.
Now here you have a couple options. If you are confident of our wiring skills you can do like I did and take a couple of sockets and hook up the neutral and ground in parallel. Two save space and since I really didn’t need two separate plug-ins (nor its own plug) for each relay I removed the little metal bar between the two sockets so they could be switched on independently. Now simply hook up hot to the left side of all your relays in parallel and then connect a wire from the right side of the relay to its own plug on the two sockets.
Now a less wiring intensive method is to simply take a 6 foot (small if you can find them) and cut the hot wire (usually the one with non-smooth wire) and attach each end of the wire to both sides of the relay.
Moisture Sensor
When it comes to a moisture sensor there are a few options. First is the classic two galvanized nails, second is the cheap gypsum soil moisture sensor which I have written up in the provided link. Lastly if my personal favorite the Vegetronix soil sensor.
If you use the Vegetronix hookup is simple no circuit needed simply hook up the 5V to red, bare wire to ground, and black to analog pin 1.
If you are using the other options you will need the simple circuit below. Technically it is a voltage divider, but that doesn’t really matter. Just hook up one end of your sensor to 5V and other sensor to ground with 10K resistor and also connected to analog pin 0.
Cheap soldered solution
If I could do it over I probably should have just bought a small breadboard. I did most of my prototyping with my larger breadboard but got cheap when I was at Radio Shack The Shack and just got this prototype board for half the price.
Virtual breadboard layout
If you are new to soldering or have no interest in learning I would definitely recommend this option. Simply place the components in the holes and make connections with 18 gauge solid copper wire. You should be able to pick a small breadboard for less than $7.
Various applications
Of course for my application, I am using this to integrate with my custom software solution to control my grow box (will be having private/public beta soon). Specifically soil sensor, temperature measurement, heater, lights, exhaust fan, and water pump.
Though there is definitely no reason you can use this same setup for other application.
A couple of ideas:
- Home automation (turn on/off lights, turn on coffee machine)
- Attic fan
- Hydroponic system
Going Forward
I would like to convert this into an Arduino shield. For those new to Arduino I will go with Arduino’s description, “Shields are boards to be mounted on top of the Arduino board and that extend the functionality of Arduino to control different devices, acquire data, etc”
So basic idea is you just plug it into the top the Arduino and hook up a couple wires to some terminal blocks and you have a nice clean solution. Creating these printed circuit boards get much cheaper the higher the quantity. I am considering doing a run of these if I get enough interest so if you may be interested in one of these send me a mail in “Contact” in the header.
Tags: arduino, cheap, coffee grounds, grow lights, growbox, led, vegetables
Homemade waterproof digital thermometer
14.9 years ago arduino, electronics, thermometer, Uncategorized, waterproof
Now I am playing with hydroponics in my grow box I want to monitor the temperature of my nutrient tank. This is important too hot it can bread disease too cold it can shock your plants. I also want to use the data to identify how ebb/flow cycles affect ambient and solution temperature (for my own nerd curiosity)
I have been thoroughly impressed with the Dallas DS18S20 temperature sensor so decided this would be a great component to use for this project and this is how you can make your own.
Materials:
- DS18S20 temperature sensor
- 1/2 inch plastic tubing (could go smaller but had some lying around)
- Aquarium/food grade silicone
- 18 gauge solid core wire (long enough to get from arduino to what you want to measure)
- Glue gun with glue
- Soldering iron with solder
Construction
Step 1: Solder the two wires to pins 1 and 2 of the DS18S20 and apply a little dab of hot glue to all of the exposed metal. This is not entirely necessary but a small safety precaution so you don’t discover you shorted the connection during assembly.
Step 2: Cut approximately 1 inch length of plastic tubing using a utility knife
Step 3: Apply liberal amount of silicone to one end of the tubing cut in step 2.
Step 4: Allow silicone to set for 15 minutes and do a visual inspection for leaks. You may also try blowing very gently into the tube to check for leaks, though not too hard to create a hole in the process.
Step 5: Attach the DS18S20 to the tube using a drop of hot glue. This is not entirely necessary but when trying to get a perfect watertight seal the less moving parts the better.
Step 6: Again apply a liberal amount of silicone to seal the top paying special attention to the area around the wires
Step 7: Give the silicone at least 24 hours to completely set.
Step 8: Testing. First off the sensor may be buoyant, if this is the case carefully attach a 1/2 hose clamp or something else to help tether it down. Next suspend in a glass of water (preferably clear) and watch for a few minutes for leaks and or bubbles. If you see bubbles try to get an much water as you can out and apply a more silicone and let set for another 24 hours
Hooking it up
This part is pretty straightforward. Pin 1 is your ground and pin 2 is your DQ which for most people doesn’t make much sense but it is a combination power source and bus output. To get this to work you hook up your ground (black wire) to your ground on your arduino and the red wire to digital in and 5v with 4.7K resistor between. Sure that is very confusing so hopefully the breadboard visual below is much more helpful.
Writing the Code
Since I am planning on using this with my grow box controller, I will show how to use this with arduino to get some numbers. You could look at my arduino code in the grow box controller post to get the values but in my case I need to get values from two DS18S20 temperature sensors so I found a great OneWire library which helps make your arduino code very simply. Simple extract the two folders in the zip archive to [ArduinoPath]\hardware\libraries and enter the following code into the arduino UI:
#include <OneWire.h> #include <DallasTemperature.h> OneWire oneWire(8); // on pin 8 DallasTemperature sensors(&oneWire); void setup() { Serial.begin(9600); // Initialize sensors sensors.begin(); } void loop() { sensors.requestTemperatures(); Serial.print(“Sensor #0: “); Serial.println(sensors.getTempCByIndex(0)); Serial.print(“Sensor #1: “); Serial.println(sensors.getTempCByIndex(1)) delay(100); // wait a little time }
If all goes well you should see output similar to the following (values in Celsius):
Sensor #0: 20.3 Sensor #1: 30.4 Sensor #0: 20.3 Sensor #1: 30.4 Sensor #0: 20.3 Sensor #1: 30.4
For people like me who are used to Fahrenheit you can simply use the following equation to convert Celsius to Fahrenheit:
°F = °C x 9/5 + 32
Though I am using this for my grow box controller there are many other uses you could use this for:
- Aquarium temperature monitoring
- Brewing temperature monitoring
- Weather station
- Soil thermometer
Tags: arduino, cheap, growbox, outdoor plants, vegetables
Best DIY cheap soil moisture sensor
15 years ago cheap, electronics, moisture sensor, water
My first version of my cheap soil moisture sensor has worked great for me but it did have a couple flaws. The first issue was construction, though I had great luck on my first attempt though after trying to recreate additional sensors given the small amount of gypsum between the sensor and the probes were so thin it was extremely easy to crack the sensor and I normally have about a 25% success rate on later creations (must have had beginners luck on the first one.
The second issue was durability. Given we are playing with gypsum and as it is suspended in water it will eventually breakdown and there is very little we can do about it. Though with my latest changes to my automated grow box which includes automated watering based on moisture content I want to ensure my measurements stay accurate throughout the season. To help with this I have decided to increase the sensors size and also am using galvanized nails to prevent rusting. After a few attempts I have come up what I feel is a pretty foolproof method of creating a moisture sensor.
How it works:
There were many questions in the comments in the previous post so hopefully I can clear this up a little here.
Technically a gypsum block measures soil water tension. When the gypsum block is dry it is not possible for electricity to pass between the probes, essentially making the probe an insulator with infinite resistance.
As water is added to the problem more electrons can pass between the probes effectively reducing the amount of resistance between the problem to the point when it is fully saturated where the probe has virtually zero resistance. By using this range of values you can determine the amount of water than exists in your soil.
Parts for cheap soil moisture sensor:
- Plaster of Paris
- 2 Galvanized Finish Nails
- 1/2 inch plastic tubing
- utility knife
Construction:
Take your utility knife and cut the tubing slightly longer than your galvanized finishing nails. Try to make the cut as straight as possible though it doesn’t have to be completely perfect.
Use your utility knife to cut the smaller plastic tube lengthwise, this will allow easier removal of your soil sensor after the mold cures.
Optional: Make the cut diagonally to prevent a potential vertical fracture line.
If you were very careful on you vertical cuts you can avoid this step, but to completely avoid spilling plaster onto my workbench I drilled four holes slightly larger than your tubing. I used these holes for support but also to catch any of the plaster in the gaps from you less than accurate vertical cuts.
Being careful that the tubing fits together where you split the tubing vertically, insert the tubes into the holes (or carefully on a flat surface) Mix Plaster of Paris and carefully fill with to the top. The friction between the tubing should keep a water tight seal where you made the cut, though if the plaster is a little thin and it appears to be leaking through wait a couple minute for the plaster to setup some and try again, at that time it should not have the viscosity to seep through the very small gap that may be causing the leak.
Take your two galvanized nails and push them through a small piece of wax paper. You may also allow the plaster to setup for a few minutes and then float the nails in the the plaster. I like the first method since gravity will help ensure they fall straight down and parallel to each other. As for spacing, I have done some experimentation with the gaps between the probes and my conclusion was, it doesn’t make much difference. As long as there is a gap (they are not touching) you should get reliable results.
After allowing the sensor to cure for about and hour remove it from the holes you drilled in the wood.
Gently pull back the plastic tubing and you have a nice clean soil sensor.
Lay them out to dry for 24 hours to cure completely and their construction is complete.
For attaching the wires there are a couple options. The best would be to solder them to the probes though to do this you need to heat up the nail hot enough to enable a strong solder connection. My little 15W soldering iron just can’t produce the heat for this so I am option for the wire wrap method. I take about an inch of wire and strip off about an inch of insulation and tightly wrap around the probe. Given copper will rust and could be a point of failure you will want to insulate this connection and the probes from the moisture. A few dabs of hot glue works pretty well. I am planning on trying liquid plastic, though I am currently out and when I have some on hand I will update with how it went.
How to use your cheap soil moisture sensor
You can simply hook up a multi-meter and check the resistance though if you want to create anything automated you would need to use an integrated circuit (IC) or a electronics prototyping platform such as Arduino. By applying voltage to one side of the sensor and using a voltage splitting circuit connected to ground and an analog input you can then measure the voltage making it through the probe. The higher the voltage, the higher the moisture content of the soil.
Conclusion
The above should give you everything you need to know to create your own cheap soil moisture sensor and how to use it. This can be used as a moisture soil sensor for watering your indoor plants like I am using it. This same moisture sensor could be for monitoring your outside soil moisture content to trigger (or preempt your irrigation system) to save some money on your water bill and/or maintain consistent moisture levels in your plants which could drastically improve water sensitive crops such as tomatoes.
Tags: arduino, cheap, growbox, led, outdoor plants, tomato plants, vegetables
How to use Vegetronix soil moisture sensor (VG400) on Arduino
15.2 years ago arduino, moisture sensor
With the summer starting to come to a close it has been time for me to start thinking back to the computerized grow box. I have been doing some considerable work on the electronics and software over the summer. Better to break stuff while the plants are outside and not while killing them inside.
Though I have been happy with my homemade gypsum soil sensors I decided to try out a commercial option hoping for better accuracy and longer life. This is important with my current plans to include automatic watering to the latest version of my grow box. Don’t want to wake up to a flood in the garage due to a broken sensor. After some looking I came across the Vegetronix VG400 which measures the dielectric constant of the soil using transmission line techniques. Which I have no idea what that means but sounds impressive.
The hookup couldn’t be simpler, red wire to 3V, bare wire to ground, and black wire to an analog input. As you can see below in my completely not to scale diagram below.
From here it all comes down to some simple code to write on the Arduino to get some values.
void setup() { // Setup serial Serial.begin(9600); }void loop() { Serial.println(analogRead(0)); delay(200); // wait 200 milliseconds |
Upload the code to the Arduino and now I can get a moisture value from the analog input between 0 and 614 (0-3 volts) depending on the degree of water saturation.
Though not as hacky as my PS2 controller moisture sensor solution definitely more elegant and reliable. Stay tuned for more details of other improvements to the computer controlled grow box.
Tags: arduino, cheap, growbox, led, outdoor plants, vegetables