Skip to content

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.

License

FelixBetz/Esp8266MotionSensor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Esp8266MotionSensor

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.

BOM (bill of materials)

Wiring

  • 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 wiring image

Developing Environment

  • 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

Features

  • 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"
      }
  • send motion state via MQTT
    • state topic: homeassistant/binary_sensor/motion_sensor_floor_01/state (states: OFF or ON)

Getting Started

  1. install VS Code and PlatformIO extension

  2. enter secrets

    • rename secrets_dummy.h to secrets.h
    • enter your connection secrets
     // Wifi settings
     #define WIFI_SSID "";
     #define WIFI_PASSWORD ""
    
     // MQTT setting
     #define MQTT_SERVER ""
     #define MQTT_USER ""
     #define MQTT_PASSWORD ""
  3. select [env:nodemcuv2] enviroment

  4. build and upload

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published