How To Make Your Smart Bin Smarter With IBM Bluemix – RadioStudio
Menu

How To Make Your Smart Bin Smarter With IBM Bluemix

By Shyam Purkayastha | Cloud Computing

Sep 10

Have you ever wondered how does an IoT-enabled smart bin works? If not then this blog post will show you exactly how to build one for yourself and you can use it too.

These days, there is a huge impetus on smart city initiatives across the world. One of the popular use cases of Smart City is the concept of Smart Bins. As we all know, efficient waste management is a growing challenge in urban areas. Hence, this Smart Bin concept has also drawn a lot of attention as part of automating the public infrastructure across cities.

What is a Smart Bin?

A smart bin is a regular trash can, equipped with a sensor. Thus, such sensored trash cans can measure the level of trash contained in them and report that to the users.

Smart bins for Efficient Waste Management

How is this concept of smart bins useful for us? If you think of waste management and the level of coordination required for efficiently managing a public waste management system, then a smart bin can lead to.

  • Efficient monitoring by waste collection agencies.
  • That leads to no more sights of overfilled trash cans across the city streets
  • That leads us to the gradual elimination of health and environmental issues related to open disposal of trash.

And finally, it will lead to a cost reduction/per bin for the waste collection agency.

 

Sensored Trash Can System built on IBM Bluemix

In this post, we are going to show you a model setup of a trash can system installed with garbage sensor, that is built atop the IBM Bluemix services. IBM Blumix cloud provides the middleware tools that can power IoT devices and applications. In this setup, we are going to use the IBM IoT Foundation services to collect data from the garbage sensor.

Looking For a Real Smart Trash Can/Waste Bin?

The setup presented in this blog post is a prototype system. If you are looking for a real product or technology around smart trash can or a smart waste bin then refer to our product R&D site on smart cities.

Block Diagram of Sensored Trash Can System

smart bin with garbage sensor

 

Components of Sensored Trash Can System

As per the above block diagram, the main components of this system are

  1. Sensored trash can: Fitted with a hardware device that controls the garbage sensor.
  2. Bluemix IoT Service: This is the IBM’s cloud service (IBM IoT Foundation) which orchestrates the messaging and communication between the trash can and the user’s mobile app.
  3. Mobile app: This is a mobile app through which the user can monitor the trash level inside the trash can. This app may be used by the waste collection agency personnel or anyone who is responsible for clearing the trash.
  4. Twilio: Twilio is a service that allows a device to send an SMS to any phone around the world. We have used this service to enable the trash can to send an SMS in case it is filled up almost till the top.

 

Trash Can Hardware Setup

The hardware device that needs to be fitted inside the trash can consists of the following

  1. Raspberry Pi 3
  2. Ultrasonic Sensor (HCSR04)

Raspberry Pi 3 is the popular single board computer, which has many GPIO pins to connect sensors and peripheral devices. It has in-built WiFi to connect to the Internet.

To sense the trash level within the trash can, we have used a garbage sensor. It is actually an ultrasonic sensor, also known as fill level sensor that detects the distance of the trash from the top of the trash can. You can get more info about this sensor (HC-SR04) here

The below schematic diagram shows how to connect the raspberry pi and the ultrasonic sensor.

Hardware Schematic Diagram

trash can schematic

Setting up IBM Bluemix & Twilio Service

To demonstrate the actual usage of smart bins, we will be taking help of the following web services from IBM Bluemix and Twilio. Follow the links below to create your account and setup these services.

  1. IBM IoT Foundation
    Follow this link to signup for the IBM Bluemix to get started.
    You can find the step by step procedure to setup the IBMIoTF service under your Bluemix account here
  2. Twilio
    You can sign up here for Twilio.
    Follow this link to get started with Twilio.

Project Setup

The software source code for this model trash can is available on GitHub.

There are two components of the software

  • Trashcan.py : The client application for Raspberry Pi 3, written in Python. It is responsible for monitoring the trash level by controlling the fill level sensor.  It is also responsible for sending the trash level data to mobile app display and as well as the SMS notification.
  • TrashCanApp : This is the mobile app. It is built on Cordova and displays a simple fill level illustration for the trash can which syncs in real time with the trash level reported by Raspberry Pi 3.

Refer the README file for step by step instruction on setting up the IBM IOT Foundation  (IBMIoTF) service to handle data forwarding between the trash can and mobile app. IBMIoTF uses the industry-standard MQTT protocol to connect devices and applications. MQTT is designed for the efficient exchange of data to-and-from devices in real-time.

To ensure that the client application at Raspberry Pi 3 and the TrashCanApp mobile app can sync up with the IBMIoTF service, we have to make some changes in the code before launching/building the programs. Refer the “Python Script Configuration” and “Mobile App Configuration” sections of the README file.

 

Project Demonstration

If you have followed along until this stage, then we are ready to demonstrate this trash can.

Although we can test the level of trash can using any obstacle placed at a distance from the fill level sensor, we want to get close to real. So here is a small model trash can be made out of an ordinary container.

 trash can with fill level sensor

You can see the fill level sensor mounted at the center. Here is a look from the inside with its two probes sticking out.

fill level sensor

All services running and all things powered up. Let’s see a demo.

As you can see in the video demonstration, we are using crumpled paper as trash. As we keep filling the container with the trash, the level goes up, and it is indicated in the mobile app as well.

At the bottom part of the video, you can see the sensor values getting updated in the IBMIoTF service web console. As we keep filling trash, the value decreases, which indicates the reducing distance between sensor-probe and the trash level. That’s the fill level sensor in action!

Check out the source code of Python client application to see how the Raspberry Pi3 controls hardware to interface with the fill level sensor for reading the distance.

You now have a fully functional smart bin solution. We hope you enjoyed this demonstration. In the coming weeks, we will present few more variants of this demo which addresses some real-world problems and solution that can be specifically applicable to this use case or IoT in general. Stay tuned and feel free to comment in case you have any queries.

Follow

About the Author

Shyam is the Creator-in-Chief at RadioStudio. He is a technology buff and is passionate about bringing forth emerging technologies to showcase their true potential to the world. Shyam guides the team at RadioStudio, a bunch of technoholiks, to imagine, conceptualize and build ideas around emerging trends in information and communication technologies.

  • Sandeep says:

    heyy!!!!
    Really nice blog and good explanation
    But i get errors while running Trashcan.py script

    Error is as follows
    ***************************************************************************
    Traceback (most recent call last):
    File “Trashcan.py”, line 195, in
    init()
    File “Trashcan.py”, line 190, in init
    except ibmiotf.connectionException as e:
    AttributeError: ‘module’ object has no attribute ‘connectionException’
    **************************************************************************
    Before this there was error related connection problem with ibm bluemix……….

    hence i changed code as respective as follows
    **********************************************************************
    gatewayoptions = {“org”: organization, “type”:gatewaydeviceType, “id”:gatewaydeviceId,”auth-method”: authMethod, “auth-key”: authKey, “auth-token”: authToken}
    gatewayclient = ibmiotf.gateway.Client(gatewayoptions)
    gatewayclient.connect()
    console.log(“Connected”);
    ***********************************************************************

    Plzzzz help for this error

    • Hi Sandeep

      Sorry to hear about this error. We will do a cross check and get back to you within a day.

      Glad that you liked the post. Thanks

      • Sandeep says:

        Yes …
        plzz tell me after cross check
        Thank you for your response

        • Hi Sandeep

          It appears to me that you are trying to execute the python script as is from the repo. You need to create your own Watson IOT service and use your credentials. Please do not use the existing credentials that you see in the code as they are dummy.

          Refer this readme file for the entire configuration details.
          https://github.com/rajeevbrahma/Trashcan/blob/master/README.md

          Pay special attention to the “Python Script Configuration” and “Mobile App Configuration” section.

          Thanks
          Shyam

          • Sandeep says:

            Heyy!!

            Hi
            There was previous error in your code
            is only “.connectionException” replace with “.ConnectionException” It means only C is capital

            So i got distance on console which is got very inaccurate and twillo work fine and in Mobileapp also show through GUI but its inaccurate.. but its fine i will chack code
            But main problem is ,, i dont get data in IBM WATSON platform as you show in video
            Even not get any device info in IBM plateform
            I follow right steps while creating Device..
            Distance and mesure and its time in IBM platform how to show ….. plzzz

            Extra feature
            And i want to use for it two beans then how do i do
            Two UV sensor

            Thank You.

          • I would love to see you build the hardware for two bins and share it with us. Give it a try.

          • sandeep says:

            Hi
            Ya i will sure share with u
            but solve my one problem
            Which i asked u in previous question
            i dont get data in IBM WATSON platform as you show in video

            Example:******************************

            Event Data point Value TimeReceived

            ***************************************

  • Sandeep says:

    Its ok done ……

  • Gagandeep says:

    hello.. interesting post…
    Glad to read this article..

  • Monojit Dey says:

    Very good articles,Really helpful,Thank you for sharing this information,keep up the good work

  • Good Post
    Very HelpFull Articale
    Thanks For Shareing

  • >