Last active
August 20, 2022 20:32
-
-
Save elizabethn119/25be959d124f4b4c86f7160cf916f4d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import adafruit_dht | |
from ISStreamer.Streamer import Streamer | |
import time | |
import board | |
# --------- User Settings --------- | |
SENSOR_LOCATION_NAME = "Office" | |
BUCKET_NAME = ":partly_sunny: Room Temperatures" | |
BUCKET_KEY = "dht22sensor" | |
ACCESS_KEY = "ENTER ACCESS KEY HERE" | |
MINUTES_BETWEEN_READS = 10 | |
METRIC_UNITS = False | |
# --------------------------------- | |
dhtSensor = adafruit_dht.DHT22(board.D4) | |
streamer = Streamer(bucket_name=BUCKET_NAME, bucket_key=BUCKET_KEY, access_key=ACCESS_KEY) | |
while True: | |
try: | |
humidity = dhtSensor.humidity | |
temp_c = dhtSensor.temperature | |
except RuntimeError: | |
print("RuntimeError, trying again...") | |
continue | |
if METRIC_UNITS: | |
streamer.log(SENSOR_LOCATION_NAME + " Temperature(C)", temp_c) | |
else: | |
temp_f = format(temp_c * 9.0 / 5.0 + 32.0, ".2f") | |
streamer.log(SENSOR_LOCATION_NAME + " Temperature(F)", temp_f) | |
humidity = format(humidity,".2f") | |
streamer.log(SENSOR_LOCATION_NAME + " Humidity(%)", humidity) | |
streamer.flush() | |
time.sleep(60*MINUTES_BETWEEN_READS) |
Hi,
Great project but I am slightly stuck. My first issue is pip3 install pureio, for some reason I am getting a 404 error, so I am not sure if this is causing my issue, I don't think that it is but I could be wrong. My second issue is this I am using BME280 but not adafruit one, I have followed both options but still cannot get it to work. I am sure that this is caused by my sensor not being adafruit but this one or the crawlspace one still give me an error.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Elizabeth,
Not sure if this has been resolved, but I have been having the same issue. I replaced 29 with
temp_f = "{:.2f}".format(temp_c * 9.0 / 5.0 +32.0)
. I noticed that when I ran the python code, after I made the changes to line 29, it would come back initially with the error that others pointed out. I ran it a few more times and then refreshed my dashboard on initial state and then ran the code again and it started to work. I would have to repeat this every time I stopped it and wanted to start it back up again. Not sure why it is doing it but as long as I can SSH into the pi and willing to run the code a few times it seems to work fine now.