You are on page 1of 18

/ Arduino Data Logger (Log Temperature, Humidity, Time on SD Card and
Home Computer)

Arduino Data Logger (Log Temperature, Humidity, Time on SD Card and Computer)
By B.Aswinth Raj 9 Comments

Arduino Temperature Data Logger using DHT11

As Engineers/Developers we always rely upon the data collected to design or improve a system. Recording data and analyzing them is a
common practice in most of the industries, here we are building Arduino Data Logger Project where we will learn how we can log data at
a speci c interval of time. We will use an Arduino board to read some data (here temperature, humidity, date and time) and save them on
a SD card and the computer simultaneously.

Arduino Project


The data saved can be easily opened in an Excel Sheet for further analyses. To maintain the date and time we will use the famous RTC
module DS3231 and to get the Temperature and Humidity we will use the DHT11 Sensor. At the end of the project you will learn

1. How to log data into SD card with Date, Time and sensor values.
2. How to write data directly to Excel Sheet on PC via serial communication.

Materials Required:
1. Breadboard
2. Arduino UNO (any Arduino board)
3. DHT11 Temperature sensor
4. DS3231 RTC module
5. SD card module

Computer/Laptop DHT11 Temperature and Humidity Sensor Circuit Diagram: The circuit Diagram for this Arduino Temperature Logger Project is shown below. Connecting wires 8. AdChoices Download Spreadsheet Reading Program As shown in the circuit diagram the connections are very simple since we have used them as modules we can directly build them on a breadboard. SD card 7. 6. The connections are further classified in the table below Arduino Pin Module Pin Temperature Sensor – DHT11 Vcc 5V Gnd Gnd Nc Nc Out Pin 7 RTC module DS3231 Vcc 5V Gnd Gnd SCL Pin A5 .

Initialize the SPI bus to interface the SD card module with Arduino. SCK.ZIP Library To feed the data from Arduino lively into an Excel sheet on computer we will also need to install software called PLX-DAQ provided by . Initialize the I2C bus to read data from RTC module. You can check LM35 with Arduino to read temperature. Read data from DTH11 Sensor (or any other data that you wish to log). 1. you can change them to any other pin if required. The RTC module DS3231 is interfaced with Arduino using the I2C communication (SCL. The pins 4 and 7 are de ned as the CS pin and output pin by Arduino program. Store the Date. CS). Time. Arduino Program Explanation: We have to write the Arduino program which can do the following. Store the Date. 2. DS3231 RTC module library from Rinky-Dink Electronics Once you have downloaded the library add them to your Arduino IDE by following Sketch->Include Library -> Add . SDA Pin A4 SD card Module Vcc 5V Gnd Gnd MISO Pin 12 MOSI Pin 11 SCK Pin 13 CS Pin 4 You can replace the DHT11 temperature sensor with any of your sensor from which you need to log the values. DHT11 Sensor Library from GitHub 2. MOSI. We previously interfaced SD card with Arduino in Music player project. SDA) and the SD card module is interfaced using the SPI Communication (MISO. 5. Temperature and Humidity on a Excel Sheet running on a computer/Laptop. Temperature and Humidity into the SD card. 4. Time. You have to download the following two libraries 1. The above steps might sound complicated but they are very easy since we have the libraries to do the hard job for us. 3.

//Sensor object named as DHT void Read_DHT11() { int chk = DHT. Follow the link to download the le and install them based on your operating system. Reading Data from DS3231: DS3231 is a RTC (Real Time Clock) module. 2. 45).setTime(18. 2017). // Init the DS3231 using the hardware interface DS3231 rtc(SDA. Initializing the SC card module: .temperature and DHT. 46. Also check this DHT11 based Arduino Temperature Measurement. Calling DHT. SCL). You can also use RTC IC DS1307 for reading the time with Arduino . 30. // Set the time to 12:00:00 (24hr format) rtc. Further. void Initialize_RTC() { // Initialize the rtc object rtc. #define DHT11_PIN 7 //Sensor output pin is connected to pin 7 dht DHT. It can be done by simply removing the comments as mentioned above and writing the date and time.setDate(6. I will explain the important segments below.Humidity respectively. I have tried my best to keep the code as simple as possible and the explanations are also given through comment sections. It sends the values of temperature and humidity as an 8-bit data serially through the output pin of the module. // Set the date to January 1st.setDOW(FRIDAY). 1. } Here I have connected the output pin to pin 7 as example you can choose any pin that supports Software Serial. // Set Day-of-Week to SUNDAY rtc. 2014 */ } Note: When using this module for the rst time you have to set the date and number). Now after adding both libraries and after installing the software. will read the value of temperature and humidity and store it in the parameter DHT. This module has its own coin cell power supply using which it maintains the date and time even when the main power is removed or the MCU has gone though a hard reset. you can use the Complete Code (given at bottom of tutorial) and upload them to your Arduino. Using this module is very easy because of the library provided by Arduino. We will take care of it later in our working section. 3. else each time you run the board the date and time will be set again. //#### the following lines can be uncommented to set the date and time for the first time### /* rtc. It is used to maintain the date and time for most of the Electronics projects. This should have created a folder named PLS-DAQ on your desktop. So once we set the date and time in this module it will keep track of it always. Reading Data from DHT11: DHT11 is a Temperature come Humidity sensor.begin().read11(DHT11_PIN). The library reads this data by using the software serial function of the Arduino. Make sure you comment them back and upload it.Parallax Inc.

txt".print(DHT.print(rtc.print(". write to it: if (dataFile) { dataFile. write to it: if (dataFile) { dataFile. //Write the first row of the excel file dataFile.print(".Time. Here we separate the values by using a “.open("LoggerCD. With the help of the DS3231 library and the DHT11 library our Arduino will be capable of reading all these four parameters and storing them into the following parameters as shown in table below Date rtc. // if the file is available. note that only one file can be open at a time. File dataFile = SD.print(rtc."). } } Using an SD card with Arduino is easy because of the SD card library which will be added to the Arduino IDE by default.println().temperature Humidity DHT. //Move to next column using a ". //Store date on SD card dataFile. FILE_WRITE).” as a delimiter. Time rtc. Time. Writing Data to SD card void Write_SDcard() { // open the file. or not present"). 4. //Store date on SD card dataFile. // don't do anything more: return. } // open the file." dataFile." dataFile.").println("Card failed.").getDateStr()).getTimeStr()). //Close the file } else Serial. note that only one file can be open at a time.humidity ." dataFile. Temperature and Humidity into our SD card .open("LoggerCD.Temperature. //Store date on SD card dataFile.getTimeStr()).Humidity"). } As said earlier our intention is to save the Date. Temperature DHT.temperature).txt” and write the rst row of our content. //Store date on SD card dataFile. //Move to next column using a ".getDateStr()).print("." dataFile.txt". // so you have to close this one before opening another.println("OOPS!! SD card writing failed").println("Date. // so you have to close this one before opening another. //Move to next column using a ". //End of Row move to next row dataFile.void Initialize_SDcard() { // see if the card is present and can be initialized: if (!SD.begin(chipSelect)) { Serial. Meaning when a comma is placed it means we have to move to the next cell in the Excel sheet. FILE_WRITE).print(".humidity).close(). File dataFile = SD. //Move to next column using a ". // if the file is available. In the SD card initialize function we will create a text le named “LoggerCD.close().print(DHT.").

//Store date on Excel Serial.println("CLEARDATA"). You can simply use the date and time running on your Laptop/computer and save them directly on Excel. //Move to next column using a "..Date. //Move to next column using a ".Humidity"). 5. TIME. You do not need a RTC Module like DS3231 to keep track of date and time.").print(parameter). your temperature and humidity values will start to get stored in your SD card.println().print("DATE"). Once the hardware and the software are ready it is time to burn the program into your Arduino Board. //always write LABEL. To indicate that we have to move to next row we have to use comma (“.print(". //Store date on Excel Serial. Later in the Write function we use the keyword “DATA” to indicate that the following information should be considered as DATA.print(DHT. This is my personal favourite because of two reasons: 1." Serial. You can notice that each parameter is separated by a comma to make it look legible and a dataFile. As soon your program gets uploaded.temperature)." Serial. To use this software with Arduino we have to send the data serially in a speci c pattern just like displaying value on serial monitor. //Store date on Excel Serial. You . The key lines are explained below: void Initialize_PlxDaq() { Serial.").print("DATA"). //always write "DATA" to Inidicate the following as Data Serial. Working Explanation: Working of the Arduino Data Logger is simple.print(DHT.print(". Writing Data to PLX-DAQ PLX-DAQ is Microsoft Excel Plug-in software that helps us to write values from Arduino to directly into an Excel le on our Laptop or PC."). 2.println(). //Move to next column using a "." Serial.print("TIME"). As shown in the Initialize function the keyword “LABEL” is used to write the rst ROW of the Excel sheet. //Store date on Excel Serial. to indicate it as first line } void Write_PlxDaq() { Serial.print(".Time. //clears up any data left from previous projects Serial." Serial. To indicate the end of row we have to send a Serial.").Now we can directly use these parameters to store them on the SD card using the print line dataFile. //End of Row move to next row } The software can recognize keywords like LABEL.print(".Temperature.humidity). is used to indicate the end of the line.println(). Note: Do not use serial monitor when using this PLX_DAQ software.”). DATA.println("LABEL." Serial.You can write and monitor the data at the same time and provides us way to plot them as graphs."). //Move to next column using a ".print(". //Move to next column using a ". DATE etc. As said earlier we can write the system date and time by sending the keywords “DATE” and “TIME” respectively as shown above.

click on Options->Enable the content -> Finish -> OK to get the following screen. Step 2: If there is a Security block.have to follow the steps below to enable PLX-DAQ to log the into Excel sheet in the computer. . You should nd a text le named “LoggerCD. As this is happening our SD card would also have saved the same values. To check is that is working simply remove the SD card and open it on your Computer. When opened it would look something like this. Step 1: Open the “Plx-Daq Spreadsheet” file that was created on your desktop during installation.txt” in it. Step 3: Now select the baud rate as “9600” and the port to which your Arduino is connected and click on Connect. Your values should start to get logged like shown in the picture below. You can leave this excel sheet open and monitor the values as they get logged.

Hope you liked the project. Then Finish.. Bonus Improvement. Simply connect a Bluetooth Device like HC-05 and write the data to PLX-DAQ via Bluetooth instead of Serial.print(parameter). but it would be hard to analyse them on a notepad. then with few advancements and just adding a few lines of code you can log data wirelessly. Click on File->Open and select “All le” at bottom right corner and select the “LoggerCD” le from the SD card. To open in excel 1. Click on “Next” again. and connect your Laptop to your Bluetooth Module an select the COM port to which your Laptops Bluetooth is connected and Taadaaa. thus making it more effective.This le has data. you can log them for any desired time by changing the delay function in the program.. 2. This will open a text import wizard. with BluetoothName.Wireless Data Logging Using Arduino: Once you have succeeded up to this point. You have a working a Wireless Data Logging System in no time. For detailed understanding of the working please watch the video below.Now your values will be opened in a Excel file as shown below I have logged the values for every 5 seconds. Hence we can open it on Excel as a CSV (Comma separated values) file...Click on “Next” and select comma as a delimiter.print(parameter). That is replace Serial. Code: /* * Program to demonstrate Data Logging/Visualisation using Arduino * * ###Connection with SD card module### * Vcc->5V * Gnd->Gnd * MISO->pin 12 * MOSI->pin 11 . 3..Open Excel. if you have any doubt write them in the below comment section and I will help you out.

//SD card CS pin connected to pin 4 of Arduino // Init the DS3231 using the hardware interface DS3231 rtc(SDA. Write_SDcard()." Serial.h> //Library for RTC module (Download from Link in article) #include <SPI.print(DHT. Write_PlxDaq(). //Store date on Excel Serial.print("TIME").print(". //always write LABEL.print("."). //Wait for 5 seconds before writing the next data } void Write_PlxDaq() { Serial. } void loop() { Read_DHT11().h> //Library for dht11 Temperature and Humidity sensor (Download from Link in article) #define DHT11_PIN 7 //Sensor output pin is connected to pin 7 dht DHT.print("DATE").h> //Library for SPI communication (Pre-Loaded into Arduino) #include <SD. delay(5000).print(".print(".Time. //Move to next column using a ".Humidity").print(DHT.Date. Initialize_PlxDaq().println("CLEARDATA").")." Serial. void setup() { // Setup Serial connection Serial.println("LABEL. SCL). //clears up any data left from previous projects Serial. //Sensor object named as DHT const int chipSelect = 4." Serial. //Store date on Excel Serial.").print("DATA"). // so you have to close this one before opening another.temperature). //Move to next column using a ". //Move to next column using a ". //Move to next column using a ". //always write "DATA" to Indicate the following as Data Serial."). Initialize_SDcard().Temperature.").* SCK-> pin 13 * CS-> pin 4 * * ###Connection with DS3231### * Vcc->5V * Gns->Gnd * SCL->pin A5 * SDA-> pin A4 * * ###Connection with DT11### * Vcc->5V * Gnd->Gnd * Out-> pin 7 * * */ #include <DS3231. //Store date on Excel Serial. .print("." Serial.begin(9600). //End of Row move to next row } void Initialize_PlxDaq() { Serial. note that only one file can be open at a time. //Store date on Excel Serial.println(). to indicate it as first line } void Write_SDcard() { // open the file. Initialize_RTC(). //Move to next column using a ".h> //Library for SD card (Pre-Loaded into Arduino) #include <dht." Serial.humidity).

// Set Day-of-Week to SUNDAY rtc. FILE_WRITE).getDateStr()).Time.Humidity").close().print("Temperature = "). // Set the time to 12:00:00 (24hr format) rtc.print(DHT. // if the file is available.println(DHT.txt".print(rtc.humidity).open("LoggerCD.getTimeStr())." dataFile.setTime(18. or not present"). Serial.begin().txt". // Set the date to January 1st. }*/ /*void Read_TempHum() { Serial. File dataFile = SD. write to it: if (dataFile) { dataFile. //Store date on SD card dataFile.read11(DHT11_PIN). //#### The following lines can be uncommented to set the date and time for the first time### /* rtc.close().setDOW(FRIDAY). } // open the file. // so you have to close this one before opening another.println()." dataFile.println(rtc. // if the file is available. //Store date on SD card dataFile."). //End of Row move to next row dataFile.getDateStr()). // Send time Serial.println("Card failed.print(rtc.println("OOPS!! SD card writing failed").setDate(6.print("."). //Move to next column using a ". //Move to next column using a ".print(". //Store date on SD card dataFile.print(DHT. } /*void Read_DateTime() { // Send date Serial. FILE_WRITE)."). //Move to next column using a ".humidity).").getTimeStr())."). .temperature).print(" -.println(DHT. 45).print(".print(rtc." dataFile. note that only one file can be open at a time. 30. } } void Initialize_RTC() { // Initialize the rtc object rtc. File dataFile = SD. //Write the first row of the excel file dataFile."LoggerCD. //Store date on SD card dataFile. // don't do anything more: return. 2017). write to it: if (dataFile) { dataFile.temperature). 46.print("Humidity = ").print(". Serial.begin(chipSelect)) { Serial. Serial. //Close the file } else Serial. } void Initialize_SDcard() { // see if the card is present and can be initialized: if (!SD. //Move to next column using a ". 2014 */ } void Read_DHT11() { int chk = DHT.println("Date.Temperature." dataFile.

I would like to convert it to Fahrenheit. Thank you very much Jul 20. Jul 12. so can you tell me if the PLX-DAQ software plugin will work with Libre Office Calc? If I had that running it would solve this problem. Quote Online Now Add new comment Comments (9) reply mark church Very well described project and applications are endless thank you for the tutorial. 2017 reply Joe Huard I like all of these instructions to do data logging. 2017 reply Greg Fun project. Could you post how to change to Fahrenheit. }*/ Video: JLCPCB Prototype: Only $2 for 10 pcs PCBs.000+ Customers & 8. My project involves reading the Sentron PAC3200 sub-meter and saving it 4 times per day into a spreadsheet. 2017 reply Arif . an Arduino that can wake me up to re-boot my computer if and when it shut off when I was asleep. 48 Hours Quick Turn China's Largest PCB Manufacturer.000+ Online Orders Per Day Up to $20 Shipping Discount on First order. 290. and the only remaining problem would be missing data from when the computer shuts off due to a power outage. I've been trying for a bit and cannot get it to work.perry looks very interesting Aug 14. even cheaper. I was thinking Arduino but have no experience with that. I could solve that by using a battery-backed up laptop or a UPS. I see the direct writing to my computer as the best and shortest solution. 2017 reply keith. Oct 24. Or. // delay(1000).

Save Preview RELATED CONTENT .Aswinth Raj https://www. Subject Comment * No HTML tags allowed. pls help me to do this. 2018 reply AISHA Did you download and add the DHT library to your IDE? If not you will get this error Feb 07.arduino. If possible what need to be done.8. 2017 reply Ola Dunk Thanks for sharing this nice project. Is it possible real time speed monitoring? We have 40 machine in a This link explains which pins of Arduino is related to which pins Mar 22. Ola Feb 05. we want to monitor the real time speed of these machines. 2018 reply Pashar How do I find out to which port is my arduino connected? Mar 21. Very nice project. 2018 reply B. Web page addresses and e-mail addresses turn into links automatically. Are some header files missing ? Or do I need an older version to compile successfully ? What else could be wrong ? regards. I appreciate this. 2018 Leave a comment Your name * E-mail * The content of this field is kept private and will not be shown publicly. Lines and paragraphs break automatically.5 and get a lot of errors about DHT missing class etc. I have tried to compile it with Aduino IDE v 1. Dec 29.

Interfacing Joystick with Arduino Arduino Light Sensor Circuit using LDR Arduino Ohm Meter MPU6050 Gyro Sensor Interfacing with Arduino Battery Voltage Indicator using Arduino and LED Bar Graph LATEST POSTS Wein Bridge Oscillator .

Interfacing Joystick with Arduino Implantable sensor relays real-time personal health data to a cell phone .

Interfacing LCD with MSP430G2 LaunchPad X-Class CMOS Image Sensor Platform from ON Semiconductor Enables New Functionality for Industrial Camera Design .

RC Phase Shift Oscillator ACTIVE FORUM TOPICS Morelow voltage analog signal passing through microcontroller RFID Hitag S 256 Technology for Racing Pigeon Timing device I am new a member Latest electrical engineering project Assistance with science fair USER LOGIN E-mail or username * Password * Log in Create new account Request new password .

FEATURED PROJECTS AND CIRCUITS Capacitance Measure MP3 Fingerprint Virtual Smoke IOT DIY Smart How Call Arduino Live Blind Sound/Noise Power Arduino Player Data Reality Speedometer Detector Robotic based Smart Phone to and Based Temperature Meter Stick Level Bank Make Based Circuit Biometric Logger Arm Raspberry Vacuum Controlled Use Message Digital and using in Circuit a CNC Attendance (Log MQ2 Pi Cleaning FM NeoPixel using Clock Humidity Arduino dB Mini Plotter System Temperature. Processing Sensor Security using Strip and Alarm over Microphone Coil Time Android and System Arduino with GSM Internet 9v on App with and Arduino Module using SD Email Processing and Arduino Card Alert TFT and and LCD ThingSpeak Computer) View all Featured Projects Robotics | EE Projects | 555 Timer Circuits | ATmega32 Projects | ATmega8 Projects | Arduino Projects | Raspberry Pi Projects | IoT Projects | Arduino ESP8266 | Calculators SIGN UP FOR LATEST NEWS Subscribe Copyright © 2018 Circuit Digest. and Gas Home Robot Radio LED Arduino with Monitoring with Tesla Machine Humidity. Advertise . All rights Privacy policy | Disclaimer | Contact Us | Submit | reserved.