Blog 6 - Binbot - Igor Kapusniak
Blog 6 - Binbot
Introduction
The BinBot is a smart recycling bin designed to encourage primary school students to sort their plastic bottles correctly through gamification. At its core, it is an interactive bin equipped with sensors and internet connectivity that allows classes to compete against each other. The bin measures how full it is using an ultrasonic sensor and tracks bottle returns through barcode scanning, awarding points to classes based on the value of recyclable bottles they deposit. This creates a fun, competitive environment where students can see their class's performance on a live leaderboard.
What makes the BinBot unique is how it brings various technologies together. Sensors on the bin send and receive data wirelessly through publishing and subscribing to MQTT topics. Node-RED receives this data and processes it, verifies scanned barcodes against the return scheme API, and updates a dashboard with graphs and class rankings. This communication is encrypted using an XOR cipher to ensure that only authorised devices can read the transmitted data, protecting the integrity of the data.
The project promotes sustainable development and teaches kids the importance of recycling by making it rewarding. By combining hardware sensors, wireless communication, and cloud based processing, the BinBot turns waste management into an engaging classroom activity that aligns with UN Sustainable Development Goals around responsible consumption, climate action, and quality education.
Binbot System Diagram
The diagram shows how all the different parts of the BinBot system work together. On the left side is the actual bin itself, which has two microbits communicating with each other through encrypted radio signals. The slave microbit collects data from the ultrasonic sensor to measure how full the bin is and displays both the fullness percentage and class ranking on its screen, while the cloud board microbit handles all the communication with the MQTT Broker. Both microbits encrypt their messages before sending them so only they can understand what's being transmitted.
Once the data reaches the cloud board, it gets published to Node-RED which is the brain of the whole system. A barcode scanner on a phone sends bottle barcode scans through the IOT MQTT mobile app to Node-RED via MQTT, which checks if they are valid bottles using an API and then collects data about that bottle such as its capacity and type. The cloud board also subscribes to information from Node-RED about class rankings and sends that back to the Binbot to be displayed. When the bin gets too full and exceeds 90%, Node-RED sends an email notification and a message to Google Classroom to let the class know. All the barcode and fullness data gets recorded and feeds into a dashboard that displays live class rankings and statistics showing each class's progress and overall performance.
Team Design
My Contribution
Beyond the hardware, I also worked on the Node-RED side to act as a bridge between different parts of the system. I implemented the leaderboard array generation that created an array of classes based on their bottle total, and set up MQTT listeners that monitored for incoming barcode submissions from the bin. A key part of this work was formatting the barcode data in a way that Davin's API calls could use, and then taking the API responses and reformatting them so Matteo's data analytics and dashboard could process the information properly.
Development Overview
The cloud board microbit acts as the master device and is responsible for all internet communication. It's divided into three main sections:
On MQTT Received: When the leaderboard topic receives an update from Node-RED, this section gets triggered. It parses the incoming leaderboard data which comes as a comma separated list of classes, then iterates through to find where this class ranks. Once the rank is calculated, it gets encrypted using the XOR cipher and sent via radio to the slave microbit so it can be displayed.
The slave microbit handles all sensor data collection and display. It consists of three main sections:
On Start: This initialises the encryption key, sets the radio group to match the cloud board, and sets up the HuskyLens display which shows both the fullness percentage and class ranking.
On Radio Received: When the encrypted ranking data arrives from the cloud board, this section decrypts it and stores it so it can be displayed on the HuskyLens screen.
Forever Loop: The ultrasonic sensor reads the distance to the bin's contents, which is then converted to a fullness percentage using the bin depth of 85cm. The percentage is encrypted and sent via radio to the cloud board. At the same time, the HuskyLens display is updated to show both the fullness percentage and the class ranking received from the cloud board, giving students feedback on their bin's status.
The leaderboard generation system takes all the bottle data collected and converts it into a ranked list of classes. This ranking is then published to MQTT so the microbits can display it on the bin's display in real-time.
Get Leaderboards Array: This function retrieves all the accumulated data about each class's bottle deposits from Node-RED's internal storage. It takes the stored school information and converts it into an array, then sorts the classes by their total deposit value in descending order so the highest scoring class appears first. The function then extracts just the class names and formats them as a comma-separated string, making it easy to pass along to the next step.
MQTT Publisher: Once the leaderboard array is generated, this node publishes the sorted class names to the binbot/leadboard topic on the MQTT broker. The cloud board microbit is subscribed to this topic and receives the updated rankings and sends it to the slave microbit for display. This creates a leaderboard that updates whenever a new bottle is scanned and processed.
The barcode processing pipeline in Node-RED handles incoming bottle scans from each class and prepares them for validation. It starts with four separate MQTT listeners one for each class that subscribe to their respective barcode topics. Initially, I tried to get dynamic topic subscriptions working so we wouldn't need four separate listeners, but that approach didn't work, so we went with individual listeners for each class.
Only Classes: This function filters the incoming messages to ensure they're actual barcode data coming from the correct topics. It uses a regex pattern to check that the message is coming from a valid binbot/classX/barcode topic, then extracts the class ID from the topic so we know which class submitted the barcode.
Class Data: Once we've confirmed it's a valid barcode message, this function structures the data into a format that can be used by the rest of the system. It takes the barcode number and wraps it up with information about which class it came from, creating a JSON object. This format makes it easy for the next step to process.
Teamwork Reflection
Conclusion
The BinBot project was a really enjoyable experience to work on. We managed to overcome obstacles with the hardware setup, successfully implemented encrypted communication between devices, and built a complete Node-RED backend that validates bottles and updates rankings.
Once everything was connected, the data was sent from the bin sensors and IOT App through to the dashboard making it easy for classes to track their progress and see live leaderboard updates. The whole system came together to create something that's both functional and useful for teaching kids about recycling.
Comments
Post a Comment