Giter Site home page Giter Site logo

iot-esp32-motion-detector's Introduction

Simple IoT ESP32 MQTT Motion Sensor

This project uses an ESP32 microcontroller to detect motion using one or more sensors and publish the results to an MQTT broker. The code is written in C++ using the Arduino framework and PlatformIO.

An example of use with a Node-RED workspace:

A screenshot of a Node-RED workspace example

Dependencies

This project depends on the following libraries:

  • WiFi.h
  • PubSubClient.h
  • Wire.h

Configuration

The config.h file contains the following configuration options:

  • WIFI_SSID: the SSID of the WiFi network to connect to
  • WIFI_PASSWORD: the password for the WiFi network
  • MQTT_SERVER: the hostname or IP address of the MQTT broker
  • MQTT_PORT: the port number for the MQTT broker
  • MQTT_USER: the username for the MQTT broker (optional)
  • MQTT_PASSWORD: the password for the MQTT broker (optional)

Usage

  1. Upload the code to your ESP32 microcontroller using the PlatformIO IDE or the pio run --target upload command in your project directory.
  2. Connect one or more motion sensors to the ESP32 using the sensorPins array in the code.
  3. When motion is detected, the ESP32 will publish a message to the esp32/motion topic on the MQTT broker with a payload of 1. When motion detection ends, the ESP32 will publish a message to the same topic with a payload of 0.
  4. ESP32 will be suscribed to the esp32/output topic to turn on/off the built-in led.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Let me know if you need any further assistance!

iot-esp32-motion-detector's People

Contributors

gerardofelipe avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.