Following my earlier post on Introducing the Microchip RN2483, I am writing this application blog post to showcase how LoRaWAN can be used for enabling waste management by means of a smart garbage bin. LoRaWAN provides long range wireless communication with ultra-low power consumption that enables very long battery life.
We built a proof of concept for garbage bin level tracking device, based on Raspberry Pi + Arduino Uno, and then optimized it further with a custom circuit to make a production grade bin level sensor(BLS) for smart city use cases. In this post, we will show you how you can quickly hack together a proof-of-concept of a functional smart garbage bin on Raspberry Pi using LoRaWAN. For more details about the custom BLS, please get in touch with us.
Managing Trash as Part of Smart City
Deploying smart trash cans for real time waste management system is one of the key applications of a smart city system. Municipal authorities need an efficient way to clear the trash from all public places before it becomes a mess. And this needs to be achieved with the minimum overhead of cost and impact to the city dwellers. LoRaWAN is one of the earlier LPWAN technologies that envisages a city-wide network for keeping track of public infrastructure assets. Once fitted with a BLS device on a trash can, LoRaWAN allows the city authorities to keep a tab on the bins via wireless connectivity.
Solution for Waste Collection using Remote Monitoring
Let's build a model end-to-end PoC for smart waste collection using LoRaWAN. [thrive_text_block color="teal" headline="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 page on smart cities. [/thrive_text_block] This solution is ideally suited for waste pickup and management companies, who can optimize their logistics resources while reducing collection costs. The PoC scope of this solution is to remotely monitor a garbage bin. The bin is fitted with a BLS device coupled with Microchip RN2483 LoRa Module, for tracking the garbage level. And the level is indicated to the user via a mobile app.Smart Garbage Bin Hardware Setup
There are three functional parts of this solution:- Node – This is the BLS device fitted in the garbage bin . It has an ultrasonic sensor to sense the garbage level inside the bin and a LoRa module (Microchip RN2483) as the communication interface. The node hardware is based on Arduino Uno.
- Gateway – This is used as an external gateway, which aggregates the data from the nodes and pushes it to cloud. The gateway connects to the nodes using LoRaWAN. The gateway is built upon Raspberry Pi and it is also interfaced with RN2483 for receiving the data from nodes over LoRa physical layer.
- UI App - This is a simple app that shows the current level of the bin. This app is the same one that we used earlier for the IBM Bluemix Smart Trash Can demo. Instead of IBM Bluemix, this time the app is powered by PubNub to establish a real-time link between the gateway and the app.
Gateway Setup
In this gateway setup, we have used the RN2483 Module with inbuilt CP2102 USB to TTL Converter, to interface with Raspberry Pi.Node Setup
In the BLS node setup, we have used the RN2483 Module with an ultrasonic sensor (HC-SR04) for level detection.Node Hardware Connections
Here is the hardware schematic for BLS node.Smart Garbage Bin Software Setup
Steps to Setup Node Software
[thrive_text_block color="teal" headline="Before You Begin"] Before proceeding, we need to install Arduino IDE on a laptop/computer. Installing the Arduino IDE - Download and Install Latest Version of Arduino IDE - Start Arduino IDE and plug the Arduino development Board to the computer. You need to be familiar with Arduino IDE. For more details, refer the Getting Started guide. [/thrive_text_block]Step 1: Clone the GitHub repository under your home directory, using the following link
git clone https://github.com/suryasundarraj/lora-based-garbageBin-tracker.git
Step 2: Open the file "/node/loraNode/loraNode.ino" from this repo in Arduino IDE.
Step 3: From Arduino IDE menu, select the Board from Tools - > Board - > Arduino UNO
Step 4: Select the USB Port from Tools menu ( Tools - > Port - > COMXX )
Step 5: Upload the Code to Arduino Uno board. Now the Arduino Uno will start transmitting the bin level through LoRaWAN.
Gateway Software Setup
Follow the procedures below to run the python program on Raspberry Pi gateway. Step 1: Log on to the Raspberry Pi console and clone this GitHub repository under the home directory.Step 2: Under the “lora-based-garbageBin-tracker” directory navigate to “gateway” subdirectory.
cd gateway
Step 3: Run the script (Check for permissions, sudo)
python loraRadioGateway.pyYou can see the logs to check that the LoRa module gets initialized and starts receiving data from the node.
mac pause radio rx 0On the Transmitter Side (Node), the commands are:
mac pause radio tx FFThis LoRa setup is tested under an ideal indoor condition. To try it outdoors and for non line of sight cases, you need to test it by setting LoRa MAC radio parameters (ADR, SF, Channel Frequency) and sending commands manually to RN2483. You can find all the commands embedded in the code. Refer the official Microchip datasheet for more details. Since LoRa works in the open ISM band, make sure to adhere to your country specific regulations for testing it outdoors. It is not recommended to use this PoC setup for extended testing. [/thrive_text_block]
Checking Bin Level on Mobile App
The mobile app is a standard Cordova-based Android app. It shows the current level of the garbage bin.Functional Demonstration of Smart Garbage Bin
Once the node and gateway setup is up and running, you can see the debug messages on the serial monitor (Arduino) and ssh terminal (Raspberry Pi), indicating the continuous Lora transmission.Here is the model garbage bin setup fitted with the node device.
As we keep filling the container with trash, the level goes up, and it is indicated in the mobile app.
[clickToTweet tweet="Now I know how to build smart garbage bin with #LoRaWAN using @MicrochipTech RN2483 for #smartcity" quote="Now I Know How To Build A Smart Garbage Bin with LoRaWAN using Microchip RN2483"]