SHT20 read Humidity issue
![userHead](https://dfimg.dfrobot.com/dfPortrait2.png)
hi,
i hope its ok to post because im not using arduino, i am using python 3. I have the following problem, erverytime i want to read the Sensor it gives me the same Humidity, if i put it in water or outside, the humidity stays the same (90 to be exact. The Temperature Sensor seems to work fine. That is the code im using (like i said its python 3):
import RPi.GPIO as GPIO
import smbus
import time
address_i2c3 = 0x40
humidity_ausgeben_command = 0xF5
temperatur_ausgeben_command = 0xF3
reset_command = 0xFE
rev = GPIO.RPI_REVISION
if rev == 2 or rev == 3:
bus = smbus.SMBus(1)
else:
bus = smbus.SMBus(0)
def get_humidity():
return -6 + (125.0 * float(readSensor(humidity_ausgeben_command))) / 2**16
def get_Temperature():
return -46.85 + ((175.72 * float(readSensor(temperatur_ausgeben_command))) / 2**16) - 4
def readSensor(command):
bus.write_quick(address_i2c3)
bus.write_byte(address_i2c3, command)
time.sleep(0.1)
result = [bus.read_byte(address_i2c3) << 8]
result_2 = result[0] + bus.read_byte(address_i2c3)
result = result_2
return result
def reset(command):
bus.write_quick(address_i2c3)
bus.write_byte(address_i2c3, command)
time.sleep(0.1)
def sht20_abfragen():
reset(reset_command)
Temperature_SHT20 = get_Temperature()
Temperature_SHT20_2 = round(Temperature_SHT20)
print("T=", Temperature_SHT20_2)
Humidity_SHT20 = int(get_humidity())
print("H= ", Humidity_SHT20)
return [Temperature_SHT20_2, Humidity_SHT20]
sht20_abfragen_erg = sht20_abfragen()
print(sht20_abfragen_erg)
Maybe someone can help and knows why the Humidity always stays the same. thaks in advance and i hope its ok, because im using python in the topic.
i hope its ok to post because im not using arduino, i am using python 3. I have the following problem, erverytime i want to read the Sensor it gives me the same Humidity, if i put it in water or outside, the humidity stays the same (90 to be exact. The Temperature Sensor seems to work fine. That is the code im using (like i said its python 3):
import RPi.GPIO as GPIO
import smbus
import time
address_i2c3 = 0x40
humidity_ausgeben_command = 0xF5
temperatur_ausgeben_command = 0xF3
reset_command = 0xFE
rev = GPIO.RPI_REVISION
if rev == 2 or rev == 3:
bus = smbus.SMBus(1)
else:
bus = smbus.SMBus(0)
def get_humidity():
return -6 + (125.0 * float(readSensor(humidity_ausgeben_command))) / 2**16
def get_Temperature():
return -46.85 + ((175.72 * float(readSensor(temperatur_ausgeben_command))) / 2**16) - 4
def readSensor(command):
bus.write_quick(address_i2c3)
bus.write_byte(address_i2c3, command)
time.sleep(0.1)
result = [bus.read_byte(address_i2c3) << 8]
result_2 = result[0] + bus.read_byte(address_i2c3)
result = result_2
return result
def reset(command):
bus.write_quick(address_i2c3)
bus.write_byte(address_i2c3, command)
time.sleep(0.1)
def sht20_abfragen():
reset(reset_command)
Temperature_SHT20 = get_Temperature()
Temperature_SHT20_2 = round(Temperature_SHT20)
print("T=", Temperature_SHT20_2)
Humidity_SHT20 = int(get_humidity())
print("H= ", Humidity_SHT20)
return [Temperature_SHT20_2, Humidity_SHT20]
sht20_abfragen_erg = sht20_abfragen()
print(sht20_abfragen_erg)
Maybe someone can help and knows why the Humidity always stays the same. thaks in advance and i hope its ok, because im using python in the topic.