I have a raspi 2 with a grovePi+ and have been trying to figure out setups for a remote weather station - I am light years away from that at this point as I cannot get a repeatable result with a temp and humidity sensor(blue) and the LCD RGB Backlight - I admit i have not documented which example i have tried(I have attempted to use all with weather or temp/humidity mentioned)I did get readouts a couple of times, the results being presented every second or so - the display worked and the temp and humidity changed over time, then tried again and got temp readings that read 858 C and wild humidity readings. I have a sauna so I know the sensors were off a bit…The times that the sensors worked and seemed accurate were when I used the example setup from the Dexter Ind. projects page - i followed the setup regarding wiring and port usage so its a mystery why I cant do this repeatedly…Ive followed SD card set up and expanded the filesystem and updated raspian, dexter software and firmware.
Ive used the Scratch examples to blink leds(worked only 1/2 the time), checked out the version for the LCD and that worked great, so Im certain that the sensors do work.
I am new to Raspberry Pi and programmimg, coding, etc. FYI
I’ll post a troubleshooting txt file and see if anyone can point me in the right direction!
Cheers
Hey Peter, it sounds from your post like you’ve been able to get positive results from all of the sensors. So it seems like the software, firmware, and hardware are all working.
But if you’re getting inconsistent results on some sensors, can you share the code you’re running that’s getting these results, and any more information about the specific setup you’re using that’s not working or giving you troubles?
Are you using the temp/humidity sensor (or the entire setup) in a particularly humid environment? A sauna might have destroyed your hardware if it’s very humid and the hardware isn’t isolated from the wet environment.
Also, your i2cdetect:
Checking I2C bus 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: 03 – -- – -- – -- – -- – -- – --
10: – -- – -- – -- – -- – -- – -- – -- – --
20: – -- – -- – -- – -- – -- – -- – -- – --
30: – -- – -- – -- – -- – -- – -- – -- 3e –
40: – -- – -- – -- – -- – -- – -- – -- – --
50: – -- – -- – -- – -- – -- – -- – -- – --
60: – -- 62 – -- – -- – -- – -- – -- – -- –
70: 70 – -- – -- – -- –
Looks like a lot of devices are showing up here and the I2C busi s working fine.
Hi and thanks for your reply and sorry for the delay in returning…no, i wasnt using it in the sauna!(wow what a hot one that would have been!)…I think the problem was that I was corrupting the micro sd card or rather that it was being corrupted and I would have to re-install the OS, sometimes forgetting to chmod the install scrip, also I was using a DHT22 and couldnt figure out how to save the change…i tried using github to install the GrovePi package and Ive had no trouble since then.
Now if i can ony figure out how to get the sensor to sample every 10 minutes or longer…
Hi @aplsaws,
Following is the code that will record the values of the temperature and humidity to a file called “Temperature.txt” for every 10 minutes. Let us know how it works for you and this also displays the value on the RGB LCD.
from grovepi import *
from grove_rgb_lcd import *
import time
start=time.time()
start=start//60
dht_sensor_port = 7 # Connect the DHt sensor to port 7
dht_sensor_type = 0 # change this depending on your sensor type - see header comment
while True:
try:
[ temp,hum ] = dht(dht_sensor_port,dht_sensor_type) #Get the temperature and Humidity from the DHT sensor
print("temp =", temp, "C\thumidity =", hum,"%")
t = str(temp)
h = str(hum)
# To check for 10 mins
if ((time.time()//60)-start) == 10:
#To write to a file
f=open("/home/pi/Desktop/Temperature.txt","a+")
f.write("temp =%fC\thumidity =%f\n"%(temp,hum))
f.close
start=time.time()
start=start//60
setRGB(0,128,64)
setRGB(0,255,0)
setText("Temp:" + t + "C " + "Humidity :" + h + "%")
except (IOError,TypeError) as e:
print("Error")
-Shoban
Shoban, thanks so much for your input and code - yes! this works fine… but only after I figured out how to disable the screensaver and blankout(it works just fine without disabling that stuff too, but data is cut after screensaver and blankout cut in.
My intention is to include a timestamp on each of the readings so it can be associated properly for historical purposes - is there a library with samples to build from in the grovepi+ libraries?
Also, the readings write so fast to the LCD that Im having trouble seeing them - is there a way of slowing down the intervals between readings?
Hi @aplsaws,
To include the time stamp you can use the datetime
library, there are various formats available with it and you can refer to the guide here . To include it in the reading you will have to add the variable (say ts) that holds time stamp to the f.write() function like:
f.write(" %s \t temp =%fC\thumidity =%f\n"%(st,temp,hum))
Regarding the readings being written fast to the LCD, you can add a delay after the line setText("Temp:" + t + "C " + "Humidity :" + h + "%")
like time.sleep(1)
.
Please let us know if this helps,
-Shoban
ok, I tried this and other variations of this(you can see ive changed the port i run the sensor from and added a delay between readings) and i continue to get syntax errors…have a look!
from grovepi import *
from grove_rgb_lcd import *
import time
import datetime
start=time.time()
start=start//60
ts = time.time()
ts = datetime.datetime.fromtimestamp(ts).strftime(’%Y-%m-%d %H:%M:%S’.)
dht_sensor_port = 4 # Connect the DHt sensor to port 4
dht_sensor_type = 1 # change this depending on your sensor type - see header comment
while True:
try:
[ temp,hum ] = dht(dht_sensor_port,dht_sensor_type) #Get the temperature and Humidity from the DHT sensor
print(“temp =”, temp, “C\thumidity =”, hum,"%")
t = str(temp)
h = str(hum)
# To check for 10 mins
if ((time.time()//60)-start) == 10:
#To write to a file
f=open(“Temperature.txt”,“a+”)
f.write(“temp =%fC\thumidity =%f\n”%(ts,temp,hum))
f.close
start=time.time()
start=start//60
setRGB(0,128,64)
setRGB(0,255,0)
setText("Temp:" + t + "C " + "Humidity :" + h + "%")
time.sleep(1)
except (IOError,TypeError) as e:
print("Error")
why it formats on here like above I dont know…
Hi @aplsaws
Can you send us a text file of your code and also can you send us a screenshot of the error that you get.
-Shoban
These are screenshots of both - the error mssg isnt cutting any of the code off.
Hi @aplsaws,
Thanks for sharing the code. It looks like you are missing () parenthesis near f.close. It should look like f.close(). There can be lot more errors, can you run this program from command line, it will show you which lines have the errors.
-Shoban