Implementing the Smart Trashcan project

Once everything has been configured, Go to Simuli Virtual Lab and start the Smart Trashcan instance we just created. Click on the Open button Under the instance name. A new tab with the built-in development environment opens up. On the left side, we have the code editor window along with the terminal at the bottom. On the right side, we have our Trashcan with a display that shows the current distance between the cover of the trashcan and the garbage.

The code for the project has been made available via GitHub. To get the code, we just need to clone the repository into our instance. Type the following command in the terminal:

git clone

All the required project files will now be cloned to a local folder with the same name. Let's change the working directory of the terminal to that folder.

cd vlab-examples/SmartTrashCan/

Open the file in the IDE by clicking on it in the File Explorer pane. Here we need to configure a few things before we can start the program. Change the following in the code with the relevant information.

broker_address = "" 
pubTopic = "<ADAFRUIT ID>/feeds/<FEED NAME>"

You can find the adafruitID and the adafruitKey under theMy Key option in Adafruit IO.

Now go to the terminal and type the following commands to install pip, which is the python package manager.

apt-get update
sudo apt-get install python-pip

Once that is done we will use pip to install the paho-mqtt package, which is needed for our program to communicate with Adafruit IO using MQTT. Type the following command to install the package.

pip install paho-mqtt

Now we are ready to run our program. Type the following command in the terminal.


The real-time distance readings will now be taken and sent to Adafruit IO. The MQTT Dashboard app is subscribed to the Adafruit IO feed and will get the real-time values and display it on the app.

Last updated