PlatformIO based project for NodeMCU ESP8266 with a PIR and DHT sensor, communicates via Homie
DHT/PIR sensor on NodeMCU using Homie and PlatformIO
Currently uses Homie 3.0.1
Project is built in PlatformIO, see below.
TEMPERATURE_INTERVAL
)pause
)DHT22 to GPIO4 (D2 on NodeMCU). If using DHT11, see DHT11 v DHT22 section below.
PIR to GPIO12 (D6 on NodeMCU).
PlatformIO is an open source ecosystem for IoT development with cross platform build system, library manager and full support for Espressif ESP8266 development. It works on the popular host OS: Mac OS X, Windows, Linux 32/64, Linux ARM (like Raspberry Pi, BeagleBone, CubieBoard).
This project is currently configured to use a DHT22 sensor. If you are using DHT11, you need to modify main.cpp:
DHT22:#define DHTTYPE DHT22
DHT11:#define DHTTYPE DHT11
If you think my code looks good to go, you can download firmware.bin in “Builds” directory and upload that to your NodeMCU using something like espTool or NodeMCU Flasher. Google these.
Currently OTA is not enabled.
My code is trash :) I’m a rookie!
Some of this code has been borrowed from others and added to this conglomerate. Will credit them when I get chance.
If using with openHAB v2.5 or above, once MQTT is configured, this device will automatically show up in Inbox to add.