IBM Bluemix powered Smart Trashcan

Towards the goal of building a smarter planet, we present to you a prototype of an IoT-enabled trash can. This use case is one of the many ones, around IoT, which empowers the things to talk to us, instead of us checking on them.

This project requires a functional account with IoTIFY. If you don’t have an account yet, please sign up in the link given below.


A trash can is one of those ubiquitous things, which hardly gets any attention until it is full and the trash seems to spill out of it. So the most obvious way to make it smart would be to detect if it is getting full and then send a notification to the personnel responsible for clearing it.

In this guide, we present to you the IOTIFY’s Trashcan Simulator, which can be used to build a smart trash can monitoring system such that the user gets notified about the trash can’s garbage level in real-time via a mobile app.

Underlying Concept

The best way to detect the level of filled trash in a trash can is by using an ultrasonic sensor attached to the lid as shown below.

The best way to detect the level of filled trash in a trash can is by using an ultrasonic sensor attached to the lid as shown below.

Empty Trash Can
Filled Trash Can

The ultrasonic sensor mounted on the lid will face downwards and send trigger waves towards the bottom of the trash can. In case the can is filled up to a certain level, the waves will bounce back as echo which will be captured back by the sensor. Sensing the time difference between the sending of the trigger signal and reception of the echo signal provides a reasonable measure of the level of the trash can.

Project Components

To build this project, we need the following components.

  • IBM Bluemix IoT Service: IBM offers it’s in-house IoT messaging service based on MQTT protocol. It is available as part of the IBM Bluemix catalog. You will need to signup for the IBM Bluemix trial account to use it.

  • IOTIFY Smart TrashCan Simulator: This is the complete hardware emulation of a trash can, available under IOTIFY. You will need to signup for IOTIFY subscription to access this.

  • Android Mobile (Optional): In order to monitor this virtual trash can via mobile, we will need an Android mobile phone.

The reference architecture of the entire system is shown below.

Software Components

As for the software, we have the following components in this project

  • TrashCan Python Script: This is a Python application that runs on the IOTIFY Smart TrashCan Simulator. It monitors the level of a trash can every few seconds and publishes the readings to IBM IoT service. We will write this python script which will act as the application program running on this setup for demonstrating the working of the smart trash can.

  • Cordova Android Mobile App: This is a Cordova-based Android mobile app which is used to monitor the trash can remotely. We will build this app and showcase how to use it in conjunction with IOTIFY Smart Trashcan simulator.

Note: This application also uses the Twilio messaging service for sending SMS notifications to the user’s mobile in case the trash can reaches a critical level. Refer Twilio documentation for setting up a Twilio trial subscription.

The complete source code for this application is available in GitHub in this repository. Refer to the README file for steps to configure and build the software components of this application.

So let’s dive in and build this application.