This repository contains the Arduino firmware for the Smart Waste Monitoring project, part of a larger system developed for the course Cloud and Fog Computing in the Internet of Things.
This firmware is designed to run on microcontrollers like ESP32, responsible for collecting sensor data and securely transmitting it to AWS IoT Core.
Note: This repository is part of a larger project, which also includes separate repositories for Deep Learning model training and AWS Lambda functions.
- Read real-time sensor data:
- Weight sensor (HX711)
- Gas sensors (MQ-135 for NH3, MQ-4 for CH4)
- Distance sensor (HC-SR04) to calculate bin fill percentage
- Real Time Clock (RTC) for timestamp generation
- MQTT Communication with AWS IoT Core (TLS secure connection)
- Simulation Mode for testing without physical sensors
- Deep Sleep Mode (available in the
mainbranch, production-ready)
main.cpp- Main application logicsecrets.example.h- Example of the credentials and certificates file (should be renamed tosecrets.h)
-
Clone this repository
-
Rename
secrets.example.htosecrets.h -
Edit
secrets.hand fill in your:- WiFi SSID and password
- AWS IoT Core endpoint
- AWS Root CA, device certificate, and private key
-
Install PlatformIO (VSCode extension or CLI)
-
Select your board (e.g., ESP32 Dev Module) in
platformio.ini -
Build and upload the firmware to your device:
pio run --target upload
-
Monitor serial output:
pio device monitor
In main.cpp, the data source can be selected by changing the MODE constant:
#define MODE 2 // 1 = Real sensor data, 2 = Simulated dataMODE 1: Use actual sensorsMODE 2: Use random simulated data (useful for development without hardware)
| Sensor/Component | Purpose |
|---|---|
| HX711 | Weight measurement |
| MQ-135 | NH3 gas detection |
| MQ-4 | CH4 gas detection |
| HC-SR04 | Distance measurement (bin fill) |
| DS3231 | Real-Time Clock (RTC) |
This project is intended for educational purposes.
Developed for the course Cloud and Fog Computing in IoT.