Testing

Today I took a half day off and finished the greenhouse automation system enough to start testing it. Here it is ready to go.

20131011-220238.jpg

20131011-220253.jpg

Once I got it putting the data in the database I had to put together some web pages so I could keep track of what was going on. Come to find out one of my light sensors is messed up, so I’m going to make another. Back to the web tracking, you can see now there’s a link on the blog called “Greenhouse Conditions”. This shows all the data being collected now during the testing and it will be where I can check on it when it’s actually out there during the winter.

More sensors and etc…

Today I worked on completing the rest of my moisture sensors and then worked on some other sensors and things. This included the outside temp sensor, the main light sensor (as opposed to the individual ones for each tree) and connection of the powerswitch tail.

20131006-212921.jpg

The light sensor is on the right and the temp sensor is the metal rod on top. (You should be able to pick out the powerswitch tail from a precious post.) I decided to use an rj11 jack (phone jack) vs a rj45 (Ethernet jack) as at most I had 3 wires to deal with. I’ll review how I made the light sensor as it is the most difficult of the three.

20131006-212940.jpg

To make this you’ll need a LDR, a 10k ohm resistor, some phone cable, a rj11 jack (rj12 will work too), and some shrink tubes.

20131006-212949.jpg

For the tools you’ll need…a soldering iron and solder, some crimpers and strippers, a lighter, some scissors, a vice and a volt meter for testing.

20131006-213002.jpg

To start, strip off the protective sheathing and strip the black, red, and green wires. Connect the red wire to one side of the LDR, the green and the 10k ohm resistor to the other, and the black wire to the other side of the resistor. Be sure to place some shrink tube on the red wire prior to attaching the LDR to the wire.

20131006-213011.jpg

Next solder all the connections and place the shrink tube over the connection for the red wire and over the black wire and end of the resistor.

20131006-213023.jpg

Next place a larger piece of shrink tube over the whole wire and shrink it on to make sure the connections are undisturbed.

20131006-213034.jpg

After that side is completed, we need to add the jack to the other side. Strip back some of the sheathing on the cable and place your wires in this order (actually order doesn’t matter, but this is the order I use. )

20131006-213042.jpg

Make sure that your wires are all the same length and place them in the jack. Use your crimper to attach the jack to the wire. Now we should test our sensor.

20131006-213050.jpg

I forgot to include alligator clips in my tools pic, but they are very helpful for this step. To test I used a keystone jack connector and attached the wires shown to the correct place on the jack. I know this makes little sense, but green is red, white green is black, and orange is green. Connect the alligator clips to the wires and voltmeter. Set the voltmeter to 1M ohms resistance.

20131006-213058.jpg

20131006-213105.jpg

The images above show what you should be seeing when exposing your sensor to light or dark. As seen in the first image, you should get a fairly low reading when the sensor is exposed to light. When it is dark, the resistance goes very high and it will show the 0 as the voltmeter cannot read that high. (I think the LDRs I have are 10m ohms in the dark).

This sensor is going to give me a good idea of the overall light my trees receive and will be attached to the upside down basket that I use to protect the temp and humidity sensors from the sun. This sensor, like the individual tree LDRs that are in the moisture sensors gets plugged into a ADC. (Red wire is +3 volts, black is ground, and green is data and goes to ADC) Its pretty easy to use this sensor and when I get to my coding post I’ll show you the code required.

Tomorrow is softball and I won’t have any time to work on my project so I might post about growing wheat….

A Little Bit of Future Plans

Since I still have some work to go to have my sensors and everything working fully, I thought I’d talk a little about some of my later plans, particularly automatic watering.

As I’ve said previously, my current greenhouse automation will turn the heater on when it gets too cold, but that’s it. Now that’s very useful and saves a lot of electricity over me having to go out there and turn it on and off when it needs to be done. To accomplish this, I have a power switch tail hooked up to my system that basically is a switch that switches 110 volts with only 3v. This is a pretty simple device to use, you plug one end into a socket (I use an extension cord), then plug the device into the other end. Next, you plug some wires from your micro controller (or in my case your micro computer) into the power and ground in the power switch tail.

20131003-211453.jpg

Since I am able to control 110v devices with this device I can control a pump to move water from one place to another. So, my plan is to place a electric pump in a rain barrel and turn it on when the moisture level in the planters indicates that the soil is dry. I’ll hook the pump up to a drip system that will drip on all the trees.

20131003-202505.jpg

20131003-202511.jpg

This is the rain barrel and pump I plan on getting to accomplish this. I should be able to get both for maybe a little over $100. The one thing I kind of worry about is that the rain barrel only holds around 50 gallons and the pump will pump around 20 gallons per minute. I have to find out if there is a way I can tone it down a bit.

20131003-213157.jpg

The other thing I have thought about is not wanting the pump to run when there is no water in the barrel. To do this I can use this float switch. When the water is below a certain level in the barrel I will set the code to not turn the pump on. I’ll have to drill a hole in the barrel to install it, but it should be easy to attach it to the ADC to determine if the switch is open or closed. I plan on running the program every 5 minutes to do all the logging and checking of the sensors.

Moisture Sensor Circuit

Tonight I thought I would post on how the rest of the moisture sensor circuit works since I think I have it going correctly now. I was using a transistor that was switched by a digital pin when it was time to run the program, but when I put it all together to test, it didn’t work at all. So this is what I have at the moment; which seems to work with the two sensors I have built right now. More testing will be required after everything is completed.

20131003-013251.jpg

The first thing you’ll need is the rj45 female jack to plug your sensor into. Remember your order from previously as you’ll need to know which pins do what in your sensor.

When I created my sensors I used brown for into the moisture sensor, brown and white as out of the moisture sensor. Green was plus volts for the LDR and green and white is the ground side. The blue wire is the data wire; which leads us to the next step.

20131003-013302.jpg

From looking at my plug and memory, I know that pin 3 should be data for the LDR. I run a wire from pin 3 to my analog input. (I use a raspberry pi so I have to have an ADC (analog to digital converter) to convert the analog signals from the sensor to something the pi can understand.

20131003-013312.jpg

The next pin is pin 5 which is the brown wire or plus volts to the sensor. I connect this to a digital pin on my pi and in my code only set it to high (or power) when I need to so I don’t experience as much electrolysis. (I’ll show this in the code later.)

20131003-013321.jpg

Next is pin 6 which is brown and white or the other side of the sensor. This also needs to be connected to an analog input

This should tell you how much moisture is in the soil by the amount of volts that transverse the sensor.

20131003-013332.jpg

The next thing you’ll need to do is to put a pull down resistor on the yellow wire to ground. This is to pull the voltage reading down to zero when there is nothing going on with the sensor. I use a 10k ohm resistor for this

20131003-013341.jpg

20131003-013349.jpg

The last step is to connect pins 7 and 8 appropriately. Pin 7 is the green wire or power for the LDR (goes to +volts and pin 8 is the green and white wire ( aka ground for the LDR)

I still have a good amount of work to complete the automation system, but it seems to be coming along quite nicely.

Tomorrow I may show the code to
see how the relative moisture is captured or I may go to a different sensor (humidity, temperature, etc…)

Moisture Sensor

I recently decided that I needed to up my game when it came to my greenhouse automation, not because I’m lazy, but because I’m forgetful. My current system tracks the inside temp, outside temp and outside humidity and turns on a heater when it gets too cold. To accomplish this I use a raspberry pi with a ds18b20 temp sensor and a powerswitch tail 2.

Now I have since built some new planters for my citrus trees (will do a post on them later) and decided I needed to build a system that tells me when they need to be watered (and waters them, but that will come later as well). The first thing I needed to come up with was a moisture sensor to stick in the ground. This sensor measures both the relative moisture in the soil and the light the plant is receiving. This is what I eventually came up with:

20131001-201100.jpg

If you’re interested in making one if these you’ll need some parts:

20131001-201307.jpg

We need a 3″ piece of 1×2 cedar, a 3″ piece of 2″ craft board, some cat 5 cable, a rj45 jack, 10″ of 2×12 gauge electric wire, a LDR, a 10K ohm resistor, and some shrink tubing.

You’ll also need some tools and supplies:

20131001-201829.jpg

These include a soldering iron and solder, a rj45 crimper and some wire strippers, hot glue gun and glue sticks, a staple gun, pliers and a lighter.

20131001-202211.jpg

20131001-202220.jpg

The first step is to place the jack on one end of the cat 5 cable. To do this strip back some of the wrapper and separate the wires. Place them in the order you would like (I used this order as I like the colors next to their white counterparts). Place the wires in the jack and put in the crimper and press it on. Cat 5 cables allow you to have 8 wires, but we only use 5.

20131001-202229.jpg

The next step involves wiring up the LDR (light dependent resistor or light sensor). Strip of the wrapping on the other end (you’ll need a good amount) and separate the wires. I use the brown wire for plus volts into the moisture sensor, the brown and white wire for minus volts, the green wire for plus volts for the LDR, green and white for ground for the LDR and the blue wire for data on the LDR.

To wire the LDR you need to connect the green wire to one side (put your shrink tube over the wire before you connect them) the blue wire and one side of the 10k ohm resistor are connected to the other side of the LDR. The green and white wire is connected to the other side of the 10k ohm resistor. Once these are all connected solder them together to create a good solid connection.

20131001-202239.jpg

Once they’re all soldered put some shrink tube over the ground side of the LDR connection.

Next, we need to put together our moisture sensor probes. Use your strippers again to pull the black and white wires out of the 2×12 gauge wire.

20131001-202252.jpg

Once separated you will need to strip some off of each end of the wires. Just a little on the wire connection side and more on the side that will go into the ground.

20131001-202302.jpg

After this solder the ends of the probes that will be in the dirt to prevent erosion.

20131001-202312.jpg

Next, we need to connect the wires to the probes. Strip off a good bit from the cat 5 cables to make sure you can wrap it around the probe. Then solder the wires to the probes. (It helps to use a small vice to hold everything still while your soldering.

20131001-202323.jpg

After we are all connected, we need to “mount” the probes to the wood blocks. I align them as shown in the picture, then staple the with 2 staples for each probe. I then go and use some pliers to push the staples in securely.

20131001-202334.jpg

Almost finished!! Now we need to secure the LDR to the wood block. To do this I hold it down and use hot glue to secure it. I try to place the LDR a little above the top of the block. I also try to put some around all the other wires to make sure they don’t touch.

20131001-202354.jpg

20131001-202402.jpg

Finally, put the other piece of wood on top of everything and hot glue it together (this uses a lot of hot glue). I try not to cover the LDR with the glue but put it all around it.

20131001-202411.jpg

For good measure I staple the cat 5 cable to the back of the block to move it back to the top of the sensor block.

This really does have most of the circuit for the LDR, but for the moisture sensor I use a transistor to cut the ground when I’m not using the sensor to cut down on electrolysis. In another post I’ll write about how I go about using this sensor.

If you have any questions just post in the comments. I have made 2 of these so far and still have 4 to go!!