fix float error
This commit is contained in:
parent
710eaa90e6
commit
6fdcd6c766
@ -48,10 +48,10 @@ while True:
|
|||||||
|
|
||||||
# Get Temperature from DHT
|
# Get Temperature from DHT
|
||||||
_, temperature = Adafruit_DHT.read_retry(DHT_SENSOR, DHT_PIN)
|
_, temperature = Adafruit_DHT.read_retry(DHT_SENSOR, DHT_PIN)
|
||||||
temperature = round(temperature, 2)
|
temperature = round(float(temperature), 2)
|
||||||
# Get Humidity from DHT
|
# Get Humidity from DHT
|
||||||
humidity, _ = Adafruit_DHT.read_retry(DHT_SENSOR, DHT_PIN)
|
humidity, _ = Adafruit_DHT.read_retry(DHT_SENSOR, DHT_PIN)
|
||||||
humidity = round(humidity, 2)
|
humidity = round(float(humidity), 2)
|
||||||
|
|
||||||
# Publish our data
|
# Publish our data
|
||||||
client.publish(temperature_topic, temperature)
|
client.publish(temperature_topic, temperature)
|
||||||
@ -60,6 +60,6 @@ while True:
|
|||||||
|
|
||||||
time.sleep(30)
|
time.sleep(30)
|
||||||
|
|
||||||
# Output data to screen
|
Output data to screen
|
||||||
# print temperature
|
print temperature
|
||||||
# print humidity
|
print humidity
|
Loading…
Reference in New Issue
Block a user