RTHMS (1) (AutoRecovered)

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 43

REAL-TIME HEALTH MONITORING

SYSTEM FOR AUTOMOBILES

[DATE] [COMPANY NAME] [Company address]


Table of Contents
Introduction and Market Research........................................................................................................................
Problem Statement...........................................................................................................................................
Business Level Requirement Analysis....................................................................................................................
Feature 1: Continuously monitor critical vehicle parameters, such as engine temperature, tire
pressure, and fuel levels, using advanced sensors to provide real-time data and alerts...................................

Feature 2: Enable preventive maintenance by analyzing sensor data to detect potential issues
early, reducing the risk of unexpected breakdowns and costly repairs....................................................

Feature 3: Ensure vehicle reliability and safety by integrating a user interface that displays real-
time health information and alerts to drivers and fleet managers, facilitating timely
maintenance actions.......................................................................................................................................
Component Level requirements............................................................................................................................
Design:..................................................................................................................................................................
Class Diagram................................................................................................................................................
Low level Test Cases and Traceability to Stakeholder’s Requirements (SRs)..................................................
Project Plan.........................................................................................................................................................
Tasks................................................................................................................................................................
Project deadlines.............................................................................................................................................
Task Assignment..............................................................................................................................................
Software Design..................................................................................................................................................
Sequence Diagram...........................................................................................................................................
Hardware Design.............................................................................................................................................
Activity Diagram..............................................................................................................................................
Block Diagram.................................................................................................................................................
Schematic Diagram in 1D.................................................................................................................................
Schematic Diagram in 3D.................................................................................................................................
Components Used...............................................................................................................................................
Test Cases............................................................................................................................................................
Challenges...........................................................................................................................................................
Code....................................................................................................................................................................
Results........................................................................................................................................................
Conclusion..................................................................................................................................................
Future Work..............................................................................................................................................
References..................................................................................................................................................
Introduction and Market Research
Real-Time Health Monitoring Systems (RTHMS) for automobiles are revolutionizing vehicle
maintenance and safety by providing continuous, real-time data on critical parameters such
as engine temperature, tire pressure, and fuel levels. These systems use advanced sensors,
microcontrollers, and data analytics to detect potential issues early, allowing for preventive
maintenance and reducing the risk of breakdowns. The primary benefits of RTHMS include
enhanced vehicle reliability, improved safety, and increased operational efficiency, making
them a valuable addition to modern vehicles.

The market for RTHMS is rapidly growing, driven by the increasing demand for vehicle safety
and reliability, as well as stringent regulatory requirements. Key players in the market include
Bosch, Continental AG, and Denso Corporation, among others. Technological advancements,
such as the integration of IoT and AI, are further enhancing the capabilities and affordability
of these systems. However, challenges like high initial costs and data privacy concerns remain.
Despite these challenges, the future of RTHMS is promising, with continuous innovations
expected to drive widespread adoption across various vehicle segments.

Problem Statement

Design and develop an automotive embedded system that includes the following features:

Feature 1: Continuously monitor critical vehicle parameters, such as engine temperature, tire
pressure, and fuel levels, using advanced sensors to provide real-time data and alerts.

Feature 2: Enable preventive maintenance by analyzing sensor data to detect potential issues
early, reducing the risk of unexpected breakdowns and costly repairs.

Feature 3: Ensure vehicle reliability and safety by integrating a user interface that displays
real-time health information and alerts to drivers and fleet managers, facilitating timely
maintenance actions.
Business Level Requirement Analysis
Feature 1: Continuously monitor critical vehicle parameters, such as
engine temperature, tire pressure, and fuel levels, using advanced
sensors to provide real-time data and alerts.

Stakeholder Requirements (R1) Business Test Cases / User Acceptance Test Case
R1.1: The system must
continuously collect data from
Verify that the system accurately collects and displays real-
sensors monitoring engine
time data from all connected sensors.
temperature, tire pressure, and
fuel levels.

R1.2: The system must ensure


accuracy and reliability of sensor Verify that the sensor data is consistent and accurate under
data. different operating conditions.

R1.3: The system must provide an Verify that the dashboard interface is user-friendly and
intuitive dashboard interface for displays real-time health data clearly and accurately.
real-time health status display.

Feature 2: Enable preventive maintenance by analyzing sensor data


to detect potential issues early, reducing the risk of unexpected
breakdowns and costly repairs.
Stakeholder Requirements (R2) Business Test Cases / User Acceptance Test Case
R2.1: The system must implement Verify that the system can correctly analyze historical sensor
algorithms to analyze sensor data data to predict and alert on potential failures
and predict potential failures.
R2.2: The system must generate
alerts and maintenance Verify that the system generates accurate and timely
recommendations based on maintenance alerts and recommendations.
predictive analysis.

R2.3: The system must integrate Verify that the system integrates seamlessly with existing
with existing vehicle maintenance maintenance schedules and systems.
schedules and systems.
Feature 3: Ensure vehicle reliability and safety by integrating a user
interface that displays real-time health information and alerts to
drivers and fleet managers, facilitating timely maintenance actions.

Stakeholder Requirements (R3) Business Test Cases / User Acceptance Test Case
R3.1: The system must develop a Verify that the interface is easy to navigate and displays real-
user-friendly interface for time data and alerts effectively.
displaying real-time health data
and alerts.

R3.2: The system must ensure the Verify that both drivers and fleet managers can access and
interface is easily accessible to use the interface without difficulty.
both drivers and fleet managers.

R3.3: The system must provide Verify that alerts are clear, actionable, and enable timely
clear and actionable alerts for maintenance actions.
timely maintenance.

Component Level requirements


Stakeholder Requirements Component Requirements
R1.1: The system must Sensors - Accuracy: ±1% for temperature,
continuously collect data ±0.5 PSI for tire pressure,
from sensors monitoring ±0.5% for fuel level
engine temperature, tire
pressure, and fuel levels.

Control - Response Time: < 1 second


Unit - Operating Temperature Range: -40°C to
+125°C
-Integration compatible with STM32
microcontroller and I2C interface.
Data - Data Refresh Rate: >10 Hz
R1.2: The system must Processing - Error Rate: < 1%
ensure accuracy and Unit
reliability of sensor data.
- Self-Calibration: Sensors must auto-calibrate
periodically

User - Display Type: LCD/TFT


R1.3: The system must Interface - Resolution: Minimum 480x320 pixels
provide an intuitive - Refresh Rate: >60 Hz
dashboard interface for real- - User-Friendly: Easy navigation and clear
time health status display. visualization
Control Unit - Algorithm Implementation: Implement
dynamic display update
- Real-time Data Handling: Handle updates
within 50 ms
Data - Capacity: Minimum 4GB for storing historical
Storage data
- Retention: Data retention for >10 years
- Access Speed: Retrieve data in <10 ms
Design:
Class Diagram
Low level Test Cases and Traceability to Stakeholder’s Requirements (SRs)

Test Case
SR Component Method Input Expected Output
Description
Test reading The returned angle
Engine engine matches the
R1.1 Temperature readTemperature() temperature N/A expected raw
sensor value (e.g.,
Sensor from the
45.0).
sensor.
Verify tire The returned angle
Tire Pressure pressure is filtered correctly
R1.1 readPressure() N/A (e.g.,
Sensor reading
accuracy. 50.0 if no filtering)
Validate fuel The calculated
Fuel Level level sensor angle matches the
R1.1 readFuelLevel() N/A
Sensor accuracy. expected value
(e.g., 15.0)
Test data The control signal is
Data processing for Sample correctly sent
R1.2 Processing processData() sensor sensor data (Require some
Unit accuracy and set MOCK
reliability. to verify)
The headlight angle
Test real-time is correctly
Dashboard health status adjusted
R1.3 displayHealthStatus() N/A
Interface display on the (Require some
dashboard. MOCK
to verify)
Validate The returned
storage of position matches
Test data the expected
R1.4 Data Storage storeHistoricalData() historical data
set actuator position.
for trend
analysis.
The PWM signal
Test displaying
matches the
the system status =
R1.4 User Interface displayStatus(constchar*) expected value
status to the "OK"
based on
driver. conversion.
Test getting
Simulate
input from the The status is
R1.4 UserInterface getUserInput() user input
user - Override correctly displayed
"Override"
mode.
Test getting Simulate The input
input from the user input "Override" is
R1.4 UserInterface getUserInput() correctly received
user - Reset "Reset"
mode. and processed.

Project Plan
Tasks
The whole project can be divided into 4 main tasks based on the features that are implemented:

1. Real-Time Sensor Data Collection


2. Data Processing and Analysis
3. Alert and Notification System
4. User Interface for Health Status Display and Data Management

Project deadlines
Sl. No Task Start Date End Date Status
1 Market Research and 20-5-2024 25-5-2024 Completed
adjusting the problem
statement
2 Finalizing the Features 26-5-2024 31-5-2024 Completed
3 Finalizing the individual 1-6-2024 7-6-2024 Completed
Requirements and
Business Test Cases
4 Individual Implementation 8-6-2024 20-6-2024 Completed
and Component Level
Testing
5 Integration and Testing 21-6-2024 5-7-2024 Completed

6 Documentation 3-7-2024 - Completed

7 Presentation 5-7-2024 - Completed


8 Complete Documentation 8-7-2024 14-7-2024 Completed

Table 1: Project Deadlines

Task Assignment
Team Member Task Assigned

Vignesh Hardware integration

Nanda Kumar User Interface

Santhosh DTC Implementation

Nikitha Arduino(STM32) Code

Software Design
Sequence Diagram
Figure 1: Sequence Diagram

Hardware Design

Figure 2: Hardware Design


Activity Diagram

Figure 3: Activity Diagram


Block Diagram

Figure 4: Block Diagram

Schematic Diagram in 1D
Schematic Diagram in 3D

Components Used

Components used
Figure 5: Final Ciruit (Integrated)

DTC Codes for bmp180 pressure sensor:


DTC Codes for bmp180 temperature sensor:
DTC Codes for Fuel level sensor:

UI/HMI:
Test Cases
Challenges :
 Real-Time Data Transmission: Ensuring minimal latency and high reliability in transmitting
sensor data from the STM32 microcontroller to the Python dashboard.
 Sensor Integration and Calibration: Integrating and calibrating various sensors with the STM32
to ensure accurate and consistent data readings across different conditions.
 Memory and Power Management: Efficiently managing the limited memory and power resources
of the STM32, particularly during continuous data collection and transmission.
 User Interface Design: Developing an intuitive and visually appealing Python Tkinter dashboard
that can handle real-time updates without performance issues.
 DTC Implementation and Handling: Implementing comprehensive Diagnostic Trouble Codes
(DTCs) for various faults and ensuring accurate diagnosis and error handling.

Code
main.ino

/**************************************************************************** **
* File Name: main.ino
* Description: Embedded C++ Code to simulate Real-time Health
Monitoring System for Automobiles
* Created By: Nikitha, Santhosh, Vignesh, Nanda Kumar
*
* Created Date: 08/06/2024
***************************************************************************** */
/**************************************************************************** **
* Header Files
***************************************************************************** */
#include “FuelLevelSensor.h”
#include “BMP180Sensor.h”
/**************************************************************************** **
* Function Definitions
*/
/**************************************************************************** **
* Name: setup()
* Description: Initialize the sensor readings
* Arguments: None
*/

void setup() {
// Initialize serial communication at 9600 baud rate
Serial.begin(9600);

// Initialize the sensors


setupFuelLevelSensor(); // Fuel level sensor initialization
setupBMP180(); // BMP180 sensor initialization
}

/**************************************************************************** **
* Name: loop()
* Description: Sensor readings with 1-second delay
* Arguments: None
*/

void loop() {
// Sensor readings processing
checkFuelLevel(); // Check and process fuel level sensor readings
checkBMP180(); // Check and process BMP180 sensor readings

// Delay between sensor checks


delay(1000); // Add a 1-second delay between sensor checks
}

/******************************** end of main


********************************/
/**************************************************************************** **
* End of File
***************************************************************************** */

DTC_Codes.h

/******************************************************************************
* File Name: DTC_Codes.h
* Description: Header file defining Diagnostic Trouble Codes
(DTC) for various sensors
* Created By: Nikitha, Santhosh, Vignesh, Nanda Kumar
* Created Date: 08/06/2024
*****************************************************************************/

/**************************************************************************** **
* Preprocessor Definition
***************************************************************************** */
#ifndef DTC_CODES_H
#define DTC_CODES_H
// Define Diagnostic Trouble Codes (DTC) for various sensors

// Define DTC codes for Tire Pressure Sensor


#define DTC_TPS_GENERAL_FAULT 3000
#define DTC_TPS_COMM_FAILURE 3001
#define DTC_TPS_NOT_RESPONDING 3002
#define DTC_TPS_BATTERY_LOW 3003
#define DTC_TPS_BATTERY_HIGH 3004
#define DTC_TPS_INTERNAL_FAILURE 3005
#define DTC_TPS_SIGNAL_LOST 3300
#define DTC_TPS_PLAUSIBILITY_FAILURE 3301
#define DTC_TPS_DATA_INVALID 3302
#define DTC_TPS_CONFIG_ERROR 3303
#define DTC_TPS_INIT_FAILED 3304
#define DTC_TPS_CALIBRATION_ERROR 3305
#define DTC_TPS_TEMP_OUT_OF_RANGE 3306
#define DTC_TPS_PRESSURE_OUT_OF_RANGE 3307
#define DTC_TPS_ACCURACY_FAILURE 3308
#define DTC_TPS_SELF_TEST_FAILED 3309
#define DTC_TPS_RANGE_CHECK_FAILED 3310
#define DTC_TPS_CIRCUIT_VOLTAGE_HIGH 3311
#define DTC_TPS_CIRCUIT_VOLTAGE_LOW 3312
#define DTC_TPS_CIRCUIT_SHORT_TO_GROUND 3313

// Define DTC codes for Engine Temperature Sensor


#define DTC_ETS_GENERAL_FAULT 3200
#define DTC_ETS_COMM_FAILURE 3201
#define DTC_ETS_NOT_RESPONDING 3202
#define DTC_ETS_CIRCUIT_VOLTAGE_LOW 3203
#define DTC_ETS_CIRCUIT_VOLTAGE_HIGH 3204
#define DTC_ETS_INTERNAL_FAILURE 3205
#define DTC_ETS_SIGNAL_LOST 3500
#define DTC_ETS_PLAUSIBILITY_FAILURE 3501
#define DTC_ETS_DATA_INVALID 3502
#define DTC_ETS_CONFIG_ERROR 3503
#define DTC_ETS_INIT_FAILED 3504
#define DTC_ETS_CALIBRATION_ERROR 3505
#define DTC_ETS_TEMP_OUT_OF_RANGE 3506
#define DTC_ETS_PRESSURE_OUT_OF_RANGE 3507
#define DTC_ETS_ACCURACY_FAILURE 3508
#define DTC_ETS_SELF_TEST_FAILED 3509
#define DTC_ETS_RANGE_CHECK_FAILED 3510
#define DTC_ETS_CIRCUIT_VOLTAGE_HIGH 3511
#define DTC_ETS_CIRCUIT_VOLTAGE_LOW 3512
#define DTC_ETS_CIRCUIT_SHORT_TO_GROUND 3513

// Define DTC codes for Fuel Level Sensor


#define DTC_FLS_GENERAL_FAULT 3100
#define DTC_FLS_COMM_FAILURE 3101
#define DTC_FLS_NOT_RESPONDING 3102
#define DTC_FLS_CIRCUIT_VOLTAGE_LOW 3103
#define DTC_FLS_CIRCUIT_VOLTAGE_HIGH 3104
#define DTC_FLS_INTERNAL_FAILURE 3105
#define DTC_FLS_SIGNAL_LOST 3400
#define DTC_FLS_PLAUSIBILITY_FAILURE 3401
#define DTC_FLS_DATA_INVALID 3402
#define DTC_FLS_CONFIG_ERROR 3403
#define DTC_FLS_INIT_FAILED 3404
#define DTC_FLS_CALIBRATION_ERROR 3405
#define DTC_FLS_TEMP_OUT_OF_RANGE 3406
#define DTC_FLS_PRESSURE_OUT_OF_RANGE 3407
#define DTC_FLS_ACCURACY_FAILURE 3408
#define DTC_FLS_SELF_TEST_FAILED 3409
#define DTC_FLS_RANGE_CHECK_FAILED 3410
#define DTC_FLS_CIRCUIT_VOLTAGE_HIGH 3411
#define DTC_FLS_CIRCUIT_VOLTAGE_LOW 3412
#define DTC_FLS_CIRCUIT_SHORT_TO_GROUND 3413

#endif // DTC_CODES_H

/******************************** end of main


********************************/
/**************************************************************************** **
* End of File
***************************************************************************** */

BMP180Sensor.h

/******************************************************************************
* File Name: BMP180Sensor.h
* Description: Header file for BMP180 sensor functions and
constants
* Created By: Nikitha, Santhosh, Vignesh, Nanda Kumar
* Created Date: 08/06/2024
*****************************************************************************/
/**************************************************************************** **
* Preprocessor Definition
***************************************************************************** */

#ifndef BMP180_SENSOR_H
#define BMP180_SENSOR_H

/******************************************************************************
* Header Files
*****************************************************************************/
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP085_U.h>

/******************************************************************************
* Constant Definitions
*****************************************************************************/

// Pressure thresholds in hPa


const float NORMAL_PRESSURE_LOW = 500.0; // Low normal pressure threshold
const float NORMAL_PRESSURE_HIGH = 2000.0; // High normal pressure threshold

// Temperature thresholds in degrees Celsius


const float NORMAL_TEMP_LOW = 0.0; // Low normal temperature threshold
const float NORMAL_TEMP_HIGH = 80.0; // High normal temperature threshold

/******************************************************************************
* Function Prototypes
*****************************************************************************/

/******************************************************************************
* Name: setupBMP180()
* Description: Initializes the BMP180 sensor
* Arguments: None
* Returns: None
*****************************************************************************/
void setupBMP180(); // Initializes the BMP180 sensor

/******************************************************************************
* Name: checkBMP180()
* Description: Checks and processes BMP180 sensor readings
* Arguments: None
* Returns: None
*****************************************************************************/
void checkBMP180(); // Checks and processes BMP180 sensor readings
#endif // BMP180_SENSOR_H

/******************************** end of main


********************************/
/**************************************************************************** **
* End of File
***************************************************************************** */

BMP180Sensor.cpp

/******************************************************************************
* File Name: BMP180Sensor.cpp
* Description: Implementation file for BMP180 sensor functions
and DTC codes
* Created By: Nikitha, Santhosh, Vignesh, Nanda Kumar
* Created Date: 08/06/2024
*****************************************************************************/
/**************************************************************************** **
* Header Files
***************************************************************************** */

#include "BMP180Sensor.h"
#include "DTC_Codes.h"

Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(10085);

/******************************************************************************
* Function Definitions
*****************************************************************************/

/******************************************************************************
* Name: setupBMP180()
* Description: Initializes the BMP180 sensor
* Arguments: None
* Returns: None
*****************************************************************************/

// Initialize the BMP180 sensor


void setupBMP180() {
//Serial.begin(9600);
while (!bmp.begin()) {
Serial.println("Could not find a valid BMP180 sensor, check wiring!");
// Print general fault DTC codes for TPS and ETS if initialization fails
Serial.println("DTC Code: P" + String(DTC_TPS_GENERAL_FAULT)); //
DTC_TPS_GENERAL_FAULT
Serial.println("DTC Code: P" + String(DTC_TPS_INIT_FAILED)); //
DTC_TPS_INIT_FAILED
Serial.println("DTC Code: P" + String(DTC_ETS_GENERAL_FAULT)); //
DTC_ETS_GENERAL_FAULT
delay(100); // Pause forever if initialization fails
}
}

/******************************************************************************
* Name: checkPressure(float pressureValue)
* Description: Checks the pressure values and prints corresponding
DTC codes
* Arguments: float pressureValue - The pressure value to be checked
* Returns: None
*****************************************************************************/

void checkPressure(float pressureValue);

/******************************************************************************
* Name: checkTemperature(float temperature)
* Description: Checks the temperature values and prints
corresponding DTC codes
* Arguments: float temperature - The temperature value to be
checked
* Returns: None
*****************************************************************************/

void checkTemperature(float temperature);

/******************************************************************************
* Name: checkBMP180()
* Description: Checks and processes BMP180 sensor readings
* Arguments: None
* Returns: None
*****************************************************************************/

// Check BMP180 sensor readings


void checkBMP180() {
sensors_event_t event;
bmp.getEvent(&event);

// Check if the event is a valid pressure reading


if (event.pressure) {
// Display pressure
Serial.print("Pressure: ");
Serial.print(event.pressure);
Serial.println(" hPa");

// Get temperature in Celsius


float temperature;
bmp.getTemperature(&temperature);

// Display temperature
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" C");

// Check pressure and temperature readings


checkPressure(event.pressure);
checkTemperature(temperature);
} else {
Serial.println("Sensor error");
}
}

// Check pressure values


void checkPressure(float pressureValue) {
if (pressureValue < 0) {
Serial.println("DTC Code: P"+String(DTC_TPS_BATTERY_LOW)); // Battery low for
TPS
}
if (pressureValue > 2500) {
Serial.println("DTC Code: P"+String(DTC_TPS_BATTERY_HIGH)); // Battery high
for TPS
}
if (pressureValue == -1) { // Assuming -1 indicates an internal failure from the
sensor
Serial.println("DTC Code: P"+String(DTC_TPS_INTERNAL_FAILURE)); // Internal
failure for TPS
}
if (pressureValue < 500 || pressureValue > 2500) {
Serial.println("DTC Code: P"+String(DTC_TPS_SIGNAL_LOST)); // Signal lost for
TPS
}
if (pressureValue < 0 || pressureValue > 1500) {
Serial.println("DTC Code: P"+String(DTC_TPS_PLAUSIBILITY_FAILURE)); //
Plausibility failure for TPS
}
if (pressureValue < 0 || pressureValue > 2000) {
Serial.println("DTC Code: P"+String(DTC_TPS_DATA_INVALID)); // Data invalid
for TPS
}
if (pressureValue < 200 || pressureValue > 3000) {
Serial.println("DTC Code: P"+String(DTC_TPS_CONFIG_ERROR)); // Configuration
error for TPS
}
if (pressureValue == 0) {
Serial.println("DTC Code: P"+String(DTC_TPS_CALIBRATION_ERROR)); //
Calibration error for TPS
}
if (pressureValue < 500 || pressureValue > 1500) {
Serial.println("DTC Code: P"+String(DTC_TPS_TEMP_OUT_OF_RANGE)); //
Temperature out of range for TPS
}
if (pressureValue < NORMAL_PRESSURE_LOW) {
Serial.println("DTC Code: P"+String(DTC_TPS_PRESSURE_OUT_OF_RANGE)); //
Pressure out of range for TPS
} else if (pressureValue > NORMAL_PRESSURE_HIGH) {
Serial.println("DTC Code: P"+String(DTC_TPS_PRESSURE_OUT_OF_RANGE));
}
if (pressureValue > 2300) {
Serial.println("DTC Code: P"+String(DTC_TPS_ACCURACY_FAILURE)); // Accuracy
failure for TPS
}
if (pressureValue == 1000) {
Serial.println("DTC Code: P"+String(DTC_TPS_SELF_TEST_FAILED)); // Self-test
failed for TPS
}
if (pressureValue > 2400) {
Serial.println("DTC Code: P"+String(DTC_TPS_RANGE_CHECK_FAILED)); // Range
check failed for TPS
}
if (pressureValue > 2200) {
Serial.println("DTC Code: P"+String(DTC_TPS_CIRCUIT_VOLTAGE_HIGH)); //
Circuit voltage high for TPS
}
if (pressureValue < 60) {
Serial.println("DTC Code: P"+String(DTC_TPS_CIRCUIT_VOLTAGE_LOW)); // Circuit
voltage low for TPS
}
if (pressureValue == 0) {
Serial.println("DTC Code: P"+String(DTC_TPS_CIRCUIT_SHORT_TO_GROUND)); //
Circuit short to ground for TPS
}
}

void checkTemperature(float temperature) {


if (temperature == -1) {
Serial.println("DTC Code: P"+String(DTC_ETS_NOT_RESPONDING)); // ETS not
responding
}
if (temperature == -999) {
Serial.println("DTC Code: P"+String(DTC_ETS_INTERNAL_FAILURE)); // Internal
failure for ETS
}
if (temperature == -1000) {
Serial.println("DTC Code: P"+String(DTC_ETS_SIGNAL_LOST)); // Signal lost for
ETS
}
if (temperature < 0 || temperature > 150) {
Serial.println("DTC Code: P"+String(DTC_ETS_PLAUSIBILITY_FAILURE)); //
Plausibility failure for ETS
}
if (temperature == 0) {
Serial.println("DTC Code: P"+String(DTC_ETS_DATA_INVALID)); // Data invalid
for ETS
}
if (temperature == -2000) {
Serial.println("DTC Code: P"+String(DTC_ETS_CONFIG_ERROR)); // Configuration
error for ETS
}
if (temperature > 125) {
Serial.println("DTC Code: P"+String(DTC_ETS_INIT_FAILED)); // Initialization
failed for ETS
}
if (temperature == -500) {
Serial.println("DTC Code: P"+String(DTC_ETS_CALIBRATION_ERROR)); //
Calibration error for ETS
}
if (temperature < NORMAL_TEMP_LOW || temperature > NORMAL_TEMP_HIGH) {
Serial.println("DTC Code: P"+String(DTC_ETS_TEMP_OUT_OF_RANGE)); //
Temperature out of range for ETS
}
if (temperature < 50 || temperature > 250) {
Serial.println("DTC Code: P"+String(DTC_ETS_PRESSURE_OUT_OF_RANGE)); //
Pressure out of range for ETS
}
if (temperature > 230) {
Serial.println("DTC Code: P"+String(DTC_ETS_ACCURACY_FAILURE)); // Accuracy
failure for ETS
}
if (temperature == 1000) {
Serial.println("DTC Code: P"+String(DTC_ETS_SELF_TEST_FAILED)); // Self-test
failed for ETS
}
if (temperature > 240) {
Serial.println("DTC Code: P"+String(DTC_ETS_RANGE_CHECK_FAILED)); // Range
check failed for ETS
}
if (temperature > 220) {
Serial.println("DTC Code: P"+String(DTC_ETS_CIRCUIT_VOLTAGE_HIGH)); //
Circuit voltage high for ETS
}
if (temperature < 60) {
Serial.println("DTC Code: P"+String(DTC_ETS_CIRCUIT_VOLTAGE_LOW)); // Circuit
voltage low for ETS
}
if (temperature < -20) {
Serial.println("DTC Code: P"+String(DTC_ETS_CIRCUIT_SHORT_TO_GROUND)); //
Circuit short to ground for ETS
}

/******************************** end of main


********************************/
/**************************************************************************** **
* End of File
***************************************************************************** */

FuelLevelSensor.h

/******************************************************************************
* File Name: FuelLevelSensor.h
* Description: Header file for the Fuel Level Sensor
functionalities
* Created By: Nikitha, Santhosh, Vignesh, Nanda Kumar
* Created Date: 08/06/2024
*****************************************************************************/

/**************************************************************************** **
* Preprocessor Definition
***************************************************************************** */
#ifndef FUEL_LEVEL_SENSOR_H
#define FUEL_LEVEL_SENSOR_H

/******************************************************************************
* External Variable Declarations
*****************************************************************************/

// External variable declarations


extern const int FUEL_LEVEL_SENSOR_PIN; // Pin number for the fuel level sensor
extern int fuelLevel; // Current fuel level reading

/******************************************************************************
* Fuel Level Threshold Values (Analog)
*****************************************************************************/

// Fuel level threshold values (analog)


const int FUEL_LEVEL_LOW_THRESHOLD = 200; // Threshold for low fuel level
const int FUEL_LEVEL_HIGH_THRESHOLD = 800; // Threshold for high fuel level

/******************************************************************************
* Function Prototypes
*****************************************************************************/

// Function prototypes
void setupFuelLevelSensor(); // Setup function for the fuel level sensor
void checkFuelLevel(); // Function to check the current fuel level

#endif // FUEL_LEVEL_SENSOR_H

/******************************** end of main


********************************/
/**************************************************************************** **
* End of File
***************************************************************************** */

FuelLevelSensor.cpp

/******************************************************************************
* File Name: FuelLevelSensor.cpp
* Description: Implementation of Fuel Level Sensor functionalities
* Created By: Nikitha, Santhosh, Vignesh, Nanda Kumar
* Created Date: 08/06/2024
*****************************************************************************/
/**************************************************************************** **
* Header Files
***************************************************************************** */

#include "FuelLevelSensor.h"
#include "DTC_Codes.h"
#include <Arduino.h> // Include Arduino framework

/******************************************************************************
* Global Variable Definitions
*****************************************************************************/

// Define the fuel level sensor pin


const int FUEL_LEVEL_SENSOR_PIN = A0;

// Initialize the fuel level variable


int fuelLevel = 0;

/******************************************************************************
* Function Definitions
*****************************************************************************/

/******************************************************************************
* Name: initializeSensor()
* Description: Simulate sensor initialization function
* Returns: bool - true if initialization is successful, false
otherwise
*****************************************************************************/

// Simulate sensor initialization function


bool initializeSensor() {
// Simulate a successful initialization
// Replace with actual initialization code if available
return true; // Return false to simulate initialization failure
}

/******************************************************************************
* Name: setupFuelLevelSensor()
* Description: Initialize the fuel level sensor
* Arguments: None
* Returns: None
*****************************************************************************/

// Initialize the fuel level sensor


void setupFuelLevelSensor() {
// Attempt to initialize the sensor
// If initialization fails, set a general fault DTC
while (!initializeSensor()) { // Assume initializeSensor() is a function that
initializes the sensor and returns a boolean
Serial.println("DTC Code: P"+String(DTC_FLS_GENERAL_FAULT)); //
DTC_FLS_GENERAL_FAULT
delay(100); // Halt execution if sensor initialization fails
}
}

/******************************************************************************
* Name: checkFuelLevelRange(int fuelLevel)
* Description: Check if the fuel level is within the normal range
* Arguments: int fuelLevel - current fuel level reading
* Returns: None
*****************************************************************************/

// Forward declaration
void checkFuelLevelRange(int fuelLevel);

/******************************************************************************
* Name: checkFuelLevel()
* Description: Check fuel level sensor readings
* Arguments: None
* Returns: None
*****************************************************************************/

// Check fuel level sensor readings


void checkFuelLevel() {
// Read the fuel level from the sensor pin
fuelLevel = analogRead(FUEL_LEVEL_SENSOR_PIN);

// Check for communication failure (e.g., no valid reading)


if (fuelLevel == -1) { // Assuming -1 indicates a failed reading
Serial.println("DTC Code: P"+String(DTC_FLS_COMM_FAILURE)); //
DTC_FLS_COMM_FAILURE
}
// Print the fuel level reading to the Serial Monitor
Serial.print("Fuel Level: ");
Serial.println(fuelLevel);

// Check if the fuel level is within the normal range


checkFuelLevelRange(fuelLevel);
}
// Check if the fuel level is within the normal range
void checkFuelLevelRange(int fuelLevel) {
// Check for various error conditions and set corresponding DTC codes
if (fuelLevel == -1) {
Serial.println("DTC Code: P"+String(DTC_FLS_NOT_RESPONDING)); // Sensor not
responding
}
if (fuelLevel < FUEL_LEVEL_LOW_THRESHOLD) {
Serial.println("DTC Code: P"+String(DTC_FLS_CIRCUIT_VOLTAGE_LOW )); //
Circuit voltage low
} else if (fuelLevel > FUEL_LEVEL_HIGH_THRESHOLD) {
Serial.println("DTC Code: P"+String(DTC_FLS_CIRCUIT_VOLTAGE_HIGH)); //
Circuit voltage high
}
if (fuelLevel == -999) {
Serial.println("DTC Code: P"+String(DTC_FLS_INTERNAL_FAILURE)); // Internal
failure
}
if (fuelLevel < 0) {
Serial.println("DTC Code: P"+String(DTC_FLS_SIGNAL_LOST)); // Signal lost
}
if (fuelLevel < 0 || fuelLevel > 1023) {
Serial.println("DTC Code: P"+String(DTC_FLS_PLAUSIBILITY_FAILURE)); //
Plausibility failure
}
if (fuelLevel == -1000) {
Serial.println("DTC Code: P"+String(DTC_FLS_DATA_INVALID)); // Data invalid
}
if (fuelLevel < 200 || fuelLevel > 3000) {
Serial.println("DTC Code: P"+String(DTC_FLS_CONFIG_ERROR)); // Configuration
error
}
if (fuelLevel < 0 || fuelLevel > 1500) {
Serial.println("DTC Code: P"+String(DTC_FLS_INIT_FAILED)); // Initialization
failed
}
if (fuelLevel == 0) {
Serial.println("DTC Code: P"+String(DTC_FLS_CALIBRATION_ERROR)); //
Calibration error
}
if (fuelLevel > 1100) {
Serial.println("DTC Code: P"+String(DTC_FLS_TEMP_OUT_OF_RANGE)); //
Temperature out of range
}
if (fuelLevel < 500 || fuelLevel > 1500) {
Serial.println("DTC Code: P"+String(DTC_FLS_PRESSURE_OUT_OF_RANGE)); //
Pressure out of range
}
if (fuelLevel > 2300) {
Serial.println("DTC Code: P"+String(DTC_FLS_ACCURACY_FAILURE)); // Accuracy
failure
}
if (fuelLevel == 1000) {
Serial.println("DTC Code: P"+String(DTC_FLS_SELF_TEST_FAILED)); // Self-test
failed
}
if (fuelLevel > 2400) {
Serial.println("DTC Code: P"+String(DTC_FLS_RANGE_CHECK_FAILED)); // Range
check failed
}
if (fuelLevel > 2200) {
Serial.println("DTC Code: P"+String(DTC_FLS_CIRCUIT_VOLTAGE_HIGH)); //
Circuit voltage high
}
if (fuelLevel < 60) {
Serial.println("DTC Code: P"+String(DTC_FLS_CIRCUIT_VOLTAGE_LOW)); // Circuit
voltage low
}
if (fuelLevel == 0) {
Serial.println("DTC Code: P"+String(DTC_FLS_CIRCUIT_SHORT_TO_GROUND)); //
Circuit short to ground
}
}

/******************************** end of main


********************************/
/**************************************************************************** **
* End of File
***************************************************************************** */

Dashboard(UI Interface):

Dashboard.py

# Import necessary libraries and modules


import serial # For serial communication with Arduino
import tkinter as tk # For GUI creation
from tkinter import ttk # For themed widgets
from tkinter import font # For custom font handling
from PIL import Image, ImageTk # For image handling
import random # For generating random values

# Attempt to set up the serial connection to the Arduino


try:
ser = serial.Serial('COM3', 9600, timeout=1) # Replace 'COM3' with the
appropriate serial port on your system
except serial.SerialException as e:
print(f"Error opening serial port: {e}")
exit()

# Function to read data from the Arduino over the serial connection
def read_data():
try:
if ser.in_waiting > 0: # Check if there is incoming data in the serial
buffer
line = ser.readline().decode('utf-8').rstrip() # Read and decode the
line from the serial port
print(f"Received line: {line}") # Print the received data for debugging
purposes
if "Fuel Level:" in line: # Check if the line contains fuel level data
fuel_value = line.split(": ")[1] # Extract the fuel value from the
line
print(f"Parsed Fuel Level Value: {fuel_value}")
update_fuel(fuel_value) # Update the fuel value on the GUI
elif "Temperature:" in line: # Check if the line contains temperature
data
temp_value = line.split(": ")[1] # Extract the temperature value
from the line
print(f"Parsed Temperature Value: {temp_value}")
update_temperature(temp_value) # Update the temperature value on the
GUI
elif "Pressure:" in line: # Check if the line contains pressure data
pressure_value = line.split(": ")[1] # Extract the pressure value
from the line
print(f"Parsed Pressure Value: {pressure_value}")
update_tire_pressures(pressure_value) # Update the tire pressure
values on the GUI
except Exception as e:
print(f"Error reading data: {e}") # Print any errors encountered during data
reading
root.after(READ_INTERVAL, read_data) # Schedule the function to run again after
a specified interval
# Function to update a given label with new text
def update_label(label, new_text):
label.config(text=new_text)

# Function to update the fuel level display


def update_fuel(fuel_value):
update_label(fuel_label_value, fuel_value)

# Function to update the temperature display


def update_temperature(temp_value):
update_label(temp_label_value, temp_value)

# Function to update the tire pressures display


def update_tire_pressures(pressure_value):
update_label(front_left_value, pressure_value)
update_label(front_right_value, pressure_value)
update_label(rear_left_value, pressure_value)
update_label(rear_right_value, pressure_value)

# Function to load an icon image from a file and resize it


def load_icon(file_path, size):
img = Image.open(file_path) # Open the image file
img = img.resize(size, Image.LANCZOS) # Resize the image to the specified size
return ImageTk.PhotoImage(img) # Return the resized image as a PhotoImage object

# Function to resize the background image to fit the window when the window is
resized
def resize_bg(event):
new_width = event.width # Get the new width of the window
new_height = event.height # Get the new height of the window
bg_resized = bg_image.resize((new_width, new_height), Image.LANCZOS) # Resize
the background image
bg_photo_resized = ImageTk.PhotoImage(bg_resized) # Create a PhotoImage object
from the resized image
canvas.create_image(0, 0, image=bg_photo_resized, anchor="nw") # Update the
canvas with the new background image
canvas.bg_image = bg_photo_resized # Keep a reference to the image to prevent
garbage collection

# Set up the main window for the GUI


root = tk.Tk()
root.title("Health Monitoring System")
root.geometry("800x600")

# Load the background image for the GUI


bg_image = Image.open('car.png')
bg_photo = ImageTk.PhotoImage(bg_image)

# Create a canvas to hold the background image


canvas = tk.Canvas(root, width=800, height=600)
canvas.pack(fill="both", expand=True)
canvas.create_image(0, 0, image=bg_photo, anchor="nw")
canvas.bind("<Configure>", resize_bg) # Bind the resize event to the resize_bg
function

# Load icons for the GUI


icons = {
"fuel": load_icon('fuel.png', (50, 50)),
"temperature": load_icon('temp.png', (50, 50)),
"battery": load_icon('battery.png', (50, 50)),
"speed": load_icon('speed.png', (50, 50)),
"tire": load_icon('tire.png', (50, 50))
}

# Define the color scheme for the GUI


BG_COLOR = "#1E1E1E"
FRAME_COLOR = "#333333"
LABEL_COLOR = "#CCCCCC"
VALUE_COLOR = "#00FF7F"
TITLE_COLOR = "#00BFFF"

# Create a frame to hold the sensor data labels and values


mainframe = ttk.Frame(canvas, padding="10", style="MainFrame.TFrame")
mainframe.place(relx=0.5, rely=0.5, anchor=tk.CENTER)

# Configure styles for the GUI elements


style = ttk.Style()
style.configure("TFrame", background=FRAME_COLOR)
style.configure("TLabel", background=FRAME_COLOR, font=("Helvetica", 14),
foreground=LABEL_COLOR)
style.configure("ValueLabel.TLabel", background=FRAME_COLOR, font=("Helvetica", 20,
"bold"), foreground=VALUE_COLOR)
style.configure("MainFrame.TFrame", background=FRAME_COLOR, relief="raised",
borderwidth=5)

# Custom font for the labels


custom_font = font.Font(family="Helvetica", size=20, weight="bold")

# Title label for the GUI


title = ttk.Label(mainframe, text="Real-time Health Monitoring System",
font=("Helvetica", 24, "bold"), foreground=TITLE_COLOR, background=FRAME_COLOR)
title.grid(row=0, column=0, columnspan=6, pady=10)

# Function to create a sensor row with an icon, label, and value


def create_sensor_row(row, column, icon, label_text, frame):
icon_label = ttk.Label(frame, image=icons[icon], background=FRAME_COLOR)
icon_label.grid(row=row, column=column*3, padx=10, pady=10, sticky=tk.W) # Place
the icon label in the grid
text_label = ttk.Label(frame, text=label_text, style="TLabel")
text_label.grid(row=row, column=column*3+1, padx=10, pady=10, sticky=tk.W) #
Place the text label in the grid
value_label = ttk.Label(frame, text="N/A", style="ValueLabel.TLabel")
value_label.grid(row=row, column=column*3+2, padx=10, pady=10, sticky=tk.E) #
Place the value label in the grid
return value_label # Return the value label for later updates

# Create rows for each sensor type in the mainframe


fuel_label_value = create_sensor_row(1, 0, "fuel", "Fuel Level: ", mainframe)
temp_label_value = create_sensor_row(1, 1, "temperature", "Temperature: ", mainframe)
speed_label_value = create_sensor_row(2, 0, "speed", "Speed: ", mainframe)
battery_label_value = create_sensor_row(2, 1, "battery", "Battery: ", mainframe)

# Create a separate frame for the tire pressures


tire_frame = ttk.Frame(mainframe, style="MainFrame.TFrame")
tire_frame.grid(row=4, column=0, columnspan=6, pady=20)

# Function to create a tire pressure row with an icon, label, and value
def create_tire_row(frame, row, column, label_text):
icon_label = ttk.Label(frame, image=icons["tire"], background=FRAME_COLOR)
icon_label.grid(row=row, column=column*3, padx=10, pady=5, sticky=tk.W) # Place
the icon label in the grid
text_label = ttk.Label(frame, text=label_text, style="TLabel")
text_label.grid(row=row, column=column*3+1, padx=10, pady=5, sticky=tk.W) #
Place the text label in the grid
value_label = ttk.Label(frame, text="N/A", style="ValueLabel.TLabel")
value_label.grid(row=row, column=column*3+2, padx=10, pady=5, sticky=tk.E) #
Place the value label in the grid
return value_label # Return the value label for later updates

# Create rows for each tire's pressure in the tire_frame


front_left_value = create_tire_row(tire_frame, 0, 0, "Front Left Tire: ")
front_right_value = create_tire_row(tire_frame, 0, 1, "Front Right Tire: ")
rear_left_value = create_tire_row(tire_frame, 1, 0, "Rear Left Tire: ")
rear_right_value = create_tire_row(tire_frame, 1, 1, "Rear Right Tire: ")
# Function to update battery value with a random percentage
def update_battery():
random_battery = random.randint(0, 100) # Generate a random battery percentage
between 0 and 100
update_label(battery_label_value, f"{random_battery}%") # Update the battery
label with the new value
root.after(BATTERY_UPDATE_INTERVAL, update_battery) # Schedule the function to
run again after a specified interval

# Function to update speed value with a random speed


def update_speed():
random_speed = random.randint(0, 120) # Generate a random speed value between 0
and 120 km/h
update_label(speed_label_value, f"{random_speed} km/h") # Update the speed label
with the new value
root.after(SPEED_UPDATE_INTERVAL, update_speed) # Schedule the function to run
again after a specified interval

# Define constants for the intervals at which the functions are called
READ_INTERVAL = 10 # Interval for reading data from the Arduino (in milliseconds)
BATTERY_UPDATE_INTERVAL = 5000 # Interval for updating the battery value (in
milliseconds)
SPEED_UPDATE_INTERVAL = 3000 # Interval for updating the speed value (in
milliseconds)

# Initial call to start reading data from the Arduino


root.after(READ_INTERVAL, read_data)

# Initial calls to start updating the simulated battery and speed values
root.after(BATTERY_UPDATE_INTERVAL, update_battery)
root.after(SPEED_UPDATE_INTERVAL, update_speed)

# Start the Tkinter GUI event loop


root.mainloop()

#End of the file


Results
The developed vehicle health monitoring system successfully integrates hardware and software components to
provide real-time monitoring of critical vehicle parameters. Below are the detailed results of the
implementation:

1. Engine Temperature Monitoring:


o The system accurately monitors engine temperature using BMP180 sensors.
o The microcontroller processes sensor data to detect overheating conditions promptly.
o Real-time updates on the LCD/OLED display ensure immediate visibility of engine temperature
status.
2. Tire Pressure Monitoring:
o Tire pressure is monitored using BMP180 sensors, ensuring optimal tire performance.
o Deviations from normal pressure levels trigger visual alerts on the display for timely corrective
action.
3. Fuel Level Monitoring:
o The water level sensor effectively monitors fuel levels in the vehicle's tank.
o Updates on the display inform the driver of remaining fuel quantity, prompting refueling when
necessary.
4. Real-time Data Transmission:
o Sensor data is acquired by the STM32 microcontroller and transmitted via I2C protocol.
o The LCD/OLED display updates every second, providing continuous real-time monitoring of
vehicle health parameters.
5. User Interface:
o The display interface presents engine temperature, tire pressure, and fuel level data clearly and
intuitively.
o Visual alerts and warnings on the display ensure that drivers are promptly notified of any
critical issues.

Conclusion
The vehicle health monitoring system developed in this project provides an effective solution for enhancing
vehicle safety and performance through continuous monitoring of essential parameters. By integrating sensors
with the STM32 microcontroller and utilizing an LCD/OLED display, the system delivers real-time feedback to
the driver, facilitating proactive maintenance and ensuring optimal vehicle operation.

Key Outcomes of the Project:

 Enhanced Vehicle Safety: Continuous monitoring of engine temperature, tire pressure, and fuel level
reduces the risk of mechanical failures and enhances driving safety.
 Real-time Monitoring: The system offers immediate updates and alerts, allowing drivers to take timely
actions to address any detected issues.
 User-Friendly Interface: The display interface is designed to be user-friendly, providing clear and
concise information for quick understanding and decision-making.

Overall, the project demonstrates the feasibility and effectiveness of using microcontroller-based systems for
vehicle health monitoring, with potential for further enhancements and integrations in future iterations.
Future Work

1. Adding More Sensors

To expand the system's capabilities and safety features, consider integrating additional sensors:

oEnvironmental Sensors: Incorporate sensors to monitor cabin temperature and humidity,


ensuring driver comfort.
o Proximity Sensors: Detect obstacles around the vehicle to aid in parking and prevent
collisions.
o Battery Health Monitor: Monitor battery voltage and health status to ensure reliable vehicle
operation.
o GPS Module: Integrate GPS for location-based diagnostics and tracking.
2. Improving the Dashboard Interface

Enhance the user interface to provide a more intuitive and informative experience:

oGraphical Representation: Implement graphs and charts to visualize historical data trends for
engine temperature, tire pressure, and fuel level.
o Customizable Alerts: Allow users to set personalized thresholds and alerts for critical
parameters, facilitating proactive maintenance.
o Voice Alerts: Integrate voice notifications to alert drivers about safety issues without
distracting from driving.
o Mobile Application: Develop a mobile app for remote monitoring and control, enabling access
to real-time vehicle health data and alerts.
3. Enhancing Data Processing Algorithms

Refine data processing algorithms to improve accuracy, reliability, and predictive capabilities:

o Machine Learning Integration: Utilize machine learning algorithms to predict vehicle


behavior and driver patterns, enhancing proactive alerting.
o Sensor Fusion: Combine data from multiple sensors to provide a comprehensive assessment of
vehicle health and environmental conditions.
o Noise Reduction: Implement advanced filtering techniques to minimize sensor noise and
ensure accurate data interpretation.
o Real-time Analytics: Enable real-time data analytics to deliver immediate insights and
recommendations for vehicle maintenance and performance optimization.

References

The following resources were utilized during the development of this project:

1. Datasheets and Technical Manuals:


o STM32F411RET6 Microcontroller Datasheet
o BMP180 Sensor Datasheet (Engine Temperature and Tire Pressure)
o Water Level Sensor Datasheet (Fuel Level)
2. Research Papers:
o "Smart Vehicle Health Monitoring System using STM32 Microcontroller" – Journal of
Embedded Systems and Applications
o "Real-time Monitoring of Vehicle Parameters for Enhanced Safety" – International Journal of
Vehicle Electronics
3. Online Resources:
o STM32CubeIDE Documentation
o Arduino IDE Documentation
o I2C Communication Protocol Documentation
o LCD/OLED Display Integration with STM32
o Python Documentation for GUI Development (Tkinter)
o PySerial Documentation for Serial Communication
4. Tutorials and Guides:
o Integrating BMP180 Sensors with STM32 Microcontroller
o Water Level Sensor Integration with STM32 via I2C
o Developing Real-time Monitoring Systems with STM32
o Building User Interfaces for Embedded Systems using Tkinter
5. Technical Articles and Forums:
o Electronics Stack Exchange and STM32 Forums for troubleshooting and community support
o Application Notes and Case Studies on STM32 Microcontroller Applications

You might also like