Blog 3 - Node-RED/BinBot - Igor Kapusniak

 

Blog 3 - Node-RED/BinBot

Node-RED

Resources : Node-RED 

What is Node-RED:

Node-RED is a flow-based development tool for block programming, it was originally developed by IBM for wiring together hardware devices, APIs and online services as part of the Internet of things. Node-RED provides a web browser based flow editor, which can be used to create JavaScript functions. 

Why Node-Red:

In a previous sprint the team was searching for ways to interact with the MQTT broker, one method that was found was Node-RED. It provides a intuitive interface where a user drags and connects various types of nodes together to create a pipeline. It was found that Node-RED provides specific nodes for MQTT communication, Along with many other features that could be linked together such as; sending emails, web hooks, http requests, JSON parsing, and a library with 3rd party extensions with almost 6000 modules. All this paired with the ease of use and ease of cooperation made this a perfect tool.

Setup

There are multiple methods of setting up node-Red however, the easiest and most reliable is through a tool called Docker. Docker is a tool that allows software and all its dependencies to be packaged into a container that runs in an isolated environment that make it easier to build and run software consistently across different systems. 

After running this command found on the node-Red website:

 

Node-RED was set up and accessible on a website that is hosted locally, it could then be accessed by entering localhost:1880 or 127.0.0.1:1880 into any browser.

 

With Node-RED setup I followed a lab which one of my classmates who first looked into Node-RED made.

The Lab included 3 parts: Connecting to a MQTT broker and publishing and receiving a message, downloading and setting up a email sender, and creating a pipeline where a incoming MQTT message would trigger an action.  

 

Connecting to the MQTT Broker:

To setup a connection to the MQTT Broker all that was needed was to enter the server url and login credentials. 
   

 

Receiving and Publishing messages was also straightforward as all that needed to be specified was the topic and how to parse the data.

 

Email Setup:

Sending emails required a little more effort to get working as I found that school provided emails do not work, additionally a special password needs to be generated (at least for gmail) which allows 3rd party applications to sends emails. Besides that the setup was seamless.

 

Using the Inject node and linking it to the email node enabled for emails to be sent with just the click of a button 

 

The configuration of the Inject node was simple as payload represents the Subject of an email and topic represents the actual message

  

Once the Do node was clicked I received an email. 







Connecting Multiple Nodes

Using multiple nodes linked together I created this pipeline with upon receiving a MQTT message will analyse it and based on the ID (Input1, 2, or 3. Using the switcher node) will do a run a different function. In this scenario input1 will trigger the first branch, and the mqtt message will be written to the debug node, in addition after a 600 seconds delay a function is run that feeds the MQTT message into the email node and an email is sent with the MQTT data. 

 

     

Node-RED Conclusion 

After using the tool for a period of time and exploring some of its many features I believe it will be very useful as it significantly reduces development time compared to regular code, and its much easier to work together as a team of the same Node-RED flow, making this an ideal tool for team collaboration.

 

Bin Bot

What is a BinBot

A normal smart bin in short is a bin with some technology like sensors and the ability to connect to the the internet. This connection enables a user to receive updates on that status of the bin such as how full it. 

However the BinBot that will be referred to here, is a bin developed by SETU students over the last couple of years, the bin uses multiple motors which enable it to rotate, it also has a face with moving eyebrows which give the binbot a level of humanification? (check this work). The motors and eyebrows are developed in such a manner that allow the robot make movements that show various emotions such as sadness, anger, curiosity, etc.

Our Task

Our task for this sprint was to come up with MQTT/smart features to the binbot that allows users to view some sort of data that the binbot collects. 

After some thought I came up with an idea to use an ultrasonic sensor to measure how full the bin is at any given time, and then publish the data on the MQTT broker. Another suggestion of mine was to encrypt the MQTT data that we are sending as by default MQTT is not very secure and can be read my anyone. Encryption would allow only authorised parties to view the data that we were sending.

Other ideas from my teammates were: 

  • Object detection and identification, were a camera would be used to detect trash that a user puts in and identify it as good or bad depending on whether its a recycling or general waste bin. This could be paired with face recognition to in a way that users could receive points for sorting trash correctly and lose points for not sorting. In addition a leader board could be created that shows how much points an individual has gathered. 

  • Using a gyroscope the tilt angle of the bin could be measured, using this angle we could tell whether the bin got knocked over and if so an email could be sent to a user that the bin has fallen over. This could be paired with sending general updates on the status of the bin as well such as when its full or some statistics about what trash has been thrown in.

  • Rotating the bin towards a sound using 4 microphones. 

 

Team Discussion

After everyone contributed ideas, we discussed the feasibility of each idea.

Encryption Discussion:

There was not too much to discuss for this feature however we decided to first focus on encrypting the MQTT messages first using TLS and then add encryption on the microbits which use unencrypted radio communication to talk to the master microbit.   

Fullness Sensor Discussion:

This feature also did not require too much discussion, however we looked into whether its possible to connect an ultrasonic sensor to a microbit and found that it was possible. The idea was to mount an ultrasonic sensor connected to a microbit to the top of the inside of the binbot, and based on the distance the sensor is reading we could infer how full the bin is and publish that data to a MQTT topic. For example if when the bin is empty we read 100 cm but after some trash has been thrown in we read 50cm we know that the bin is around 50% full.

We also came up with an idea to connect a microbit to a lcd display. This would allow us to display how full the bin is on the outside of the bin without looking inside. We once again verified that this is possible with a microbit and found that it was.

Rotating the BinBot Towards Sound Discussion:

Initially we where excited for this idea as a team however, we came to a realisation that this would not be feasible as the noise from the motors that move the brows make a lot of noise and would alter the direction the robot turned towards. Because of this we decided to drop the idea.

Tilt and Email Discussion:

This idea was developed upon and we decided that users would be able to provide their email and receive daily report not only on whether the bin has fallen over but how full it is, as well as other data that is collected.

To do this we would use Node-RED and the IOT MQTT Panel App. The user would publish their email to a MQTT topic using the app and node red would parse the list of emails and send a report to each user. 

Object detection and identification Discussion:

This was our biggest idea as it would incorporate a vision system, machine learning and classification. However we realised that this would cause a lot of GDPR issues as the data collected would contain faces. So we decided to shift the scope of the project in a slightly different direction. Instead of collecting trash in general we could collect bottles. This would drastically change our approach for this feature as now we could leverage the bar codes found on bottles for the return deposit scheme. This would allow us to use a bar code scanner for identification. 

We also shifted the use case for the BinBot, we decided that it could be used in classrooms where classes could compete with each other. Instead of identifying individual people using their face we would now use class IDs and scores would be group based rather than individual. 

Classes would be able to compete with each other and have a live leader board based on how much money they have in their bin. Additionally web hooks would be used to send a report to the classes google classroom.

UN Sustainable Development GOALS

An important part of this project is to incorporate some of the 17 UN sustainable development goals into the binbot. After some discussion with the team we came to an understanding that our project falls under Industry Innovation and Infrastructure, Responsible consumption, Sustainable cities and communities, Quality education, Climate action, and Life on Land.

The project promotes and teaches kids the importance of recycling through gamification.

 

BinBot Implementation Discussion

Tools and Tech:

The project will primary centre around Microbits, MQTT, and Node-RED, However other tech will also be used.

List of Tech and Tools:

  • MQTT
  • Node-RED
  • Microbits
  • TLS (Encryption)
  • Ultrasonic Sensor
  • LCD Display
  • Bar Code Scanner
  • Google Classroom and Email

 Scope and Timeline:

We decided to split up the remaining 6 weeks into 3 sprints of 2 weeks. The first 2 sprints will be dedicated to development and the final week to debugging and finishing off any remaining tasks.

For myself I plan on getting the ultrasonic sensor publishing accurate measurements to MQTT in first sprint and I plan on getting the LCD display implemented in sprint 2. The final sprint would involve any final fixes and helping out others.

Block Diagram

 

 

 

 

Comments

Popular posts from this blog

Blog 1 - Igor Kapusniak