This project uses NodeMcu (ESP8266) to detect movement with 3 motion sensors (Hailege AM312 ). The state of the motion sensor is sent via MQTT. The project is ready for Homeassistant auto discovery.
- PowerSupply of the Motions Sensors:
3.3V - First Motion Sensor (Out Pin) is connceted to
D0/GPIO16 - Second Motion Sensor (Out Pin) is connceted to
D1/GPIO5 - Third Motion Sensor (Out Pin) is connceted to
D2/GPIO4
- VS Code is used as IDE
- PlatformIO extension for building/uploading code
- 2 building enviorments:
[env:nodemcuv2]: using COM port to flash software[env:nodemcuv2_ota]: using ArduinoOTA to flash over the air via WiFi
- ArduinoOTA to flashing OTA
- Home Assistant auto discovery
- discovery topic:
homeassistant/binary_sensor/motion_sensor_floor_01/config{ "name": "Motion Sensor Floor", "unique_id": "motion_sensor_floor_01", "device_class": "motion", "state_topic": "homeassistant/binary_sensor/motion_sensor_floor_01/state", "expire_after": "60" }
- discovery topic:
- send motion state via MQTT
- state topic:
homeassistant/binary_sensor/motion_sensor_floor_01/state(states:OFForON)
- state topic:
-
install VS Code and PlatformIO extension
-
enter secrets
- rename
secrets_dummy.htosecrets.h - enter your connection secrets
// Wifi settings #define WIFI_SSID ""; #define WIFI_PASSWORD "" // MQTT setting #define MQTT_SERVER "" #define MQTT_USER "" #define MQTT_PASSWORD ""
- rename
-
select
[env:nodemcuv2]enviroment -
buildandupload