/RemoteTrash

A project prepared for IoT laboratories at AGH University of Science and Technology

Primary LanguagePython

Remote Trash

A project prepared for IoT laboratories at AGH University of Science and Technology.

Developed by:

The subject of the project was to create a system that implements smart monitoring. We chose to design system that would monitor the level of filling the trash bins in the city.

Based on articles (first1, second2) we have designed what should contain the device, which will measure level of garbage in a bin. The digital twin of this device and software for it was prepared by us. To run simulations we have made mocked libraries and functions, which could be replaced by real ones in actual device.

Our device sends information about its battery condition and trash level to Google Cloud cyclicaly. It uses MQTT to connect with cloud.

Our digital device is a twin of actual device, which should contain :

  • microcontroller ESP32 (eg. FireBeetle ESP32)
  • HCSR04 ultrasonic sensor
  • two lithium batteries 3.7V each (eg. li-ion 18650 - capacity: 2600mAh each)

The device will be programmed using micro python.

Because HCSR04 requires 5V and ESP32 only 3.3V we will add a resistor to the circuit. (like here3)

FireBeetle ESP32 parameters: (sources: first4, second5)

parameter value
Power Supply 3.3V DC
Deepspeed Current: 0.011mA
Working Current: 80mA
Transmission Current 190mA

HCSR04 parameters: (source6)

parameter value
Power Supply +5V DC
Quiescent Current: <2mA
Working Current: 15mA

Battery usage
Assumptions:

  1. ESP32 and HCSR04 sensor are being awaken for 30 s twice a day. For the rest of day the are in a deep sleep (ESP32) or turned off (sensor). Alternatively, ESP32 and HCSR04 sensor are turned on for equivalent of 30 s twice a day, e.g. 1 min once a day.
  2. Communication with server is using WiFi. We assume there is a constant access to WiFi network.
  3. To get 5V and 3.3V power supply we assumed that these regulators would be used: first7, second8.

With these assumptions our device's working time would be about 19 days 9 h and 30 min.

Code description

The main program of the device is in file device.py.
To create an object of the Device class, the device configuration should be passed as a parameter. The device configuration should contain the information needed to connect using mqtt and information about a bin like: bin id, capacity and time between two sent messages (message_time).

As long as the device's battery is not discharged the device gets the bin filling, updates the battery usage, sends information to the cloud and falls into a sleep for a specified period of time (message time). The device uses less energy while sleeping.

The actual device should retrieve information about the level of filling the bin from the HCSR04 sensor. We have mocked library used to operate the sensor, so that the bin will be filling up with the given speed.
We have also mocked some of machine library functions used to operate microcontroller.

The simulation is run from the file simulation.py, where the devices programs are started in separate threads.

Cloud Computing

To handle data processing and managing of IOT devices we chose Google Cloud services. IOT Core service is responsible for registering devices, receiving data and uploading configuration to devices. Telemetry data gathered from smart bins are passed to Big Query via Dataflow and then they are ready to be processed with Big Data/AI tools available on Google Cloud. Data are transferred with MQTT protocol secured with TLS and RSA algorithm. Devices are configured to send: battery level, bin fulfillment, device ID and timestamp of a measurement - all packed up into JSON.

We also prepared a simple script to bulk register many devices. We only have to pass device list as an argument and script will do all job for us, this includes key generation and sending proper metadata to IOT Core.

Visualization

The visualization is run as a seperate script visualization.py. Data is queried from Big Query every 10 seconds and for each device only the entry with the newest timestamp is displayed. To run the script you need to supply a path to a file with your Google Could credentials. This can be done by running the following command:

export GOOGLE_APPLICATION_CREDENTIALS="path to your credentials"


1 first article: IoT based Smart Garbage and Waste Monitoring System using MQTT Protocol, authors: Harshitha N, Nehashree K Ruthika, Rhea Benny, Varsha S P, Keerthi Kumar M2 2Assitant Professor, Department of TCE, GSSSIETW, Mysuru, Karnataka, India. Students, BE, Department of TCE, GSSSIETW, Mysuru, Karnataka, India; access: 10.02.2021
2 second article: Smart Waste Collection System Based on Location Intelligence authors: Jose M. Gutierrez, Michael Jensenb, Morten Heniusa and Tahir Riaz; access: 10.02.2021
3 Using An Ultrasonic Sensor (HC-SR04) with a 3.3v micro-controller (Tiva C Series) author: sheldondwill; access: 10.02.2021
4 Guide to Reduce the ESP32 Power Consumption by 95% author: Christopher David; access: 10.02.2021
5 DFRobot FireBeetle ESP32 IOT Microcontroller; access: 10.02.2021
6 HC-SR04 Datasheet author: Elijah J. Morgan; access: 10.02.2021
7 access: 11.01.2021
8 access: 11.01.2021