View Single Post
Old 11-16-15, 02:01 AM   #36
TechShop
FNG
 
Join Date: Jul 2015
Location: Washington
Posts: 71
Thanks: 8
Thanked 19 Times in 13 Posts
Default Arduino temperature datalogging code.

Here is a sketch for Arduino micro-controller boards that will log data from the inexpensive DS18B20 digital temperature sensors to your SD or Micro-SD card.

The source is included in this post, and the .ino file is attached. I had to rename it to .txt so that it would upload. Download it and rename it to "_DS18B20_SDLOG.ino", or just copy and paste the code into a new sketch in your Arduino IDE window.

It is a functional and useful program that stores raw data in the CSV format. You can also send some basic commands via a serial or USB connection to change settings and retrieve data from your log file.

You can paste the log data directly into Open Office Calc, Microsoft Excel or other similar programs to create a graph. The graph I've posted in this thread was created in about 3 minutes using Open Office Calc v4.12.

I provide this AS IS. This code is sloppy and was written in a hurry so that I could get up and running. I don't plan to take it any farther because I will not be using the Arduino in my final control scheme.

Currently I am using the 1.6.6 version of the Arduino IDE.
This sketch runs on on the Arduino "Duemilanove" board with the Atmega 328P although there isn't enough memory to run as full featured as I intended. I haven't had any major problems, but it may be unstable. It should run better on the Arduino boards that use the ATmega32U4 and others with more memory than the 328P.

I used the following two locations as reference material and also blatantly ripped off some of their code. If you want to learn about the one wire library or the SD library, these are good references:

OneWire Arduino Library, connecting 1-wire devices (DS18S20, etc) to Teensy
https://www.arduino.cc/en/Reference/SD
Attached Files
File Type: txt _DS18B20_SDLOG.txt (14.2 KB, 408 views)
TechShop is offline   Reply With Quote