Few weeks ago I made a datalogger using Arduino, SD card, DS3231 real time clock chip and DHT22 sensor which logs: date, time, temperature and humidity values where data is stored on a text file in the SD card.
This topic shows how to build the same data logger using Arduino, DHT22 sensor and Microsoft Excel where the Arduino sends data (temperature and humidity) serially to an Excel sheet.
Related Projects:
Arduino datalogger with SD card, DS3231 and DHT22 sensor
Arduino with DHT22 sensor and LCD
Hardware Required:
- Arduino board
- DHT22 digital humidity and temperature sensor
- 4.7k ohm resistor
- Breadboard
- Jumper wires
The Circuit:
Project circuit schematic is shown below.
As shown above, the circuit is very simple we need the DHT22 sensor only and there is no need for a real time clock chip (DS3231, DS1302, DS1307 …) because Microsoft Excel can get data and time information from Windows.
The DHT22 sensor has 4 pins (from left to right): VCC (5V), data, NC (not connected pin) and GND. Data pin is connected to Arduino UNO pin 2.
Arduino Code:
To read data (temperature and humidity) from the DHT22 sensor we need a small library which can be downloaded from the link below. After downloading the library, it can be added to Arduino IDE by going to: Sketch –> Include Library –> Add .ZIP Library …
Adafruit DHT sensor library – GitHub
In order to send data serially from the Arduino board to Excel we need a small software named PLX-DAQ (Parallax Data Acquisition tool). This software is just an add-in for Microsoft Excel. PLX-DAQ download link can be found in the page below:
https://www.parallax.com/downloads/plx-daq
After downloading and installing you will see a new folder created in your PC desktop named: PLX-DAQ which contains two shortcut files: PLX-DAQ Help File and PLX-DAQ Spreadsheet. Double click (or open using Excel) on the second file (PLX-DAQ Spreadsheet) gives a window as the one shown in the picture below. If there is a security warning (macros have been disabled) just click on Options –> check: Enable this content –> OK . Note that this plugin was tested with Microsoft Office 2007 and it should work with Office 2010, but unfortunately it doesn’t work with Office 2013.
To start receiving data just choose the COM port and baud rate then click on Connect (Arduino IDE serial monitor must be closed before connecting with PLX-DAQ software).
Full Arduino code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | // Excel datalogger using Arduino and DHT22 sensor #include <DHT.h> // Include DHT library code #define DHTPIN 2 // DHT22 data pin is connected to Arduino pin 2 #define DHTTYPE DHT22 // DHT22 sensor is used DHT dht(DHTPIN, DHTTYPE); // Initialize DHT library void setup() { Serial.begin(9600); // Initialize serial communications with the PC dht.begin(); // Initialize the DHT library Serial.println("CLEARDATA"); // Clear all Excel sheet data // Label columns: A for date, B for time, C for temperature and D for humidity Serial.println("LABEL,Date,Time,Temperature,Humidity"); } void loop() { Serial.print("DATA,DATE,TIME,"); // Write date and time on row A and row B respectively Serial.print(dht.readTemperature()); // Read temperature from sensor and send its value to Excel Serial.print(","); // Move to next column Serial.print(dht.readHumidity()); // Read humidity from sensor and send its value to Excel Serial.println(","); // Move to next column and start new row delay(1000); // Wait 1 second } |
Finally as a result I got the following Excel sheet:
If you have a problem with time column (column B) just select that column –> right mouse click –> Format Cells (a new window will open) –> select Time (from a list on the left) –> OK .
Discover more from Simple Circuit
Subscribe to get the latest posts sent to your email.
What could be the code if i use 2 or more dht sensors?
How to select the COM port?