Traveling in Blanquillo AND MORE
  • Home
  • Trips
    • 2022 >
      • 2022 Tennessee
      • 2022 Blue Ridge Parkway
    • 2021
    • 2020 >
      • 2020 Sierras
    • 2019 >
      • 2019 Crater Lake
      • 2019 Westside Regional Park
    • 2018 >
      • 2018 So.California
      • 2018 Colorado-Arizona
      • 2018 Banff-Jasper
      • 2018 Osoyoos, BC
    • 2017 >
      • 2017 Olympic
      • 2017 Channel Islands
      • 2017 Eclipse
    • 2016 >
      • 2016 Glacier-Yellowstone
      • 2016 Southwest
    • 2015 >
      • 2015 Bryce-Zion
      • 2015 Lava Beds
      • 2015 Bristlecone-Yosemite
      • 2015 July first trip
    • 2014 >
      • 2014 Utah
    • 2011 >
      • Gold Beach
  • Camping Map
  • Our Escape
  • Radio and Hobbies
    • Amateur Radio Commentary >
      • AREDN
      • Antenna on mast
      • Winlink
    • Christmas LED Display
    • Scripts for Growing Classes >
      • 12- WeatherFIles
      • 11- sketch_MorseCodeDecoder.ino
      • 2e-RGB-LED
      • 2f-RGB-LED-GUI
      • 2g-RGB-LED-GUI
      • 3a-thermometer.py
      • 3b-thermometer-plus
      • 4a_DHT_simpletest.py
      • 4b_DHT_send_temperature.py
      • 4c_DHT_send_temperature_LED.py
      • 4c_DHT_send_temp.service
      • 4d_DHT_send_temp_LED_OLED.py
    • Winlink for Field Day 2020
    • VE Credentials
    • Antenna Analyzer Code
  • Collegedale Tax Prep
  • Links
  • Contact
  • Home
  • Trips
    • 2022 >
      • 2022 Tennessee
      • 2022 Blue Ridge Parkway
    • 2021
    • 2020 >
      • 2020 Sierras
    • 2019 >
      • 2019 Crater Lake
      • 2019 Westside Regional Park
    • 2018 >
      • 2018 So.California
      • 2018 Colorado-Arizona
      • 2018 Banff-Jasper
      • 2018 Osoyoos, BC
    • 2017 >
      • 2017 Olympic
      • 2017 Channel Islands
      • 2017 Eclipse
    • 2016 >
      • 2016 Glacier-Yellowstone
      • 2016 Southwest
    • 2015 >
      • 2015 Bryce-Zion
      • 2015 Lava Beds
      • 2015 Bristlecone-Yosemite
      • 2015 July first trip
    • 2014 >
      • 2014 Utah
    • 2011 >
      • Gold Beach
  • Camping Map
  • Our Escape
  • Radio and Hobbies
    • Amateur Radio Commentary >
      • AREDN
      • Antenna on mast
      • Winlink
    • Christmas LED Display
    • Scripts for Growing Classes >
      • 12- WeatherFIles
      • 11- sketch_MorseCodeDecoder.ino
      • 2e-RGB-LED
      • 2f-RGB-LED-GUI
      • 2g-RGB-LED-GUI
      • 3a-thermometer.py
      • 3b-thermometer-plus
      • 4a_DHT_simpletest.py
      • 4b_DHT_send_temperature.py
      • 4c_DHT_send_temperature_LED.py
      • 4c_DHT_send_temp.service
      • 4d_DHT_send_temp_LED_OLED.py
    • Winlink for Field Day 2020
    • VE Credentials
    • Antenna Analyzer Code
  • Collegedale Tax Prep
  • Links
  • Contact
​#4c_send_temperature_LED.py
# get temperature from DHT22 and send to an Adafruit IO feed
​# blink LED when data sent to Adafruit
# Import standard python modules
import time
import Adafruit_DHT
from gpiozero import LED

# import Adafruit IO REST client
from Adafruit_IO import Client
# Initialize the DHT device, with data pin connected to:
sensor = Adafruit_DHT.DHT22
pin = 18
green=LED(23)

# Delay between sensor reads, in seconds
DELAY_SECONDS = 300

# Set to your Adafruit IO key.
# Remember, your key is a secret,
# so make sure not to publish it when you publish this code!
ADAFRUIT_IO_KEY = 'ADAFRUIT_IO_KEY'

# Set to your Adafruit IO username.
# (go to https://accounts.adafruit.com to find your username)
ADAFRUIT_IO_USERNAME = 'ADAFRUIT_IO_USERNAME'

# Create an instance of the REST client
aio = Client(ADAFRUIT_IO_USERNAME, ADAFRUIT_IO_KEY)

# Set up `temperature and humidity` feed
pi_temperature = aio.feeds('temperature')
pi_humidity = aio.feeds('humidity')

while True:
    try:
        # Print the values to the serial port
        #temperature_c = dhtDevice.temperature
        humidity, temperature_c = Adafruit_DHT.read_retry(sensor, pin)
        temperature_f = temperature_c * (9 / 5) + 32
        #humidity = dhtDevice.humidity
        #print(
        #    "Temp: {:.1f} F / {:.1f} C    Humidity: {:.1f}% ".format(
        #        temperature_f, temperature_c, humidity
        #    )
        #)
        aio.send(pi_temperature.key, temperature_f)
        aio.send(pi_humidity.key, humidity)
        for x in range(1,3):
            green.on()
            time.sleep(1)
            green.off()
            time.sleep(1)

    except RuntimeError as error:
        # Errors happen fairly often, DHT's are hard to read, just keep going
        print(error.args[0])

    # Delay for DELAY_SECONDS seconds to avoid timeout from adafruit io
    time.sleep(DELAY_SECONDS)
Copyright © 2023 by Dornbush Web Design