I am using the AM2302 Temp/Humidity Sensor. I start with
sudo apt-get update && sudo apt-get -y install git python-dev
git clone https://github.com/adafruit/Adafruit_Python_DHT.git
cd Adafruit_Python_DHT/
sudo python setup.py install
and I connected the sensor:
- "-" to GND (pin 6)
- "+" to 3V3 (pin 1)
- "S" (signal) to GPIO4 (pin 7)
I run the following code :
import os
import time
import sys
import Adafruit_DHT as dht
import json
while True:
h,t = dht.read_retry(dht.DHT22, 4)
msg = json.JSONEncoder().encode({'tem' : round(t,3),'hum' : round(h,3)})
print msg
time.sleep(5)
I got
Traceback (most recent call last):
File "tem_hum.py", line 9, in <module>
msg = json.JSONEncoder().encode({'tem' : round(t,3),'hum' : round(h,3)})
TypeError: a float is required
which means there is no data it just returns none.
I already tried these in the below links:
https://github.com/adafruit/Adafruit_Python_DHT/issues/63 https://github.com/adafruit/Adafruit_Python_DHT/issues/73 https://github.com/adafruit/Adafruit_Python_DHT/issues/44
Any suggestion to make it read both Temp/Humidity.
Thanks in Advance.

Failed to get reading. Try again!– I_Al-thamary Jan 05 '19 at 20:44MUST NOTbe enabled with the default GPIO 4 if you are using the AM2302 on GPIO 4. – joan Jan 06 '19 at 00:04sudo rpi-update 52241088c1da59a359110d39c1875cda56496764sudo rebootand right now the raspberry pi doesn't connect at all. – I_Al-thamary Jan 06 '19 at 05:04"-" to GND (pin 6)"+" to 3V3 (pin 1)"S" (signal) to GPIO4 (pin 7)– I_Al-thamary Jan 06 '19 at 06:53