🚮

Monitoring Dump

The project helps to look after landfills, where all of our garbage generally goes.
notion image

Things used in this project

notion image
 

Story

Problem

The waste from our houses and from various factories are dumped in the form of those massive landfills. Most of that waste is not recycled and much may be organic. This organic compounds on decomposing and then combining with inorganic waste from factories make harmful gases like all the volatile organic compounds (VOC), along with Methane, CO2, Ammonia, Sulfides, disulfides, mercaptans etc. Plastics also burn to release Benzene and toluene which are VOCs. All of this gases are harmful to nature and humans. Most of this gases have the concentration increased very rapidly and are harmful to the people. These gases (like CH4) catch on fire causing more pollution. According to a report by sciencedaily.com, the H2S Gas from landfills causes lung cancer and other gases cause other diseases like Bronchitis also. This makes it unhealthy to live near landfills with a layer of polluted air over the vast area. And moreover, it is very difficult to monitor the vast areas. The current sensors are very bulky and need to be replaced with small and independent interconnected devices.
notion image
1 / 3 • Most Landfills have lot of sand particles and more Origanic waste

Concept/Solution/Goal

The simple solution is to monitor this vast landfills and then report the data to authorities. Based on various concentration levels that particular area can be cleaned. Also, if the levels are too high then the citizens can be warned. To monitor this vast areas the solution is to create many interconnected nodes that communicate to a central server where all the data is saved and managed. Also if there is fire, the temperature and CO2 contents rise rapidly so we can have a fire fighting team to extinguish it and not let more of waste to burn and cause pollution.
So, We have Rapid IOT Prototyping Kit that has many sensors and a Raspberry Pi that can communicate with Rapid IOT via BLE and get the data. This data can be stored and help the authorities to see the periodic changes and also warn the people. But, it is must to keep the gateways secured as if the data is changed then it can be a big problem.
notion image
1 / 2 • Article on Landfills, Its effects , etc.

Materials & Software Required

  • NXP Rapid IOT prototyping Kit
  • RPi 3B/3B+/3A+ >> as they have BLE in them
  • Python > best language
  • Rapid IOT studio >for coding Rapid IOT
  • InfluxDB >Database
  • Mosquitto >Handle MQTT requests
  • Node-Red >Manage flow of data
  • Grafa >Display all the data
More information on top
notion image
1 / 5 • Rapid IOT and RPi 3B+

About Rapid IOT and its Use

NXP's Rapid IOT Kit is a All-In-One which can help makers to easily and quickly make their project and have a ready prototype. Also with the use of its industry grade sensors, it is also very easy to convert it into ready - perfect product.
Features
  • Kinetis® K64 MCU based on Arm® Cortex®-M4 Core
  • KW41Z Wireless MCU (BLE, Thread, Zigbee)
  • NT3H2211 NFC Forum Type 2 Tag
  • A1006 Secure Authentication & anti-counterfeit IC
  • Multiple sensors (Gyroscope, Acc/Mag., Barometer/Temp., Air Quality, Ambient light and capacitive touch)
  • Rapid IoT Studio IDE
  • Automatic source code & project generation for MCUXpresso IDE/SDK
  • iOS/Android mobile apps and IoT Cloud connect platforms
  • Expandable to most IoT end-node use cases with 400+ Click boards™
  • Compatible with NXP IoT Modular Gateway
We will use the following sensors for our project:
  • Temperature and Humidity Sensor >for general data and also detection of fires
  • Air Pressure Sensor >with help of pressure concentrations at various locations, the direction of fire with the wind can be determined.
  • CO2 and VOC sensor >main gases for being notorious and directly proportional to size and pollution in landfill
  • Light Sensor >for detecting day and night and light distribution and light intensity as it directly depends on the severity of fire
All the sensors i.e., ENS210;MPL3115;CCS811;TLS2572 are present in the Rapid IOT for their respective functions.

Coding the Rapid IOT

To code the Rapid IOT is extraordinarily simple. It has an online GUI drag and drop IDE with which you can fully create the project and even use it to make your project. It consists of connected nodes like things which have specific meaning and the AtMo language which is the backbone is like Java and has lots of inheritance and calling of methods.
We can easily program it with the studio>
notion image
The online code
The Atmo code and Source files are attached below.
Though there is a problem in CO2 reading in the GUI based studio, it will not read the CO2 values as there is some problem in backed code. So for that you have to keep it as measurement for VOC then change the code in Atmo language which can be done by option to switch to pure code. While parsing you need to change from
ATMO_Status_t GetAirQualityStr_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
	unsigned int temp;
	ATMO_GetUnsignedInt(in, &temp);
	char str[32];
	sprintf(str, "%u ppb", temp);
	ATMO_CreateValueString(out, str);
	return ATMO_Status_Success;
}
to
ATMO_Status_t GetAirQualityStr_CO2_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
	unsigned int temp;
	ATMO_GetUnsignedInt(in, &temp);
	char str[32];
	sprintf(str, "%u ppm", temp);
	ATMO_CreateValueString(out, str);
	return ATMO_Status_Success;
	//return ATMO_Status_Success;
}
And it works!
Then you need to find out the Bluetooth UUIDs of your specific BLE characteristics. UUIDs are Bluetooth identification ID which tell what data is sent with which ID. Like this>
notion image
The UUIDs of the Pressure BLE gate
The one in Red is Service UUID which must remain same for all BLE Gatt Characteristics. Make sure of that! And the one in the Black is the UUID for the specific BLE GATT and will be different for all other GATTs.
Just take a note of all that UUIDs as it will be required later.
Also there is option to change the BLE characteristics and use it in in NXP's own app to get the values.

About Raspberry Pi and its Use

Raspberry Pi is a very famous single board computer and is also very powerful for its size and price also having a very large community and support.
Here we are using Raspberry Pi to do a lot of stuff as its has a SOC. The RPi handles the BLE connection, Manages data flow, stores the data and also displays it.

Code for RPi

First you need to find the mac address of your device. For that we can use command line Bluetooth tool.
//execute

bluetoothctl
//this should connect to the Bluetooth modem.

scan on
//with this you will be able to see the list of devices near you
//you can identify your's MAC address by comparing it to one given on back of your device

connect <Mac Adress>
//with this you will connect to the device

pair <Mac Adress>
//with this you will be paired with Rapid IOT and start receiving data with respective UUIDs
//UUIDs are Bluetooth identification ID which tell what data is sent with which ID
The code to get values from BLE connection is very simple. We are using Python script in RPi to connect to device and extract values and then send it via MQTT.
Very simple and commented? Check it below.
You need to replace the UUIDs in the code with the ones you found earlier. Don't forget to replace service UUID!
You can install all the libraries and other dependencies on your fresh Linux distro (recommended : Raspbian) for all the server side things : https://tech.scargill.net/the-script/
You can execute the code by:
python <file name>.py <ble adress of NXP>
// Ex: python MD2.py 00:67:sa:...

Node Red

Node red is a nodeJS based GUI controlled programming. Like Rapid IOT studio, you have Nodes (hence : nodered) which are connected with lines and the code flows in the direction of the lines.
Here we are using it to get back the string sent by the python script containing the values and then parsing it to separate all the reading and then storing it in the database. The flow can be found below.

InfluxDB and Grafana

What is InfluxDB?
InfluxDB is a database that is opensource and a easy and quick alternative to SQL or other paid databases.
The main advantages of it over others is:
  • Its free to use.
  • You need far less coding knowledge and do not need to spend a lot of time in just adding databases, entries and keys and hence you can focus on the result. A big + point against SQL
  • The amount of data you can store depends on the available ROM you have but reading although depends upon RAM. But since the NXP's inbuilt data storage has only 100MB this is better.
  • You can have some cool features. Like if you are taking readings every 10s which we are here then for a day you can average it to per min, for a month to hour and so on. Hence, we can store more required information in less memory and also amount of resource required to read it is reduced.
  • It can be installed locally on any machine rather than rely on third party server. Especially helpful when the data does impact to lot of people and needs to be secured.
What is Grafana?
Grafana is a very useful tool to analyze and show the data over a log period of time. You can easily see the data and see the data of a particular time also very easily. It is also very customizable as it is opensource.
The Grafana dashboard's script can be found below. So that you can import it in your own project and do not need to do all the graph configuration again.

Video of Project

An explanation of project and working demo>>>
Video on YT

Some Debugging and encountered problems

Sometimes the python code may not work and give some Bluetooth error. Or while scanning for BLE devices the bluetooth host may not start. So you can check if Bluetooth is on by
rfkill list
//and if it says is software blocked then execute

rfkill unblock bluetooth
//as root 
//and it will work.
If you want that the program runs even when you log out of user (via SSH) the you can excecute the code with
nohup python <name of file>.py <ble adress of your Rapid IOT> &
If you want to learn more about InfluxDB and Grafana and if you are facing some installation issues then, this is a good video: https://www.youtube.com/watch?v=JdV4x925au0

Conclusion

This project was a very fun one. And I plan to grow it further. Not necessarily BLE devices, we can use some RF ones also and WiFi is there for our rescue. Also adding a GSM shield to RPi can send the data to cloud in middle of landfill if you are confident about your security.
This project can help the people working in landfills. Also the vast fires that are occurring can be detected by some algorithm and can be extinguished. Which can lead to reduction in pollution. Also the citizens living near the landfills can be warned and the air get cleared by the authorities.
 

Schematic?

There is no need for any physical connection!
notion image
 

Code

Code - Monitoring Dump
notion image