Introduction: Quick & Easy Temperature Loggers

I work as a software developer for a biology lab where my day job consists of creating applications to deal with big data visualisation. Recently however one of my colleagues had the need to take regular temperature measurements form a range of jars of liquids over quite an extended period. The commercial available solutions to achieve this are expensive and surprisingly lacking in features. So, as a dedicated hacker and maker, I immediately stepped in an said we could make something better ourselves. So we did. And this is how.

Requirements

  • 1 or 2 temperature sensors per data logger
  • Temperature range 10-40°C
  • Probes should be waterproof and capable of being sterilised with ethanol
  • Log temperature every 15 mins
  • Operate over a period of 21 days

Step 1: Design

With the stated requirements it was obvious that we could achieve or aims with an Arduino of some description reading data from some digital temperature sensors. A real time clock would be necessary to ensure readings are taken at the required time intervals and an SD card could be used to store the measured in data in a file that could easily be read from a PC or Mac.

After some consideration, googling and searching eBay the following components were selected:

  • Arduino Leonardo Pro Micro (clone)
  • Maxim IC DS18B20 Digital Temperature Sensor with waterproof enclosure and 1m cable
  • Maxim IC DS1307 RTC break out board
  • SD Card breakout board

The Leonardo Pro Micro was chosen for its small size and USB interface which eradicates the need for external serial interface and also allows the circuit to be powered via standard mobile phone charger.

The following ancillary parts were also purchased:

  • TDK 4GB SD Cards
  • Male-to-Female Dupont Cables
  • Female-to-Female Dupont Cables
  • Plastic food container

Step 2: Schematic & Circuit Construction

The schematic shows how the various components were connected together. All circuit boards had header pins soldered on so connection could be made with Dupont connectors. The temperature probes came with about 1m of cable with bare wires to which I also soldered Dupont connectors. Power for the SD card and RTC was daisy chained from the Arduino board to make connections easier.

Step 3: Hardware Construction

As can be seen from the picture, the whole circuit was housed in a plastic food container into which holes were drilled/cut for the USB and temperature probe cables. The glass jars that were to contain the liquids being observed had plastic screw on lids which were drilled to the diameter of the sensor probe cable and were threaded on prior to the probe being connected to the rest of the circuit.

Step 4: Software

The software for the loggers was created using the Arduino IDE. Code had to be written to setup and control the temperature sensors which use the 1-Wire bus, SD Card which uses SPI and the RTC which uses I2C. First the code sets up the necessary interfaces in turn and then performs initialisation for the peripherals as required (creating a file on the SD card for example). It then enters a loop to poll the RTC to see if the desired sample interval has elapsed. If so it takes a reading from each of the temperature sensors and writes the results to the output file which is formatted as a CSV with columns for date, time and temperature for each sensor.

The source code (ABIO_DataLogger.ino) is included with this article. To allow the DS18B20 sensors to work without an external pull up resistor on the data line I used a slightly modified version of the OneWire library to allow the use of the Arduino's internal pull ups which I have also attached. The DS1307RTC library can be found here, otherwise I think the dependencies are standard libraries.

Step 5: Operation

To use the data logger the user simply places inserts a blank, FAT 32 formatted SD card, attaches the temperature sensors and powers on the Arduino. The system will happily log away every 15 minutes until powered down. To recover the data, simply insert the SD card into a PC or Mac and copy off the CSV file you will find there.

Step 6: Further Development

After successfully using the setup to collect data for 3 weeks, we decided to change the experimental setup slightly and as a result had a need to collect data more frequently (every 5 seconds) and to view the output live as well as logging the data for later analysis. To do this I modified the code slightly to send the temperature readings via USB (virtual COM port) to a laptop and then use a python program to plot the data in real time.

The modified Arduino source code is attached (ABIO_DataLogger2.ino) as is the python source code (abiologger.zip) for the GUI which both plots and logs the data received from the Arduino. The python GUI requires Python 3, the PyQt5 bindings to the Qt Framework as well as matplotlib and numpy.

The picture shows the setup using a MacBook Air with two data loggers attached and running two instances of the python GUI. The two plots show data acquired using this setup.

Comments

author
geigercounter120 (author)2016-09-07

Hi Jazzy Camel,

thanks very much for sharing this. Looks exactly what I'm after for monitoring both fermentation & ambient temperatures using 2 DS18B20s in my homebrew set up. I'll be using a Nano (clone) (can still power it from a smartphone charger, so don't need to bug out about Li battery hell) mounted on a mini breadboard and will be using the DS3221 RTC (presumably it's just a case of swapping the call to the DS1307 library in your code to the DS3221 library?).

While I'm impatiently waiting for parts from China I'll try to get my head around the Arduino code :)

Thanks again :)

author

@geigercounter120

If its any help to you, I have an example of using an Arduino, a DS18B20 and a solid state mains relay to control the temperature of a water boiler for use as a mash tun: https://github.com/jazzycamel/BoilerController.

Thanks for your comment, good luck and have fun!

author

Crikey, thanks for that! I feel I might have to leave a trail of breadcrumbs to find my way back out of this DIY/hack maze I'm entering :)

author
MarloG1 (author)2016-05-09

good day jazzy camel,

i'm using duemilanove,

thank you for your help, it's working now, i connected a pull up resistor to my sensors, again thank you for your help.

author
jazzycamel (author)MarloG12016-05-09

Good to know you've got it working, we'll done :) Glad I could help.

author
MarloG1 made it! (author)2016-05-04

good day,

i made this project but ran into some trouble, it indicates that my DS18B20 sensor FAILED

Screenshot from 2016-05-05 14-52-38.png
author
jazzycamel (author)MarloG12016-05-05

That failure is right at the first step of communicating with the sensors, i.e. it's failing to find any and/or the right number of DS18B20's on the 1Wire bus. What model of Arduino are you using? Is NUM_BS18B20 set to the number of sensors you have connected?

Also, a few things to check:

1) Are all the connections the same or equivalent to those in my circuit diagram
2) Are you using my tweaked version of OneWire.cpp? If not, you'll need to connect a 4.7kΩ pullup resistor between the 1Wire bus (pin 7) and VCC (you might try this anyway).

This is just the first few things that come to mind. Try these and let me know the results, I hope you get it working :)

author
jazzycamel (author)jazzycamel2016-05-05

That should have been NUM_DS18B20, sorry!

author
MarloG1 (author)2016-05-04

please help

author
upetakis (author)2016-02-02

Hi. I want to use DS3231 instead DS1307. What commands need to change in the sketch? Thanks

author
diy_bloke (author)2014-12-11

looking good. May i advise against the use of the DS3107. It is a reasonable RTC but not really accurate. Better use the DS3231. It is DS3107 compatible, more accurate and I think it even has a build in temperature sensor.
The price is more or less the same

author
jazzycamel (author)diy_bloke2014-12-11

Hi diy_bloke,

Thanks for the suggestion, if I were to make more I would definitely look at the DS3231, especially if there is no price or compatibility differences. In this case the accuracy of temperature measurements was more important than that of time, over a 15 minute interval even a few seconds either way is acceptable, and I found the break out boards dirt cheap on eBay! :)

Thanks again ;o)

author
diy_bloke (author)jazzycamel2014-12-11

DS3221 are currently around a dollar on aliexpress :-)

over a month the DS3107 could easily be off by half an hour,doesnt make much difference for the interval, but have to adjust from time to time

author
jazzycamel (author)diy_bloke2014-12-11

Yeah I searched for them on eBay. £3 would get me a break out board delivered with battery! :)

I did notice a little drift with the DS1307, nowhere near half an hour in the 21 days we used them, but I don't doubt this is possible given the right conditions.

Conclusion: DS3231 is definitely the way to go in future!

author
diy_bloke (author)jazzycamel2014-12-12

Currently 1 euro, including a 24C32 EEPROM:

http://www.aliexpress.com/item/Hot-Sale-DS3231-AT2...

DS3107 Drift seems dependend on temperature. I have one module with minimaldrift and another with very noticable drift

author
zoomx (author)diy_bloke2015-08-15

I have a DS1307 module that drift about 30 s a day. I believe that it has a cheap crystal. I agree that DS3231 is much better and is reasonable cheap.

author
diy_bloke (author)zoomx2015-08-15

30 secs is a lot. The DS3231 doesnt have NVRAM, but most modules do have an EEPROM included

author
zoomx (author)diy_bloke2015-08-15

I checked the drift for more than one month so I can correct it. But DS3231 is better.

author
diy_bloke (author)zoomx2015-08-15

tnx :-)

author
Timofte Andrei (author)diy_bloke2014-12-13

it's 1307, for crying out loud, not 3107...

author
diy_bloke (author)Timofte Andrei2014-12-14

well seems it was clear enough to understand

author
ethan.mamer (author)2014-12-15

Thank you so much for this! I've been thinking about building a low power temperature data logger like this as well! For my research I need higher accuracy than the DS18B20 loggers can provide. Have you looked into using thermistors instead? My concern is that the Arduino Micro board might have too much noise to make it any more accurate than the digital temp logger.

author
jazzycamel (author)ethan.mamer2014-12-16

What kind of accuracy/resolution are you looking for? In 12bit mode (default) the DS18B20 has a resolution of 0.0625°C and and accuracy of ~±0.5°C.

To answer your other question: yes, I have used thermistors before and you're right, electrical noise from the μC (and in general) can be an issue. I have always tried to hook them up to an external high resolution ADC and to use a clean, separate power source where possible. With this approach though you do have to do all the calibration yourself and find a thermistor in a package that suits your requirements (if need waterproof or contact measurements that is). Short connections between thermistor and ADC are also a good idea.

author
Timofte Andrei (author)2014-12-13

the nice fact is that you can add more sensors to your datalogger and you can use it for a lot of purposes

author
AvelinoMoro (author)2014-12-11

Muy interesante, gracias por compartirlo.

author
seamster (author)2014-12-10

Very interesting project! Thank you for sharing this.