Jump to Navigation

Garden Project - Temperature Sensors

As promised, I'm going in depth on each of the components that make up the Garden Project and I'm starting with the temperature sensors. Monitoring temperature of the garden is going to play a huge part in how the garden performs. Down the line it's going to be a factor in the frequency of watering and the amount of water. Theoretically the hotter it is outside, the more evaporation will take place and watering should be longer I would think. It's going to be important early in the spring to make sure we don't dip down in to the frost temps also.

I'm using the LM34 in the example although there are similar 3 pin sensors that will work also. I've swapped the LM34 with the TMP38 and the readings are pretty darn close. I'm using the TO-92 package, but it's really immaterial other than the pin out. Before using any sensor, it's best to have the datasheet handy. Just don't take my word for things. I'm not that bright and I'm sure I overlooked something. You can find the LM34 datasheet HERE.

Directly from the datasheet, this is what the pin out of the LM34 looks like

You can see there are 3 pins on there, +Vs, Vout and GND.

Again, right from the datasheet it says to connect the pins as such.

To keep things simple with my power supplies and whatnot, I've connected +Vs to 5V, and GND to the ground on the 5V supply. The Vout pin will get connected to the analog pin of my Arduino. The Arduino will be another article, for now we'll just focus on how these sensors work.

To test the sensor, I stuck it into my breadboard and connected the pins. The pin on the left is connected to my +5V power rail, the right side is connected to my ground rail and the center pin I'll connect to my meter

Now to test the output. You can see from the datasheet that the output is calibrated to 10mV(0.010)/ degree F. It's in the mid/low 70'sF in my work room, so I'm expecting my meter to read 0.700ish V when I connect it.

Looks pretty good to me. I should have been measuring across a resistor, but I think just doing this gives a pretty good indication if we hooked it up correctly.

In order to make this something I can actually install it's best if had a PCB all made up for it. I figured I'd dress it up a little with an LED to show if it was getting power or not. This is what THAT looks like.


if you want to see how I made these boards, see this article here

You can see the spot for the LM34 on the right. I added a place for an LED and the accompanying resistor for that. This is what it looks like all assembled. I added a 3 pin connector also.

Looks pretty good. right? WELLLLLLLLLLLL there was a problem. When I connected it all up, was getting a slightly higher reading than I was expecting - about 10F... The HECK? I wacked in some caps, I added a load resistor, I added a precision power source (more on that in another article as well) and nothing, NOTHING would make that thing read correctly with any consistency. So I connected my oscilloscope and I saw this.


ignore the bottom line for now

AACK!!! See how that line is all wavy... it should be pretty straight. It will go up and down a little over long periods of time, but we're looking at about 10mS there, and it's all over the place. Let's zoom in on that and see just how whacked that is.

Yikes. Looks like about every 4mS we're going up or down 100mV. Wait? How much was the temp off by? 10F Well dang. That actually makes sense. Depending on when that Arduino is reading that analog pin, we could be reading up or down 100mV. With 10mV = 1F that's 10 degrees F. So now what? Slap in "faster" caps right? Yeah, that didn't work. I'm practically connected directly to the Arduino, so lead length shouldn't be an issue, but when I do finally install this thing, I WILL have long leads on it, it's only going to get worse. I'm screwed! I REALLY don't want to buy the digital sensors. They are expensive, and I don't feel like learning how to read the data from them, I have like a billion of these LM34's laying around... grr...

Well, it turns out there is a solution. I asked around, and I talked to my uncle who actually IS an engineer and WAY smarter than I am... like WAY smarter. So, I call him up and I'm sulking and telling him how I had these boards made and they look REALLY nice and now I can't use them and this sucks, and waaaa!!! He says, "in the final installation, how are you planning on connecting these to the Arduino?" Well, I have a ton of scrap cat5/cat6 cable around I figured I'd just whack off 30 feet or so and use that. "So twisted pair?" Well YEAH, that's what Cat5/6 is. "Read the datasheet for the LM35, I'm pretty sure there is a note regarding using these things with TP wire. The LM35 is the same sensor, it's just calibrated for C instead of F."

Well I'LL be. Look at THAT!

So I whipped a sensor up with this configuration and connected it with a 30 foot piece of twisted pair wire.


Ok now you can pay attention to the bottom line.

The top line was the traditional connection method, the bottom line is using the twisted pair connection method. Notice how nice and steady that line is? No wavy line? pretty straight. If you know how to read my scope you'll notice that it's reading the correct voltage for the room too.

So it's back the design room and making up the CORRECT boards. They look like this

Note that I dropped the LED from the design also. When those come in I'm pretty confident my signals will be clean. I'll keep you posted on that.

Ok, so we got the electronics figured out, now how the HECK are we going to mount these things outside? I mean, we're going to have things like rain, and bird poop, and the sprinkler and all things outdoors. What are we going to PUT these things in? Thankfully I have access to a 3D printer at work, AND the department that controls it was trying to use up some CHEAP filament they had that was causing problems for them. So they printed up some enclosures for me in exchange for a small donation to their department. Also, if the board is going to be completely enclosed, there's no point in having an LED.

Not a perfect solution, but you can't beat the price. I've found that the 3D printed stuff isn't always water resistant, so I figure after drilling the hole for the cable to hang out, I'll paint the enclosure to fill in some of the thin spots then probably hit it with some NeverWet(tm)

I think that's it. You can see some more pictures related to the temp sensors here. Stay tuned for the next component!



Main menu 2

Dracula