https://github.com/styriaelectronics/can_accelerometer_logger
STM32 data-logger: captures 3-axis ADXL345 acceleration (1 kHz / 1 s buffer) and streams it over UART & CAN-FD.
https://github.com/styriaelectronics/can_accelerometer_logger
accelerometer adxl345 can-bus data-logger stm32
Last synced: 7 months ago
JSON representation
STM32 data-logger: captures 3-axis ADXL345 acceleration (1 kHz / 1 s buffer) and streams it over UART & CAN-FD.
- Host: GitHub
- URL: https://github.com/styriaelectronics/can_accelerometer_logger
- Owner: StyriaElectronics
- License: cc0-1.0
- Created: 2025-04-18T07:56:17.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-05-04T09:36:15.000Z (8 months ago)
- Last Synced: 2025-05-19T19:21:19.824Z (8 months ago)
- Topics: accelerometer, adxl345, can-bus, data-logger, stm32
- Language: C
- Homepage: https://styria-electronics.at
- Size: 767 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ๐ฆ CAN Accelerometer Logger
is a small STM32-based project that reads 3-axis acceleration data from an ADXL345 sensor, buffers it for 1 second at 1โฏkHz, and then transmits it via UART and CAN bus. Perfect for capturing impact or vibration events in embedded systems.
[]()
[]()
[]()
[]()
[]()
[]()
## ๐ Features
- ๐งญ 3-axis accelerometer data from ADXL345 via SPI
- โฑ๏ธ 1000 samples per second (1โฏkHz), total 1000 samples in buffer
- ๐ข Trigger signal via GPIO (rising edge)
- ๐พ Data is buffered in RAM, sent after acquisition
- ๐ค Data output via UART and optionally via CAN
- ๐ฆ CAN data transmission in chunks with custom protocol
- ๐งช Simple and compact C code, ideal for lab testing or automotive debug setups
## โ๏ธ Requirements
STM32 microcontroller with:
- SPI (ADXL345)
- UART (for output)
- GPIO (for trigger input)
- CAN (for data transmission)
- ADXL345 accelerometer (3.3โฏV logic)
- STM32CubeMX / STM32CubeIDE (for initial setup)
## ๐ Wiring
| Signal | STM32 Pin | ADXL345 |
|--------------|------------|----------------|
| SPI MOSI | e.g. PA7 | SDI |
| SPI MISO | e.g. PA6 | SDO |
| SPI SCK | e.g. PA5 | SCL |
| SPI CS | e.g. PB0 | CS |
| Trigger Input| e.g. PA8 | (external source) |
| UART TX | e.g. PA9 | (debug terminal) |
| CAN TX / RX | any FDCAN-capable pins |
## ๐งช Example Workflow
1. **Boot**
2. **Wait** for trigger (PA8 โ)
3. **Acquire** 1000 XYZ samples (1 ms cadence)
4. **Transmit**
- UART: CSV line per sample
- CAN FD: Header + chunked payload โ CRC-8 terminator
---
## ๐ฌ CAN Protocol Overview
| Frame | CAN ID | DLC | Payload |
|-------|--------|-----|---------|
| **Request** | `0x123` | 1 | `0xAB` (host โ logger) |
| **Header** | `0x321` | 3 | `LEN_H`, `LEN_L`, `CHUNK_CNT` |
| **Payload** | `0x322` โฆ `0x32F` | up to 64 | Raw data bytes (XYZ buffer) |
| **CRC** | `0x330` | 1 | CRC-8 (XOR of `LEN` + payload) |
- **LEN** = 2000 bytes (1000 samples ร 2 bytes per axis)
- **CHUNK_CNT** = ceil(LEN / 64)
- CRC is calculated after the final payload frame and sent in its own frame.
> *Default bitrate:* 500 kbit/s nominal.
## ๐ Folder Structure
```
CAN_Accelerometer_Logger/
โโโ Core/
โ โโโ Src/
โ โโโ Inc/
โโโ Drivers/
โโโ .gitignore
โโโ README.md
โโโ LICENSE (CC0-1.0)
```
## ๐ License
This project is licensed under **CC0 1.0 Universal (Public Domain Dedication)**. You can use it freely without attribution โ though a โญ on GitHub is always appreciated :)
## โ ๏ธ Disclaimer
This project is provided "as is" without warranty of any kind, either expressed or implied.
In no event shall the author(s) be liable for any claim, damages, or other liability arising from, out of, or in connection with the use or other dealings in this project.
## โจ Credits
Made with โค๏ธ by **Styria Electronics** for high-performance embedded data acquisition over CAN bus.
๐ ๏ธ Contributions welcome!