Project: Fuel Level Alerting

Posted on Sun, Oct 13, 2019 ESP32 IoT Startup

What's up

The project is all about an integration effort of an ESP32-connected weight detection machinery to an online service to unlock possibilities like remote monitoring and alerting. To elucidate, think of remotely monitoring your gas cylinder's fuel level and getting alerted whenever the level drops below a custom-defined threshold.

The project consists of 3 independent network-connected modules:

How do you measure the weight

A load cell is a simple piezo-electric device which is designed to measure pressure (or more precisely changes in pressure) through it's bend ratio. Upon change of weight of the payload, the bend change is captured in terms of changes in the electrical signal proportionally. Therefore once we calibrate the load cell to find its "factor" against a standard weight, any weight within the manufacture range can be quite precisely measured applying simple ratios. Now, HX711 is a simple amplifier magnifying this electrical input from this load cell thereby making it available to boards to interpret and process it furthur. We experimented with collecting the results on both Arduino Uno and ESP32.

Connection of load cell โ†’ HX711 โ†’ Arduino

Connection of load cell โ†’ HX711 โ†’ ESP32

Hardware Setup

Load Cell Configuration

The load call would support a weight plate on one of its ends perpendicular to its length; while other end would be fixed to a base.

Complete picture - with Arduino Uno

Initial setup - Connected to PC (didn't work perfectly)

Complete picture - with ESP32

Setup with ESP32 (worked perfectly)

HX711 โ†’ ESP32 Connection Diagram

ESP32 with HX711 (BEWARE! Please ensure the 3.3V and GND are connected correctly in your setup!! WRONG in the diagram!!)

Application Mock Screens

Source

Template Designs

Source

Functionality Details

How do you set up a new gas cylinder device?

To start monitoring the newly fitted ESP32-connected gas cylinder, we need to help that ESP32 connect the network (obviously through WiFi). To help it connect to WiFi, we have one obvious option:

And, to accomplish this, we use Bluetooth Low Energy (BLE) to establish the connectivity between the client (say the phone here) and ESP32. So we come quite closer to the ESP32 (maximum range of BLE is 100m). This is a beautiful part in itself as the ESP32 then helps us see which all wireless networks it can see. And then we choose the network and send the SSID and password serially to the ESP32 which should next remember them in its flash memory (some boilerplate code here). So, the ESP32 now can connect the network ๐Ÿ™‚.

What's the logic of level-based alerting?

The app provides the interface to input a custom level at which the user wants to be alerted - could be say 75% or 33% or 1%. We need to address multiple challenges here:

What are some possibilities and optimizations to look at?

Project Development Checkpoints

ESP32

Sending the weight values every X minutes
Storing the calibration factor in EEPROM
Storing the SSID-password in EEPROM
BLE code to help the ESP32 get connected to a WiFi (take from PGA app)
Storing the measured percentage in EEPROM (to detect anomalies - like power switchoff or wrong readings)

Server

API to uniquely store the weights for every user
API to uniquely retrieve the weights for every user
API - register with a deviceId and customerId
Fix alreadyAlertedRecently condition
Logic to map OneSignal Id with deviceId
API to store the created alerts for every user

Ionic app

Home screen showing the percentage of gas and buttons
Creating custom push notifications using OneSignal
Register screen where the deviceId and customerId are registered in the database
CreateAlert functionality
ShowAllAlerts functionality
GetConnected screen to help ESP32 get connected to a WiFi