/environment

Monitor temperature and humidity (DHT22) using MicroPython on an ESP8266 and send the results to ThingSpeak.

Primary LanguagePythonMIT LicenseMIT

Environment Monitor

Monitors temperature and humidity using MicroPython on an ESP8266 and a RHT03 (DHT22) sensor and sends the results to ThingSpeak.

Circuit

The following circuit diagram shows how I connected the sensor to a NodeMcu ESP8266 development board:

Circuit diagram

Usage

Configure a ThingSpeak channel something like:

ThingSpeak channel

Download the urequests HTTP library and create a file called secrets.py:

"""Secret values required to connect to services."""
WIFI_SSID = 'XXXXXX'
WIFI_PASSPHRASE = 'XXXXXX'
THINGSPEAK_API_KEY = 'XXXXXX'
WUNDERGROUND_API_KEY = 'XXXXXX'

and copy with the rest of the python files to the ESP8266.

Run the following script from the REPL to load the wifi network.

# Connect to WiFi router
import network
import secrets

wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(secrets.WIFI_SSID, secrets.WIFI_PASSPHRASE)
wlan.ifconfig()

Reboot the ESP8266 to automatically run the program.