Arduino

Arduino Tutorial #26 How to take Arduino sensor data to excel sheet.

How to take arduino sensor data to excel sheet

In this tutorial we are going to see how to take arduino sensor data to excel sheet and plot it for analysis. So let’s get started.

For this you will need a software Tera Term. Which will take Arduino data to excel sheet.  You can take any sensor data with this software. Download link for software Tera Term.  For this tutorial we are going to make temperature go high with hot air of hair dryer and sensor data will be plotted in excel sheet. If you want to know more about temperature sensor with Arduino click here.  After downloading software tera term. Install it. Now you can see its icon on desktop but before opening it go to Arduino IDE.

Sketch we are using for this experiment.

// Example testing sketch for various DHT humidity/temperature sensors
// Written by ladyada, public domain

#include "DHT.h"

#define DHTPIN 2 // what digital pin we're connected to

// Uncomment whatever type you're using!
//#define DHTTYPE DHT11 // DHT 11
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
//#define DHTTYPE DHT21 // DHT 21 (AM2301)


DHT dht(DHTPIN, DHTTYPE);

void setup() {
 Serial.begin(9600);
 Serial.println("Date & Time, Humidity %, Temperature *C, Temperature *F");

dht.begin();
}

void loop() {
 // Wait a few seconds between measurements.
 delay(1000);

// Reading temperature or humidity takes about 250 milliseconds!
 // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
 float h = dht.readHumidity();
 // Read temperature as Celsius (the default)
 float t = dht.readTemperature();
 // Read temperature as Fahrenheit (isFahrenheit = true)
 float f = dht.readTemperature(true);

// Check if any reads failed and exit early (to try again).
 if (isnan(h) || isnan(t) || isnan(f)) {
 Serial.println("Failed to read from DHT sensor!");
 return;
 }


 Serial.print(",");
 Serial.print(h);
 Serial.print(",");
 Serial.print(t);
 Serial.print(",");
 Serial.println(f);

}

And add this line in setup function.

 Serial.println("Date & Time, Humidity %, Temperature *C, Temperature *F");

Depend upon your sketch you can decide how many numbers of columns you require. We want 4 columns first column is for date & time. But make sure each column is separated with comma (,). Then second column is for humidity then temperature in Celsius & temperature in Fahrenheit. And also make sure it is printed in new line.

 Serial.print(",");
 Serial.print(h);
 Serial.print(",");
 Serial.print(t);
 Serial.print(",");
 Serial.println(f);

We are adding comma before humidity because first column is for date and time it will be generated by tera term software. So each data is separated by comma. Make sure it is in same line. In last line it is println. Now open the tera term software.

Tera Term Serial
Tera Term Serial

Select serial and port. Goto file and click on log.

Tera Term log
Tera Term log

Check the box timestamp because we want date and time also. It will ask where we want to save this log file.

Tera Term save log
Tera Term save log

I am saving it on desktop. Make sure you save it with .csv file. So it will create excel sheet. After saving log file press reset button on Arduino. Now I am making temperature go high by hot air of hair dryer. After taking readings you can close the tera term software. Goto desktop and open file. In excel sheet select all column and goto insert then chart and plot all three data in one graph.

Arduino sensor data is plotted in excel sheet
Arduino sensor data is plotted in excel sheet

You can plot only one data at a time just select two column and plot it.  This data can use for further analysis.

Single data graph for arduino sesnor data to excel sheet
Single data graph for arduino sesnor data to excel sheet
Components list to buy online:

http://amzn.to/2vqIKJP  (DHT22)

http://amzn.to/2fvSRJq   (Arduino)

http://amzn.to/2wxPmWz  (Breadboard)

http://amzn.to/2vJ3lvo   (Jumper wire)

http://amzn.to/2vmSK8l  (Resistor)

For more videos subscribe the channel

Till than keep learning keep making. 🙂

 

Leave a Reply

Your email address will not be published. Required fields are marked *