In this project, I utilized ESP32 and the HC-SR04 sensor to develop a streamlined system for remote data monitoring. By employing ESP-IDF over MQTT, the sensor readings are efficiently sent to a HiveMQ broker. This seamless integration allows for easy access and analysis of real-time data from remote locations, making it ideal for applications like environmental monitoring, industrial automation, and smart agriculture.
Hardware
- ESP32 development kit
- Micro USB cable
- HC-SR04 ultrasonic sensor module
- Connecting wires
Software
sensor_to_mqtt/
└── components/
└── mqtt_start/
└── wifi_start/
└── main/
├── CMakeLists.txt
├── sensor_to_mqtt.c
└── CMakeLists.txt
└── sdkconfig
- Open sensor_to_mqtt in cmd
- Run export.bat to set up ESP-IDF environment
- Add details to files such as Wi-Fi SSID, password, mqtt broker username, password, uri etc.
- Make sure to connect esp32 to your PC and sensor to pins as provided in code.
- Run
idf.py build flash monitor