Fuelmanager is an integrated system that gives car owners information about the fuel consumption and fuel consumption of a car.
By installing a simple plug and play module and connecting it to their smartphone, the user will receive a lot of information about fuel consumption, fuel consumption and even an overview of all the recent routes he traveled.
Assembled on ESP32 modules, Raspberry Pi 4 and a Bluetooth OBD2 reader, Fuelmanager is cheap and easy to make and use.
Tools and Materials: -Raspberry Pi 4 (4GB minimum RAM); – Micro SD card (64 GB recommended);
-Car charger USB-C;
-Down converter 12V – 5V (1A);
-Autoscanner OBD2 ELM327 Bluetooth module;
-LCD display HDMI; -ESP32 DevKit module; -Cable HDMI; -Rotary encoder; -LED strip WS218B RGB;
-GPS NEO module – N8M;
Step one: diagram
The device diagram is not complicated. No boards, everything is assembled from ready-made modules. The main thing in this device is software.
Step Two: Configuring Raspberry Pi 4
Downloading the Raspberry Pi Imager from the site https://www.raspberrypi.org/software/
Downloading the Raspberry Pi OS Flash to the SD card.
After installation, you need to remove the SD card from the PC and insert it again.
The computer should display a disk named “Boot”, open it.
Create an empty file with no extension named “ssh” to enable the ssh function on the Raspberry Pi
Find and open the cmdline.txt file and add to the end ip = 169.254.10.1.
Insert SD card into Raspberry Pi
Connect your computer and Raspberry Pi directly with an Ethernet cable.
Connecting the Raspberry Pi power supply
Open a CMD or terminal window and enter ssh [email protected]
The default password is “raspberry”.
Next, you need to configure the Raspberry Pi OS.
Using sudo raspi -config select 3 – & gt; Serial Port – & gt; No – & gt; Yes
We select option 5 and indicate our country, this is important for the Wi-Fi network.
Next, follow the instructions on the Raspberry Pi website to configure the Hostapd wireless access point.
Install the database server.
sudo apt install mariadb-server mariadb-client
create user student @ localhost identified by 'W8w00rd';
flush privileges: 'grant all privileges on *. * to username @ localhost; '
Install RGB LED drivers.
curl -L http://coreelec.io/33 |
Step three: software installation
Next you need to download software from this repository
There will be 3 folders: Backend, Frontend, Database.
Go to the Backend folder and run this command:
pip3 -r install requirements
Go to the Databse folder and run the following command:
mysql -u student -p W8w00rd Fuelmanager.sql
Go to the Frontend folder and run the following commands:
sudo -i sudo apt install apache2 sudo nano /etc/apache2/sites-available/000-default.conf Change & # 39 ; DocumentRoot & # 39; to & # 39; DocumentRoot/frontend & # 39; Save by CTRL + X and Y service apache2 restart
Step Four: Configuring ESP32 and OBD2
This step requires a Bluetooth OBD2 and ESP32 module.
The software should work with any of the ELM327 based Bluetooth OBD2 modules.
The script automatically connects to the Wi-Fi network that the Raspberry Pi 4 creates to send everything data to the server.
Since both Bluetooth and Wi-Fi are used, the software is larger than the built-in ESP32 flash memory. You can fix this by changing the partition scheme:
go to Arduino Tools – & gt; Board – & gt; Pick ESP32, then go to Tools – & gt; Partition Scheme – & gt; Pick Minimal Spiffs
The code can be downloaded below.
# include & # 34; BluetoothSerial.h & # 34; # include & # 34; ELMduino.h & # 34; # include & lt; ArduinoJson.h & gt; # include & lt; HTTPClient.h & gt; # include & lt; WiFi.h & gt; constchar * ssid = & # 34; Fuelmanager & # 34 ;; constchar * password = & # 34; Fuelmanager123 & # 34 ;; String serverName = & # 34; http & # 58; //192.168.0.10 & # 58; 5000/api/postobd & # 34 ;; BluetoothSerial SerialBT; #defineELM_PORT SerialBT ELM327 myELM327; voidsetup () & # 123; WiFi.begin (ssid, password); while (WiFi.status ()! = WL_CONNECTED) & # 123; delay (500); } ELM_PORT.begin (& # 34; Fuelmanager & # 34 ;, true); while (! ELM_PORT.connect (& # 34; OBDII & # 34;)) & # 123; delay (500); } while (! myELM327.begin (ELM_PORT, true, 2000)) & # 123; delay (500); } delay (1000); } voidloop () & # 123; delay (500); float rpm = myELM327.rpm (); float maf = myELM327.mafRate (); float kph = myELM327.kph (); float coolanttemp = myELM327.engineCoolantTemp (); float engineload = myELM327.engineLoad (); if (myELM327.status == ELM_SUCCESS) & # 123; if (WiFi.status () == WL_CONNECTED) & # 123; HTTPClient http; http.begin (serverName); http.addHeader (& # 34; Content-Type & # 34 ;, & # 34; application/json & # 34;); StaticJsonDocument & lt; 200 & gt; doc; doc & # 91; & # 34; rpm & # 34; & # 93; = rpm; doc & # 91; & # 34; maf & # 34; & # 93; = maf; doc & # 91; & # 34; speed & # 34; & # 93; = kph; doc & # 91; & # 34; coolant & # 34; & # 93; = coolanttemp; doc & # 91; & # 34; load & # 34; & # 93; = engineload; String requestBody; serializeJson (doc, requestBody); int httpResponseCode = http.POST (requestBody); http.end (); }} else myELM327.printError (); }
Step Five: User Interface and Database
In the picture we see the user interface. Here you can configure various parameters such as fuel cost, quantity, etc.
Every second while the user is driving a vehicle with Fuelmanager installed, ESP32 reads OBD2 data and converts it into data. This data is sent to the Flask API with a POST request.
When it arrives, the API stores it in the database along with the measurement timestamp and data from the GPS module connected to the Raspberri Pi.
When the car starts moving and the system reads that there is data in the measurement table, it starts to process all the data to obtain the corresponding information and even creates a GPX file from the GPS data. Then everything is saved in the Tour table. If you want to see the distance traveled, you just need to take data from the Tour table.
This is where the car parameters are stored, the most important variable: Current_FuelPrice. Whenever the user wants to see costs, the current fuel price for that day is used. This means that he has to set the price of fuel every time he refills and the price changes.
This is the personal login data, which stores user information and a password hash.
< a href = "https://usamodelkina.ru/uploads/posts/2021-07/1625248523_1-5.jpg" rel = "prettyPhoto"> Step six: launch automation
The server side should start every time the Raspberry Pi is turned on, that is, whenever the car starts the engine.
sudo nano /etc/systemd/fuelmanager.service
Paste the content below
CTRX + XY to save < br> sudo systemctl enable fuelmanager.service
sudo systemctl start fuelmanager.service
& # 91; Unit & # 93; Description = Fuelmanager After = network.target & # 91; Service & # 93; ExecStart =/usr/bin/python3 -u /backend/app.py WorkingDirectory =/backend/StandardOutput = inherit StandardError = inherit Restart = always User = & # 91; Install & # 93; WantedBy = multi-user.target
Step seven: case
The case for the device was 3D printed by the master. The wizard made an OBD2 case that connects to the existing OBD2 + ESP32 adapter and Buck converter.
The LCD case is designed for a 7 “display, and a Raspberry Pi can be installed behind it.
Print files can be downloaded below.
After printing the details, you only need collect everything and install in the case.