This is an example sketch for the esp8266 with a PIR motion sensor that sends an MQTT message when motion occurs to the configured MQTT broker.
It also uses the tzapu WiFiManager package to allow the user to setup wifi.
It is a fork of my basic esp8266 MQTT example sketch.
For this project I'm using a NodeMCU esp8266 board. The HiLetgo board. There's a good pinout diagram for the ESP8266 here
I'm using the HC-SR501
Variable | Use |
---|---|
ssid | WiFi SSID |
password | WiFi Password |
MQTT_SERVER | MQTT server IP address or name |
MQTT_PORT | MQTT server port |
MQTT_TOPICBASE | String pre-pended to the topic of all MQTT messages |
delayMS | default main loop delay in milleseconds |
ipInterval | default number of intervals between sending IP address, zero to never send |
The following parameters can be configured via MQTT.
Topic | Use |
---|---|
esp8266/config/delay | main loop delay in milleseconds |
esp8266/config/ipinterval | number of intervals between sending IP address, zero to never send |