A simple IoT simulation using MQTT where smart trash bins periodically send their fill levels to a central station. The central station monitors these levels and issues commands to empty bins when needed, optimizing the route based on a cost matrix.
We highly recommend creating and activating a virtual environment:
python3 -m venv venv
source venv/bin/activate # On macOS/LinuxThen install all the necessary dependencies:
pip install -r requirements.txtMake sure Mosquitto is installed and running. On macOS, you can install and run it using:
brew install mosquitto
brew services start mosquitto # Optional: runs Mosquitto in the backgroundor temporary foreground run (without brew services
mosquitto -vBefore running the code, you can configure global settings in the conf.yaml file.
There are two ways to deploy this project: an automatic mode (available only on macOS), or manual mode.
The script launcher.py will open five new terminal windows:
- One for the central station
- Four for each smart bin
To launch everything automatically, simply run:
python launcher.py
For manual deployment, open five terminal windows.
- In the first window, run the central station:
python central_station.py- In the remaining four terminals, run the smart bins by specifying their unique IDs:
python smart_bin.py --id {id_number}Replace {id_number} with a number between 0 and 4 (inclusive). Each bin must have a unique ID.