Two Channel Temperature Logger

I was curious about how warm the sleeping bags and pads would be, if the tent kept us warmer versus sleeping under the stars, and basically at what temperatures we can comfortably sleep in with the gear we have. So I decided to monitor the temperature outside and inside the tent and record the data.

This logger will keep track of the temperature of 2 waterproof probes and write them to a SD card in a CSV file. When we return home these files can be opened in Excel and graphed. It will also be easy to later add other sensors to monitor and record data (like a light sensor to see how the temperature jumps after the sun rises).


What we’ll need:

Arduino UNO

Adafruit SD Logger Shield

16×2 LCD

DS18b20 Waterproof Temperature Sensor

Adafruit Arduino Enclosure

SD card

10k Potentiometer

10k Resistor

4.7k Resistor

Wires

A power source, for the first few trips I will be using two 9 volt batteries in parallel.

Arduino 2 channel data logger


Optional Hardware:

3.5mm Female Stereo Jack  x 2

3.5mm Male Stereo Jack x 2

Rocker Switches x 2

Arduino 2 channel data logger


I prototyped out the LCD to decide how bright I wanted the display. I went pretty dim, using a 10k ohm resistor on the back light, to save on power and so it wouldn’t be blinding in a dark tent at night. This is the simple setup from any basic LCD tutorial.

Arduino 2 channel data logger


Placing the UNO into the enclosure.

Arduino 2 channel data logger


After soldering the header pins onto the SD Shield, it fits nicely on top of the UNO. Though we will have to take it back out to do some more work.

This would be a good time to test the SD shield and make sure all your solder points are going to hold. You should also do the initial set up of the RTC (real time clock) that comes on the SD board. We’re going to need it. Instructions on how to do this can be found in this demo.

Arduino 2 channel data logger


This is the wiring diagram for the finished product. It looks like there is a lot going on here but when it all comes together it really isn’t that bad, I promise!

Arduino 2 channel data logger


I soldered in the ribbon cable that will be the data lines for the LCD and the thermometer. (You don’t actually have to use ribbon cable, I just used it to keep things neat). The three lines that are loose will be trimmed and tucked away for expansion later. There is however an issue with this picture. Data lines 11 and 12 had to be moved since I didn’t notice until after that the SD shield uses pins 10, 11, 12, and 13 for its logging. I moved them to pins 8 and 9. I also added lines from the 5 v out and the ground pins.

Arduino 2 channel data logger


Here’s the LCD wired up with the lines from the SD logger shield. I bridged the 5 v in and the ground from the far right (LCD power) to the 5 v and ground on the far left (back light) with a 10 k ohm resistor on the 5 v line to dim out the back light. I will add a switch on the connecting line so I can turn the back light on and off to save power.

Arduino 2 channel data logger


It all fits pretty nicely. Now we need to test the LCD. For this I had to mock up the missing parts of the circuit, the potentiometer and the power connections on a bread board.

Arduino 2 channel data logger


I ran the simple hello world demo script to make sure the LCD was working and wired properly. It lives!

Arduino 2 channel data logger


I tried to layout the passive hardware as efficiently as possible. The potentiometer and the pull up resistor for the data line are placed for easy access.

Arduino 2 channel data logger


Here’s a look at the back of the board. The traces aren’t pretty but they do the job.

Arduino 2 channel data logger


Using a dremel and a drill, Amanda cut holes in the top plate of the enclosure to add the ports and switches.

Arduino 2 channel data logger


I wired the switches up to some leads to be attached later. The good thing about the sensors we’re using is they are addressable so we were able to wire together the 2 ports to cut back on clutter.

Arduino 2 channel data logger


We discovered that the switches and ports wouldn’t fit with the LCD pins standing up, so I carefully bent them with pliers.

Arduino 2 channel data logger


At this point, assuming everything is wired up correctly, you can close it up and it’s ready to go.


Optional: Solder the male ends of the 3.5 mm jack onto the ends of the sensors.


The Code

For the code I downloaded the following libraries that are not included in the base arduino IDE:

Sleep_n0m1 – This can be used to put the arduino into a sleep mode for longer battery life. There are a few options out there for this but I found this one to be the easiest to use on the fly.

OneWire – This library manages the different sensors on the same wire.

RTClib – If you have already set up your RTC with the tutorial linked above you will already have this on. It reads and sets the data from the Real Time Clock on the SD shield.

DallasTemperature – This library will intemperate the date from the sensors.

You will also need to get the unique address of the sensors you have. I used the script and instructions here to find the addresses of my sensors. These addresses will need to be substituted for the ones I have that are unique to my devices.


Running this on your Arduino (with everything wired up correctly) should write something like this to your SD card:

millis stamp date time probe1 probe2
8817 1.46E+09  2016/5/24 17:53:06 -0.17 70.81
61390 1.46E+09  2016/5/24 17:53:59 0.05 70.93
120012 1.46E+09  2016/5/24 17:54:58 0.39 70.93
180031 1.46E+09  2016/5/24 17:55:58 0.61 70.93
240028 1.46E+09  2016/5/24 17:56:58 0.84 70.93
300053 1.46E+09  2016/5/24 17:57:58 1.18 70.93
360057 1.46E+09  2016/5/24 17:58:58 1.4 70.93

Output like this is easy to open and graph in excel.

Arduino temperature logger test graph

This graph is from a test with one probe in deep freezer and one in the room. The consistent wave is from the compressor in the freezer cycling. This is also when I learned how power hungry this project was. It ate through a 9 volt in about 8 hrs. A future iteration will focus on energy efficiency.


The First Field Test

The first real test was when we went out to the Pawnee Grasslands over Memorial Day weekend. I set the system up shortly after we set up the tent and let it run until we broke down camp in the morning. I powered it with two 9 volt batteries in parallel to ensure I had enough power to last the entire time.

Arduino 2 channel data logger

It did well for its first trip. I tried to shield the probe outside of the tent from direct sunlight using a paper cup but there were a few obvious times where that didn’t protect it as well as I would have hoped. The first dip in the temp was from a small storm that rolled through and the second was from sunset. It got down to around 47°F that night with the tent temperature hovering just about that. The spike on the outside (probe 2, in red) after sunrise was with the probe in direct sunlight, and the fall on both probes after that was moving probe 2 out of the sun and opening the tent.


The initial logger was a success and I am already designing a smaller, more efficient version for adventures in the future. I’m planning to add humidity and UV index sensors. I’ll do another write up for the new design.


Credit where credit is due

I just wanted to credit some of the resources I used in the project. Most of the SD logger code and set up comes from the adafruit SD logger Tutorial and the preloaded examples in the Arduino IDE. The information used to decipher and use the probes comes from this post that really helped me to understand how the data was being captured.

Leave a Reply

Your email address will not be published. Required fields are marked *