Quick & Easy Temperature Loggers





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.


  • 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.



  • Water Contest

    Water Contest
  • Clocks Contest

    Clocks Contest
  • Oil Contest

    Oil Contest

24 Discussions

We've been using a similar setup for our underwater loggers, and you might find some of that work interesting: http://www.mdpi.com/1424-8220/18/2/530 (open access - pdf is free to download) Especially take a look at the PVC housings we used. The 4" rubber bottomed housing shown there is easy to put together, rugged enough for real world deployment, and double sided tape holds the modules together securely on the the 4" knock out cap.

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 :)

2 replies

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 :)

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.

1 reply

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

please help

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

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

10 replies

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)

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

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!

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.

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

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

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.