Skip to content

mazen-daghari/Sport-car-Dashboard

Repository files navigation

Sport-car-Dashboard

Here's a detailed tutorial on how to implement a project that retrieves, processes, and visualizes real-time vehicle data using the CAN protocol, Nextion, Arduino, Altium Design, and OBD-II.

How to start?

Step 1: Data Retrieval

Objective: Acquire real-time key information from a vehicle (speed, engine RPM, coolant temperature) via the CAN protocol.

Materials Needed: OBD-II to USB adapter

Arduino board (e.g., Arduino Uno)

CAN Bus shield for Arduino

OBD-II cable

Vehicle with OBD-II port

Steps: Set Up the Hardware:

Connect the CAN Bus shield to the Arduino board.

Connect the OBD-II cable to the vehicle's OBD-II port and the other end to the CAN Bus shield.

Install Required Libraries:

Install the necessary libraries for CAN communication in the Arduino IDE. You can use the MCP_CAN library.

Write the Arduino Code:

Write a sketch to initialize the CAN Bus and read data from the vehicle. Here's a basic example:

cpp #include <mcp_can.h> #include <SPI.h>

const int SPI_CS_PIN = 10; MCP_CAN CAN(SPI_CS_PIN);

void setup() { Serial.begin(115200); if (CAN.begin(MCP_ANY, CAN_500KBPS, MCP_8MHZ) == CAN_OK) { Serial.println("CAN Bus Initialized"); } else { Serial.println("CAN Bus Initialization Failed"); while (1); } CAN.setMode(MCP_NORMAL); }

void loop() { if (CAN_MSGAVAIL == CAN.checkReceive()) { CAN.readMsgBuf(&len, buf); unsigned long canId = CAN.getCanId(); Serial.print("ID: "); Serial.print(canId, HEX); Serial.print(" Data: "); for (int i = 0; i < len; i++) { Serial.print(buf[i], HEX); Serial.print(" "); } Serial.println(); } } Upload the Code:

Upload the code to the Arduino board and open the Serial Monitor to see the real-time data being retrieved from the vehicle.

-Step 2: Data Processing

Objective: Process the received data to make it usable.

Steps: Parse the Data:

Modify the Arduino code to parse the CAN messages and extract specific information such as speed, engine RPM, and coolant temperature.

Convert Units:

Convert the raw data into human-readable units. For example, convert speed from km/h to mph if needed.

Filter the Data:

Implement filtering algorithms to smooth out the data and remove any noise.

-Step 3: Visualization

Objective: Display the data clearly and intuitively on a graphical interface.

Materials Needed: Nextion display

Arduino board

Steps: Set Up the Hardware:

Connect the Nextion display to the Arduino board using the appropriate pins (e.g., TX, RX, VCC, GND). image image Design the Interface:

Use the Nextion Editor to design the graphical interface. Create elements such as gauges, text fields, and buttons to display the data.

image

image

image

Write the Arduino Code:

Modify the Arduino code to send the processed data to the Nextion display. Here's an example:

cpp #include <Nextion.h>

NexText speedText = NexText(0, 1, "speed"); NexText rpmText = NexText(0, 2, "rpm"); NexText tempText = NexText(0, 3, "temp");

void setup() { nexInit(); // Initialize CAN Bus and other setup code }

void loop() { // Read and process CAN data String speed = String(parsedSpeed); String rpm = String(parsedRPM); String temp = String(parsedTemp);

speedText.setText(speed.c_str()); rpmText.setText(rpm.c_str()); tempText.setText(temp.c_str()); }

Upload the Code:

Upload the code to the Arduino board and observe the data being displayed on the Nextion screen.

Technologies Used CAN: Controller Area Network protocol for vehicle communication.

Nextion: Display for graphical interface.

Arduino: Microcontroller for data acquisition and processing.

Altium Design: Software for designing custom PCBs if needed.

OBD-II: On-Board Diagnostics standard for vehicle data retrieval.

By following these steps, you can successfully implement a project that retrieves, processes, and visualizes real-time vehicle data using the CAN protocol and various technologies.

for further questions mail me on:dagmazen@gmail.com

Licence()

Releases

No releases published

Packages

No packages published