0

I used a DHT 11 sensor with an Arduino Uno to measure temperature and humidity. I used the following code to print the temperature and relative humidity in Serial Monitor.

dht DHT;

#define DHT11_PIN 7

void setup(){
  Serial.begin(9600);
}

void loop()
{
  int chk = DHT.read11(DHT11_PIN);
  delay(1000);
  Serial.print(DHT.temperature);
  Serial.print(" , ");
  Serial.println(DHT.humidity);
  delay(1000);
}

The Serial monitor printed the following data values in a list in the order of: time, temperature (Celsius), humidity (percentage).

22:17:55.686 -> 25.00 , 55.00
22:17:57.713 -> 25.00 , 55.00
22:17:59.741 -> 25.00 , 54.00
22:18:01.769 -> 25.00 , 54.00
22:18:03.793 -> 25.00 , 55.00
22:18:05.813 -> 25.00 , 54.00
22:18:07.837 -> 25.00 , 54.00
22:18:09.868 -> 25.00 , 55.00
22:18:11.880 -> 25.00 , 55.00
22:18:13.900 -> 25.00 , 55.00
22:18:15.915 -> 25.00 , 56.00
22:18:17.950 -> 25.00 , 56.00
22:18:19.972 -> 25.00 , 56.00
22:18:21.994 -> 25.00 , 56.00
22:18:24.024 -> 25.00 , 56.00
22:18:26.043 -> 25.00 , 56.00
22:18:28.093 -> 25.00 , 55.00
22:18:30.122 -> 25.00 , 55.00
22:18:32.141 -> 25.00 , 55.00
22:18:34.142 -> 25.00 , 55.00

I used the PuTTY software to save the sensor data to a CSV file. However, I end up with a few strange numbers at the top before the values start printing properly.

25.25.00 , 53.00
25.00 , 53.00
25.00 , 53.00
25.00 , 53.00
25.00 , 53.00
25.00 , 53.00
25.00 , 53.00
25.00 , 53.00
25.00 , 53.00
25.00 , 53.00
25.00 , 53.00
25.00 , 53.00
25.00 , 53.00
25.00 , 53.00
25.00 , 53.00
25.00 , 53.00
25.00 , 53.00
25.00 , 53.00
25.00 , 53.00

Also, when I open the CSV file in Excel, the time values have disappeared, even though they were there in the serial monitor. Excel Spreadsheet

What can I do to get the time stamps to show up in my spreadsheet? Additionally, is there a way I can have the graph automatically update as more data is read?

3
  • 1
    Your post title is how to generate the graph, but what you actually described and asking is how to get ride the unnecessary garbage from the Putty.
    – hcheung
    Jul 14, 2020 at 6:17
  • 1
    The time stamps you see in the serial monitor are generated by the serial monitor. Jul 14, 2020 at 9:19
  • 1
    You could write a visualization with processing
    – chrisl
    Jul 14, 2020 at 10:11

1 Answer 1

2

Perhaps the built-in Arduino Serial Plotter is all you need to visualize your data. I wrote a tutorial a while back that might help you.

2
  • I used the serial plotter. I get a plot of both temperature (as a blue line) and humidity (as a red line). However, I can't still get time to display on the x-axis. How do I accomplish this?
    – Dev Dhruv
    Jul 15, 2020 at 2:08
  • I believe the x-axis is the number of samples. If you send your plot values on a particular time cadence, the x-axis should then correspond to time.
    – woolsey
    Jul 15, 2020 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.