This is a simple example of how you can use diagnostic requests, which do not require an authentication, to get the information you need. This project displays information about the voltage of each individual cell, as well as the state of charge and battery voltage.
The device is connected to the OBD2 diagnostic connector on the Mazda CX-30 e-Skyactiv-X.
Development Environment:
- CooCox CoIDE Version: 1.7.7
ID | B0 | B1 | B2 | B3 | B4 | B5 | B6 | B7 | Description |
---|---|---|---|---|---|---|---|---|---|
726 | 03 | 22 | C2 | 5B | 00 | 00 | 00 | 00 | Requesting the number of keys |
72E | 04 | 62 | C2 | 5B | 02 | 00 | 00 | 00 | Key number response |
This example demonstrates a diagnostic command following the UDS standard, commonly used in automotive diagnostics. The communication involves a request (ID 726) and a corresponding response (ID 72E).
- Length: 03 bytes (following the control byte).
- SID (Service Identifier): 22 - Indicates a request for reading data.
- DID (Data Identifier): C2 5B - Identifies the data to be read (in this case, C25B).
- Optional Data: 00 00 00 00 - Additional request data (in this example, no extra data).
- Length: 04 bytes.
- Positive Response SID: 62 - Indicates a successful execution of the request.
- DID (Data Identifier): C2 5B - Same data identifier as in the request.
- Data: 02 - Represents the response data (in this case, the number of stored keys).
Component | Name |
---|---|
Microcontroller | STM32F103C8T6 |
Display | SSD1306 I2C 128x64 |
CAN Transceiver | MCP2551-I/SN |
Step-Down Voltage Regulator* | D24V50F5 |
Resistor | R1: 10 kΩ |
Note: The step-Down Voltage Regulator D24V50F5 regulator is a relatively expensive option but offers comprehensive protection features. For a more cost-effective solution, consider the S13V10F5. The S13V30F5 is an advanced version with reverse voltage protection up to 20V.
STM32F103C8T6 | SSD1306 | MCP2551 | Resistor | Voltage Regulator | OBD2 |
---|---|---|---|---|---|
5V | VDD | VOUT | |||
3.3V | VCC | ||||
GND | GND | VSS | R1 | GND | 4-5 |
B6 | SLC | ||||
B7 | SDA | ||||
B11 | RXD | ||||
B12 | TXD | ||||
RS | R1 | ||||
CANH | 6 | ||||
CANL | 14 | ||||
VIN | 16 |
The SSD1306 display driver files used in this project were originally authored by Tilen Majerle. Alexander Lutsai has made modifications specifically for STM32f10x.
The SSD1306 display driver files are distributed under the terms of the GNU General Public License as published by the Free Software Foundation. The full text of the license can be found here.