Displaying the weather
For our first project, we will be using the humidity and temperature sensor of the gross array and use its measurements to be displayed on an OLED display. You will need the two modules and some connection cables to set up the hardware for this project.
Connect the only display module to any of the three i2c ports on the GrovePi, and connect the humidity and temperature sensor to port D7. Now we will have a look at the following code and then learn what each statement does:
from grovepi import * from grove_oled import * dht_sensor_port = 7 oled_init() oled_clearDisplay() oled_setNormalDisplay() oled_setVerticalMode() time.sleep(.1) while True: try: [ temp,hum ] = dht(dht_sensor_port,1) print "temp =", temp, "C\thumidity =", hum,"%" t = str(temp) h = str(hum) oled_setTextXY(0,1) oled_putString("WEATHER") oled_setTextXY(2,0) oled_putString("Temp:") oled_putString(t+'C') oled_setTextXY...