from grovepi import *
from grove_rgb_lcd import *
from time import sleep
from math import isnan
dht_sensor_port = 7 # connect the DHt sensor to port 7
dht_sensor_type = 0 # use 0 for the blue-colored sensor and 1 for the white-colored sensor
setRGB(0,255,0)
while True:
try:
# get the temperature and Humidity from the DHT sensor
[ temp,hum ] = dht(dht_sensor_port,dht_sensor_type)
print(“temp =”, temp, “C\thumidity =”, hum,“%”)
# check if we have nans
# if so, then raise a type error exception
if isnan(temp) is True or isnan(hum) is True:
raise TypeError('nan error')
t = str(temp)
h = str(hum)
# instead of inserting a bunch of whitespace, we can just insert a \n
# we're ensuring that if we get some strange strings on one line, the 2nd one won't be affected
setText_norefresh("Temp:" + t + "C\n" + "Humidity :" + h + "%")
except (IOError, TypeError) as e:
print(str(e))
# and since we got a type error
# then reset the LCD's text
setText("")
except KeyboardInterrupt as e:
print(str(e))
# since we're exiting the program
# it's better to leave the LCD with a blank text
setText("")
break
# wait some time before re-updating the LCD
sleep(0.05)
So, what display did you want to send a color command to? The LCD?
Did you try changing the temperature (by putting it somewhere else), or the humidity, (by breathing on it), to see if the readings changed in a reasonable way?
Did you try changing the temperature (by putting it somewhere else), or the humidity, (by breathing on it), to see if the readings changed in a reasonable way?
**Correct , I tested with lighter and values were changed **
The RGB commands might be for a specific display or a display using a different interface.
If you want to set colors, you will need to look up the specific display commands for your specific display hardware, the ports used, and modify the display class accordingly.
The reason for this is that these libraries were written years ago, (likely for hardware that no longer exists!), and you will need to update it to use new hardware.
Idea,
If you can fork the GitHub repo for that software, modify the driver class for the new hardware to make it work, (and rename it!), you can send @cleoqc a pull request to the main repo. She often includes contributions like this.
We’ve all tossed things her way. She can’t think of everything, new hardware is manufactured all the time and she is willing to consider/include relevant and useful contributions.