Posts: 38
Joined: Wed Mar 16, 2016 10:03 am

Plotting Grove Pi sensor data using matplotlib

Sat May 05, 2018 12:23 pm

I have a Grove Pi sitting on top of my Pi and 2 sensors hooked up.
One that measures the temperature and humidity and one that measures dust.

I would like to plot the data, but cant seem to get my head around how to use matplotlib.

This is my code, which prints data and shows on a small LCD:

Code: Select all

import time
import grovepi
import atexit
from grove_rgb_lcd import *


sensor = 7

while True:

                #Gather data from sensor
                [new_val,lowpulseoccupancy] = grovepi.dustSensorRead()
                [temp,hum] = grovepi.dht(sensor,0)

                if new_val:
                        #Print data 
                        print ("temp =", temp, "C & Humidity =", hum,"% & Dust consentrantion =",lowpulseoccupancy)

                        #Prepare data for use on LCD
                        t = str(temp)
                        h = str(hum)
                        d = str(lowpulseoccupancy)

                        #Set LCD color
                        #Print on LCD
                        setText("T:" + t + "C" + " H:" + h + "%" + " Dust:" + d + "ppm")

                #Wait 5 seconds
        except (IOError,TypeError) as e:
Can you help with the code needed to plot a graph for just one of the inputs?

Return to “Advanced users”