Got GrovePi working nice today with Your help, relays are switching and some other sensors are read fine, but I can’t seem to get temperature sensor working.
Raw value of sensor seems to be always 1023 and when trying to read temperature with t=grovepi.temp(1) i get math domain error:
analog pin 1 raw value: 1023
Traceback (most recent call last):
File “test.py”, line 36, in <module>
t=grovepi.temp(a1)
File “/home/pi/work/GrovePi/Software/Python/grovepi.py”, line 52, in temp
t=(float)(1/(math.log(resistance/10000)/3975+1/298.15)-273.15)
ValueError: math domain error
Well, that’s of course what you get when trying to calculate (1023-1023)*10000/1023, so the question is; Why the raw value is always 1023?
I use DHT11 based Grove Temperature and Humidty Sensor, which is in the supported sensor list, but obviously i’m missing something here. Maybe it’s because this is my first python project and I haven’t used grove sensors or even arduino before either…
Am I trying to use even right function?
Hi,
The Temperature and Humidity sensor uses another library called DHT.h with Arduino. The code that you have been trying is for the analog temperature sensor which gives an analog reading. We are working on the getting the functions included in the firmware and software and would send a software update this week which will solve the problem and add other features too.
I actually came into same conclusion later yesterday when I googled that sensor of mine some more, read some of dht.h and realized that the sensor is digital, not analog
I got mixed up with this because same sensor was in the supported list, so I imagined somehow that the libraries, functions etc are already there.
I also try to read the dht sensor. I have updated the firmware, in grovepi.py is dht defined. I am not familiar with arduino and a beginner in python programming. My (simple) program is like this:
import smbus
import time
import grovepi
bus = smbus.SMBus(0)
address = 0x04
pin=4
module_type=0
print dht(pin,module_type)
The error I get is this:
print dht(pin,module_type)
NameError: name 'dht' is not defined
I thought the dht is defined in grovepi.py ??
What did I mis?
Thank you for the help guys! No errors in the code anymore.
but… nothing sensible comes from the sensor:
[nan, 0.0]
My code:
import smbus
import time
import grovepi
bus = smbus.SMBus(0)
address = 0x04
pin=4
module_type=2
print grovepi.dht(pin,module_type)
I have a temperature humidity sensor pro. I have searched for tutorials to get it worked but no satisfying results yet.
My final goal is to get temperature readings on a website, I managed getting a website running on the raspberry pi. I am stuck with:
Hi Arne,
Sorry for all the troubles. Just wanted to check that if you have update the firmware on the GrovePi too. Changes were made to the firmware so do update the firmware too to get the DHT working.
# GrovePi + Grove Temperature & Humidity Sensor Pro
# http://www.seeedstudio.com/wiki/Grove_-_Temperature_and_Humidity_Sensor_Pro
import grovepi
# Connect the Grove Temperature & Humidity Sensor Pro to digital port D4
# SIG,NC,VCC,GND
sensor = 4
while True:
try:
[temp,humidity] = grovepi.dht(sensor,1)
print "temp =", temp, " humidity =", humidity
except IOError:
print "Error"