{"id":331,"date":"2010-08-17T19:24:38","date_gmt":"2010-08-17T23:24:38","guid":{"rendered":"http:\/\/lukemiller.org\/?p=331"},"modified":"2015-04-30T20:09:33","modified_gmt":"2015-05-01T03:09:33","slug":"a-thermocouple-datalogger-based-on-the-arduino-platform","status":"publish","type":"post","link":"https:\/\/lukemiller.org\/index.php\/2010\/08\/a-thermocouple-datalogger-based-on-the-arduino-platform\/","title":{"rendered":"A thermocouple datalogger based on the Arduino platform"},"content":{"rendered":"<p>Updated with new Arduino code July 8 2012.<\/p>\n<p>It never hurts to collect more data, and I often find myself wanting to record temperatures from a few extra animals. <a href=\"http:\/\/www.omega.com\/toc_asp\/subsectionsc.asp?subsection=e01&amp;book=das\">Most (all?)<\/a> <a href=\"http:\/\/www.microdaq.com\/data-logger\/thermocouple_dataloggers.php\">commercial<\/a> <a href=\"http:\/\/www.dataloggerinc.com\/categories\/Thermocouple_Data_Loggers\/10\/\">thermocouple<\/a> <a href=\"http:\/\/www.campbellsci.com\/cr1000\">dataloggers<\/a> <a href=\"http:\/\/www.dcccorporation.com\/hotmux.html\">that<\/a> <a href=\"http:\/\/www.picotech.com\/thermocouple.html\">will<\/a> <a href=\"http:\/\/www.saelig.com\/DLTHPC\/DLTHPC04.htm\">record<\/a> <a href=\"http:\/\/volt.ni.com\/niwc\/measurements\/datalogging\/temp_logging_8_channel_usb.jsp\">temperatures<\/a> from multiple thermocouples cost several hundred or thousands of dollars. I set out to put together a <em>relatively<\/em> cheap 8-channel thermocouple datalogger based on the open-source Arduino development platform.<\/p>\n<figure id=\"attachment_352\" aria-describedby=\"caption-attachment-352\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/Mux_board_topside.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-352\" title=\"Mux_board_topside\" alt=\"\" src=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/Mux_board_topside-300x186.jpg\" width=\"300\" height=\"186\" srcset=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/Mux_board_topside-300x186.jpg 300w, https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/Mux_board_topside.jpg 600w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-352\" class=\"wp-caption-text\">My 8-channel thermocouple datalogger. A single type-T thermocouple is plugged in to one of the channels. In the center of the board is the ADG407 multiplexer, and below it is the AD595 thermocouple amplifier. Two buttons are provided, one to cycle through menus and turn the LCD backlight on, the other restarts the datalogger.<\/figcaption><\/figure>\n<p>By way of introduction, the Arduino development platform consists of a cheap and fairly easy-to-understand microcontroller board and associated software to easily program the microcontroller. A basic Arduino &#8220;Duemilanove&#8221; board with an Atmega328 microcontroller can be purchased for roughly $30 (<a href=\"http:\/\/www.adafruit.com\/index.php?main_page=product_info&amp;cPath=17&amp;products_id=50\">AdaFruit Industries<\/a>, <a href=\"http:\/\/www.sparkfun.com\/commerce\/product_info.php?products_id=666\">SparkFun Electronics<\/a>). The software to program the microcontroller is freely available from many sources, including the <a href=\"http:\/\/www.arduino.cc\/\">main Arduino site.<\/a><\/p>\n<p>My datalogger setup consists of the Arduino board:<\/p>\n<figure id=\"attachment_339\" aria-describedby=\"caption-attachment-339\" style=\"width: 400px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/Arduino_board.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-339\" title=\"Arduino_board\" alt=\"\" src=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/Arduino_board.jpg\" width=\"400\" height=\"317\" srcset=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/Arduino_board.jpg 400w, https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/Arduino_board-300x237.jpg 300w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/a><figcaption id=\"caption-attachment-339\" class=\"wp-caption-text\">Arduino Duemilanove<\/figcaption><\/figure>\n<p>A <a href=\"http:\/\/www.adafruit.com\/index.php?main_page=product_info&amp;cPath=17_21&amp;products_id=243\">SD card and real time clock shield<\/a> from Adafruit Industries:<\/p>\n<figure id=\"attachment_340\" aria-describedby=\"caption-attachment-340\" style=\"width: 400px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/SD_card_shield.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-340\" title=\"SD_card_shield\" alt=\"\" src=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/SD_card_shield.jpg\" width=\"400\" height=\"292\" srcset=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/SD_card_shield.jpg 400w, https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/SD_card_shield-300x219.jpg 300w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/a><figcaption id=\"caption-attachment-340\" class=\"wp-caption-text\">Datalogger shield<\/figcaption><\/figure>\n<p>My homemade pcb to interface with the thermocouples and provide a LCD screen readout:<\/p>\n<figure id=\"attachment_341\" aria-describedby=\"caption-attachment-341\" style=\"width: 400px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/Mux_board_underside.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-341\" title=\"Mux_board_underside\" alt=\"\" src=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/Mux_board_underside.jpg\" width=\"400\" height=\"374\" srcset=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/Mux_board_underside.jpg 400w, https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/Mux_board_underside-300x280.jpg 300w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/a><figcaption id=\"caption-attachment-341\" class=\"wp-caption-text\">LCD and thermocouple PCB<\/figcaption><\/figure>\n<p>The LCD+thermocouple board is designed to sit on top of the Adafruit datalogger shield, which is designed to sit on top of the Arduino board. The datalogger shield uses its factory pins for the SD card and real time clock, along with the stock code base, except for the two indicator LEDS. The indicator LEDs should be unhooked from whatever Arduino pins you connected them to. The LCD+thermocouple board requires all of the remaining pins on the board, and the SD write indication is instead accomplished with the LCD. The only other modification to the Adafruit datalogger shield was the installation of female header pins with long leads (available from Adafruit, listed below) instead of the normal male header pins that it comes with. The LCD+thermocouple board uses modified male header pins to interface into the female pins of the Adafruit board.<\/p>\n<figure id=\"attachment_351\" aria-describedby=\"caption-attachment-351\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/Mux_board_side.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-351\" title=\"Mux_board_side\" alt=\"\" src=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/Mux_board_side.jpg\" width=\"600\" height=\"209\" srcset=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/Mux_board_side.jpg 600w, https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/Mux_board_side-300x104.jpg 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><figcaption id=\"caption-attachment-351\" class=\"wp-caption-text\">LCD + thermcouple PCB side view. The header pins hanging below the board interface with the Adafruit datalogger shield. The Omega thermocouple sockets shown the left edge are ideal for interfacing with normal miniature thermocouple plugs (the blue thing).<\/figcaption><\/figure>\n<p>Here&#8217;s a rough parts list and cost breakdown:<\/p>\n<table width=\"100%\" border=\"1\" cellspacing=\"2\" cellpadding=\"2\">\n<tbody>\n<tr>\n<th>Item<\/th>\n<th>Supplier<\/th>\n<th>Part #<\/th>\n<th>Quantity<\/th>\n<th>Cost<\/th>\n<th>Total<\/th>\n<\/tr>\n<tr>\n<td>Arduino Duemilanove<\/td>\n<td><a href=\"http:\/\/www.adafruit.com\/index.php?main_page=product_info&amp;cPath=17&amp;products_id=50\">Adafruit<\/a><\/td>\n<td>50<\/td>\n<td>1<\/td>\n<td>$30<\/td>\n<td>$30<\/td>\n<\/tr>\n<tr>\n<td>Datalogger Shield<\/td>\n<td><a href=\"http:\/\/www.adafruit.com\/index.php?main_page=product_info&amp;cPath=17_21&amp;products_id=243\">Adafruit<\/a><\/td>\n<td>243<\/td>\n<td>1<\/td>\n<td>$19.50<\/td>\n<td>$19.50<\/td>\n<\/tr>\n<tr>\n<td>LCD 20&#215;4 Display<\/td>\n<td><a href=\"http:\/\/www.adafruit.com\/index.php?main_page=product_info&amp;cPath=37&amp;products_id=198\">Adafruit<\/a><\/td>\n<td>198<\/td>\n<td>1<\/td>\n<td>$18.00<\/td>\n<td>$18.00<\/td>\n<\/tr>\n<tr>\n<td>Battery pack, 6xAA<\/td>\n<td><a href=\"http:\/\/www.adafruit.com\/index.php?main_page=product_info&amp;cPath=44&amp;products_id=248\">Adadruit<\/a><\/td>\n<td>248<\/td>\n<td>1<\/td>\n<td>$5.00<\/td>\n<td>$5.00<\/td>\n<\/tr>\n<tr>\n<td>Stacking header pins, female<\/td>\n<td><a href=\"http:\/\/www.adafruit.com\/index.php?main_page=product_info&amp;cPath=17_21&amp;products_id=85\">Adafruit<\/a><\/td>\n<td>85<\/td>\n<td>1<\/td>\n<td>$1.50<\/td>\n<td>$1.50<\/td>\n<\/tr>\n<tr>\n<td>Header pins, male<\/td>\n<td><a href=\"http:\/\/www.sparkfun.com\/commerce\/product_info.php?products_id=116\">SparkFun<\/a><\/td>\n<td>PRT-00116<\/td>\n<td>1<\/td>\n<td>$2.50<\/td>\n<td>$2.50<\/td>\n<\/tr>\n<tr>\n<td>Push button<\/td>\n<td><a href=\"http:\/\/www.sparkfun.com\/commerce\/product_info.php?products_id=97\">SparkFun<\/a><\/td>\n<td>COM-00097<\/td>\n<td>2<\/td>\n<td>$0.35<\/td>\n<td>$0.70<\/td>\n<\/tr>\n<tr>\n<td>AD595 amplifier<\/td>\n<td><a href=\"http:\/\/www.digikey.com\/\">Digikey<\/a><\/td>\n<td>AD595AQ-ND<\/td>\n<td>1<\/td>\n<td>$12.35<\/td>\n<td>$12.35<\/td>\n<\/tr>\n<tr>\n<td>ADG407 multiplexer<\/td>\n<td><a href=\"http:\/\/www.digikey.com\/\">Digikey<\/a><\/td>\n<td>ADG407BNZ-ND<\/td>\n<td>1<\/td>\n<td>$9.56<\/td>\n<td>$9.56<\/td>\n<\/tr>\n<tr>\n<td>P2N2222A NPN transistor<\/td>\n<td><a href=\"http:\/\/www.digikey.com\/\">Digikey<\/a><\/td>\n<td>P2N2222AGOS-ND<\/td>\n<td>1<\/td>\n<td>$0.53<\/td>\n<td>$0.53<\/td>\n<\/tr>\n<tr>\n<td>680 ohm resistor<\/td>\n<td><a href=\"http:\/\/www.digikey.com\/\">Digikey<\/a><\/td>\n<td>CF18JT680RCT-ND<\/td>\n<td>1<\/td>\n<td>$0.09<\/td>\n<td>$0.09<\/td>\n<\/tr>\n<tr>\n<td>10k ohm resistor<\/td>\n<td><a href=\"http:\/\/www.digikey.com\/\">Digikey<\/a><\/td>\n<td>CF18JT10K0CT-ND<\/td>\n<td>1<\/td>\n<td>$0.09<\/td>\n<td>$0.09<\/td>\n<\/tr>\n<tr>\n<td>Trim pot, 5k ohm<\/td>\n<td><a href=\"http:\/\/www.digikey.com\/\">Digikey<\/a><\/td>\n<td>490-3002-ND<\/td>\n<td>1<\/td>\n<td>$1.38<\/td>\n<td>$1.38<\/td>\n<\/tr>\n<tr>\n<td>28-pin DIP socket<\/td>\n<td><a href=\"http:\/\/www.digikey.com\/\">Digikey<\/a><\/td>\n<td>3M5469-ND<\/td>\n<td>1<\/td>\n<td>$0.27<\/td>\n<td>$0.27<\/td>\n<\/tr>\n<tr>\n<td>14-pin DIP socket<\/td>\n<td><a href=\"http:\/\/www.digikey.com\/\">Digikey<\/a><\/td>\n<td>3M5462-ND<\/td>\n<td>1<\/td>\n<td>$0.18<\/td>\n<td>$0.18<\/td>\n<\/tr>\n<tr>\n<td>Thermocouple jack, type-T<\/td>\n<td><a href=\"http:\/\/www.omega.com\/pptst\/PCC-OST-SMP.html\">Omega Eng.<\/a><\/td>\n<td>PCC-SMP-V-T-5<\/td>\n<td>2<\/td>\n<td>$19.00<\/td>\n<td>$38.00<\/td>\n<\/tr>\n<tr>\n<td>Thermocouple wire (50&#8242;) type-T<\/td>\n<td><a href=\"http:\/\/www.omega.com\/pptst\/FineWire_DupInsul.html\">Omega Eng.<\/a><\/td>\n<td>TT-T-30-SLE-50<\/td>\n<td>1<\/td>\n<td>$43.00<\/td>\n<td>$43.00<\/td>\n<\/tr>\n<tr>\n<td>Thermocouple plugs type-T<\/td>\n<td><a href=\"http:\/\/www.omega.com\/pptst\/SMPW_SMP_HMP_HMPW.html\">Omega Eng.<\/a><\/td>\n<td>SMPW-T-M<\/td>\n<td>8<\/td>\n<td>$1.75<\/td>\n<td>$14.00<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<td><strong>Total<\/strong><\/td>\n<td><strong>$197<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Admittedly, $200 still isn&#8217;t super cheap, and that price doesn&#8217;t include an enclosure (I haven&#8217;t figured out a perfect housing yet), or the costs of the printed circuit board and tools. There should probably be some capacitors in this design as well, but I haven&#8217;t gotten there yet. Most of the small passive components and the NPN transistor in that list can be substituted with parts that are close in value.<\/p>\n<p>The ADG407 multiplexer <a href=\"http:\/\/www.analog.com\/en\/switchesmultiplexers\/multiplexers-muxes\/adg407\/products\/product.html\">(datasheet)<\/a> is what allows us to feed 8 different thermocouples into a single $13 AD595 thermocouple amplifier. The AD595 <a href=\"http:\/\/www.analog.com\/en\/sensors\/analog-temperature-sensors\/ad595\/products\/product.html\">(datasheet)<\/a> is designed to work with type K thermocouples, and type-T thermocouples are functionally identical over the 0\u00b0C to 50\u00b0C temperature range that most biological studies inhabit. Note that I list the AD595<strong>A<\/strong> model here, which is only spec&#8217;d from the factory to be +\/- 3\u00b0C, but you&#8217;ll typically find that they&#8217;re pretty much spot-on when compared to a calibrated thermometer or other temperature measuring device. You also have the ability to calibrate your particular datalogger (which you should absolutely be doing) and make adjustments in software to suit the particular AD595 that you receive. There is a much more expensive $30 AD595<strong>C<\/strong> model available as well (+\/- 1\u00b0C) that is manufactured to tighter tolerances at the factory, but I&#8217;m not convinced it&#8217;s necessary if you calibrate properly. Again, for a homemade project like this, designed by a person whose electrical engineering training consists of taking an electronics shop class in 9th grade (really), you should really be verifying the output temperatures yourself.<\/p>\n<p>The Eagle schematic for the LCD+thermocouple board looks like this:<\/p>\n<figure id=\"attachment_1477\" aria-describedby=\"caption-attachment-1477\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/Updated_sch.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-1477\" alt=\"Eagle schematic for the circuit.\" src=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/Updated_sch-300x289.png\" width=\"300\" height=\"289\" srcset=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/Updated_sch-300x289.png 300w, https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/Updated_sch-1024x988.png 1024w, https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/Updated_sch.png 1033w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-1477\" class=\"wp-caption-text\">Eagle schematic for the circuit.<\/figcaption><\/figure>\n<p>Eagle schematic file: <a href=\"http:\/\/www.lukemiller.org\/electronics\/tc_mux\/tc_mux_board_v7.sch\">tc_mux_board_v7.sch (updated 2013-01-31)<\/a><\/p>\n<p>My layout for the LCD+thermocouple board exceeds the PCB dimensions allowed by the free version of CadSoft&#8217;s Eagle program, so I laid my board out using <a href=\"http:\/\/www.freepcb.com\/\">FreePCB<\/a>, which is available as freeware. The FreePCB project file and a pdf of the bottom copper layer suitable for toner-transfer etching are available here:<br \/>\nFreePCB file: <a href=\"http:\/\/www.lukemiller.org\/electronics\/tc_mux\/tc_mux_rev7.fpc\">tc_mux_rev7.fpc<\/a><br \/>\nPDF of bottom copper layer: <a href=\"http:\/\/www.lukemiller.org\/electronics\/tc_mux\/tc_mux_v7.pdf\">tc_mux_v7.pdf<\/a><\/p>\n<p>Finally, the sketch that runs everything is here: <a href=\"http:\/\/www.lukemiller.org\/electronics\/tc_mux\/temp_mux_proto_v7.pde\">temp_mux_proto_v7.pde<\/a> (only works under Arduino v22 or earlier)<\/p>\n<p><strong>UPDATE 2012: <\/strong>A current version of the code, updated to work under Arduino 1.0, can be found at my github.com account:<\/p>\n<p><a href=\"https:\/\/github.com\/millerlp\/Thermocouple_datalogger\" target=\"_blank\">http:\/\/github.com\/millerlp\/Thermocouple_datalogger<\/a><br \/>\nThe program weighs in at 24598 bytes, which is too large to fit on an older Atmega168 microcontroller, but leaves you some room to expand on a Atmega328 or Mega.<\/p>\n<p>Before running the temperature logging sketch, you must go through the initial setup routine for the Adafruit datalogger shield in order to initialize the real time clock and SD card. <a href=\"http:\/\/www.ladyada.net\/make\/logshield\/\">See the tutorial <\/a>at the Adafruit site for that information.<\/p>\n<p>Once everything is built and loaded, the temperature logger goes through a few initial setup screens before logging data.<\/p>\n<p>First it displays the current time and date to help you verify that the timestamps will be correct.<\/p>\n<figure id=\"attachment_345\" aria-describedby=\"caption-attachment-345\" style=\"width: 400px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/LCD_time.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-345\" title=\"LCD_time\" alt=\"\" src=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/LCD_time.jpg\" width=\"400\" height=\"289\" srcset=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/LCD_time.jpg 400w, https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/LCD_time-300x216.jpg 300w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/a><figcaption id=\"caption-attachment-345\" class=\"wp-caption-text\">Time verification<\/figcaption><\/figure>\n<p>The next screen lets the user set the data saving interval. The options range from 5 seconds to 10 minutes. The user can press a button (visible to the upper left of the LCD) to cycle through the various options. Since I&#8217;m using a 2GB SD card, it would take weeks or months to fill with the simple text data we&#8217;ll be recording, so a fast sampling rate makes sense.<\/p>\n<figure id=\"attachment_346\" aria-describedby=\"caption-attachment-346\" style=\"width: 400px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/LCD_save_interval.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-346\" title=\"LCD_save_interval\" alt=\"\" src=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/LCD_save_interval.jpg\" width=\"400\" height=\"289\" srcset=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/LCD_save_interval.jpg 400w, https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/LCD_save_interval-300x216.jpg 300w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/a><figcaption id=\"caption-attachment-346\" class=\"wp-caption-text\">Choosing the save interval<\/figcaption><\/figure>\n<p>Next the user is presented with the option to set how long the LCD backlight will stay on, using the same button for control. To save battery power, the LCD is shut off after some amount of time, while the datalogging routine continues running in the background. The user can hit the button any time to turn the LCD backlight on again.<\/p>\n<figure id=\"attachment_347\" aria-describedby=\"caption-attachment-347\" style=\"width: 400px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/LCD_light_timeout.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-347\" title=\"LCD_light_timeout\" alt=\"\" src=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/LCD_light_timeout.jpg\" width=\"400\" height=\"289\" srcset=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/LCD_light_timeout.jpg 400w, https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/LCD_light_timeout-300x216.jpg 300w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/a><figcaption id=\"caption-attachment-347\" class=\"wp-caption-text\">Choosing the lcd timeout<\/figcaption><\/figure>\n<p>After those setup steps, the datalogger begins displaying and recording temperatures from all 8 thermocouple channels. A little &#8220;save&#8221; indicator pops up after each write to the SD card.<\/p>\n<figure id=\"attachment_348\" aria-describedby=\"caption-attachment-348\" style=\"width: 400px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/LCD_temps.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-348\" title=\"LCD_temps\" alt=\"\" src=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/LCD_temps.jpg\" width=\"400\" height=\"289\" srcset=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/LCD_temps.jpg 400w, https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/LCD_temps-300x216.jpg 300w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/a><figcaption id=\"caption-attachment-348\" class=\"wp-caption-text\">Temperature data<\/figcaption><\/figure>\n<p>The temp_mux_proto_v7.pde program uses a simple smoothing routine to avoid aliasing weird voltage readings. The last 10 readings on a channel are averaged and the result is displayed as the temperature for that channel. The temperature readings are occurring roughly every 500ms, and temperatures tend to change relatively slowly, so this smoothing routine won&#8217;t introduce much delay in the temperature output.<\/p>\n<p>The data are written to the SD card in a comma-separated-value (.csv) file. A new file is created each time the logger is restarted, and each file gets a unique name (LOGGER00.csv, where the 00 increments each time). The data can be downloaded to any computer and opened with a spreadsheet program.<\/p>\n<figure id=\"attachment_350\" aria-describedby=\"caption-attachment-350\" style=\"width: 752px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/csv_file.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-350\" title=\"csv_file\" alt=\"\" src=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/csv_file.png\" width=\"752\" height=\"123\" srcset=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/csv_file.png 752w, https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/csv_file-300x49.png 300w\" sizes=\"auto, (max-width: 752px) 100vw, 752px\" \/><\/a><figcaption id=\"caption-attachment-350\" class=\"wp-caption-text\">The output file. The thermocouples were sitting in an ice bath at this point. The unixtime column is similar to the standard seconds since Jan 1 1970, but the real time clock library doesn<\/figcaption><\/figure>\n<p>I calibrated the thermocouple temperatures against a NIST-traceable 0.1\u00b0C alcohol thermometer, with everything submerged in a well-mixed water bath. Using the thermometer as my reference, I recorded thermocouple temperatures over a range from ~0 to 50\u00b0C. For comparison, I also included a thermocouple in the water bath that was attached to a commercial Omega HH21 hand-held thermocouple thermometer.<\/p>\n<figure id=\"attachment_349\" aria-describedby=\"caption-attachment-349\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/Calibration_figures.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-349\" title=\"Calibration_figures\" alt=\"\" src=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/Calibration_figures-300x249.png\" width=\"300\" height=\"249\" srcset=\"https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/Calibration_figures-300x249.png 300w, https:\/\/lukemiller.org\/wp-content\/uploads\/2010\/08\/Calibration_figures.png 785w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-349\" class=\"wp-caption-text\">Temperature data<\/figcaption><\/figure>\n<p>The data for the 8 thermocouples are given in the left column, and data from the HH21 thermocouple thermometer are shown in the right column. Both sensors are reasonably linear across the full temperature range compared to the reference thermometer. My thermocouple mux transitions from reading slightly warm to slightly cool over the whole temperature range, but the majority of values are within 0.5\u00b0C of the thermometer value. Given that I was recording the thermometer values by hand and matching up the thermocouple data after the fact, the actual deviation is probably slightly less. The Omega HH21 read slightly cool across the whole temperature range, going from 0.8 to 0.2\u00b0C cooler than the thermometer as I warmed the water.<\/p>\n<p>I&#8217;ve set the Arduino to use the Atmega328&#8217;s internal bandgap voltage as its analog reference voltage. The bandgap voltage is nominally 1.1V, +\/- 5%. You can tweak this value in the sketch if the thermocouples are consistently reading high or low, since your Atmega chip may be slightly different from the factory. Using the bandgap reference limits the usable temperature range of the thermocouples to roughly 0-110\u00b0C, since the AD595 amplifier puts out a 10mV\/\u00b0C signal that should reach 1.1V at 110\u00b0C. The bandgap voltage allows a fairly high temperature resolution, recording temperatures in 0.11\u00b0C steps. Additionally, the bandgap voltage appears to be quite stable over a range of supply voltages. I ran the logger until my battery pack dropped down to ~3.8V, so that the LCD was no longer able to light up, but the temperatures recorded by the logger were stable right up until the microcontroller quit running altogether.<\/p>\n<p>The major caveat with this system currently is that it seems to be extremely susceptible to ground loop noise (see <a href=\"http:\/\/news.jeelabs.org\/2010\/05\/08\/thermocouple-enigma\/#comments\">Jee Labs<\/a> for a similar problem). If you use this in a noisy electrical environment, those long thermocouple wires can act as antennae and lead to wildly fluctuating input voltages and wildly inaccurate temperature values. For instance, using the heating element of my laboratory hot plate\/stirrer caused all sorts of funky things to happen. Turning the heating element off (while keeping the magnetic stir bar running) let the logger record accurate temperatures. Obviously this won&#8217;t be an issue if you&#8217;re out in the field far away from any electrical noise, but usage in the lab may be hampered in some cases. The logger also picks up noise from cheap wall wart power supplies and on at least some of my computer USB ports. As a result, I run the logger primarily off of a battery pack for now.<\/p>\n<p>Finally, if you&#8217;ve never put together your own thermocouples from scratch, I have an older post explaining the process: <a href=\"http:\/\/www.lukemiller.org\/journal\/2008\/04\/rolling-your-own-thermocouples.html\">Rolling your own thermocouples<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Building a 8-channel temperature datalogger using Arduino.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[217,4],"tags":[21,6,22,5],"class_list":["post-331","post","type-post","status-publish","format-standard","hentry","category-arduino","category-journal","tag-arduino","tag-datalogger","tag-temperature","tag-thermocouple"],"_links":{"self":[{"href":"https:\/\/lukemiller.org\/index.php\/wp-json\/wp\/v2\/posts\/331","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lukemiller.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lukemiller.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lukemiller.org\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/lukemiller.org\/index.php\/wp-json\/wp\/v2\/comments?post=331"}],"version-history":[{"count":32,"href":"https:\/\/lukemiller.org\/index.php\/wp-json\/wp\/v2\/posts\/331\/revisions"}],"predecessor-version":[{"id":2000,"href":"https:\/\/lukemiller.org\/index.php\/wp-json\/wp\/v2\/posts\/331\/revisions\/2000"}],"wp:attachment":[{"href":"https:\/\/lukemiller.org\/index.php\/wp-json\/wp\/v2\/media?parent=331"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lukemiller.org\/index.php\/wp-json\/wp\/v2\/categories?post=331"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lukemiller.org\/index.php\/wp-json\/wp\/v2\/tags?post=331"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}