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.