Prerequisites for Smart Trashcan
Simuli Virtual Lab
First, we need to create a new instance on the Simuli Virtual Lab platform of the Smart Trashcan project.
Log in to your Simuli account and navigate to the Simuli Virtual Lab. Here we will create a new emulated instance of the Smart Trashcan
. Click on the Launch
button under the Smart Trashcan to get started.
This will open the configuration menu. First, provide a name for the project. Then, we will select the board which will be a Raspberry Pi
. Then we will select the OS which will be Buster
. Next, we will select the HCSR04
Ultrasonic Distance Sensor. Finally, we will review that the all the details are correct and click on the Launch
button.
Once we have clicked on the Launch button, a new instance of the Smart Trashcan will be created. It can take a few minutes for this process to be completed.
While our new instance is being created, let's move forward to creating an Adafruit IO account and configure it.
Adafruit IO
Go to the Adafruit IO website, if you already have an account, you can directly log in and skip to the configuration part. If this is your first time at Adafruit IO, click on the Get Started for Free
button at the top. This will take you to a signup page, fill all the details and click on the CREATE ACCOUNT
button.
Once the account has been created, go back to the Adafruit IO website. Let's start by creating our feeds. Feeds act as our MQTT topics, where we can either publish our data or subscribe to receive the data. In this case, we will create a feed for publishing the distance between the cover of the trashcan and the garbage.
Click on Feeds
, and then click on view all
. This will open up a list of all the feeds currently set up for our account. Let's create our feeds for luminosity and bulb status.
Click on the New Feed
button, this opens up a pop-up, let's name the feed trashcan
. Finally, click on Create to create
this new feed.
Once we have our feeds set up, let's configure the MQTT Dashboard app.
MQTT Dashboard
You can download the MQTT Dashboard app from the Play Store. iOS users can download the Easy MQTT app from the App Store. These apps work as MQTT Clients and can both publish data and subscribe to topics and get data.
We will be using these apps as a way to interface with our Smart Trashcan and get the distance value right on our phone.
Let's start configuring the MQTT Dashboard app.
For iOS users using the Easy MQTT app, the interface might differ slightly, but the overall procedure is the same.
Once you have downloaded the MQTT Dashboard app, open it. The app will prompt us to connect it to an MQTT broker. Tap on the Add first broker
button.
A new page will open with the configuration for the MQTT broker. Switch on Broker protection as Adafruit requires authentication to connect and then fill the rest of the fields as given below:
You can find your Adafruit username and key by clicking the My Key
button in Adafruit IO.
Once all the fields have been filled properly tap the save
button at the bottom. You should now see an empty page, now you can add tiles that will act as a way to interact with our Arduino.
Tap on the +
button at the bottom of the page, this will prompt you to choose a type of tile, select Standard
. A new prompt will show the different types of tiles you can choose from. First, select Progress
. Now we can configure this tile.
Start by giving it the name Smart Trashcan
, then set the publish and subscribe topics to username/
feeds/trashcan
, where username is your Adafruit IO username. Finally, set the map between values to 0 & 210
. You can also set a colour and an icon to make the tile look good.
You have now successfully configured the MQTT Dashboard app. Now all that's left is to upload the sketch to the Arduino and we are done.
Last updated