Last active
August 20, 2022 20:32
-
-
Save elizabethn119/25be959d124f4b4c86f7160cf916f4d4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.