An open API service indexing awesome lists of open source software.

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.

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.

[![Platform](https://img.shields.io/badge/platform-STM32-blue.svg)]()
[![Interface](https://img.shields.io/badge/interface-CAN%2FUART-green.svg)]()
[![Status](https://img.shields.io/badge/status-Stable-brightgreen.svg)]()
[![License](https://img.shields.io/badge/license-CC0--1.0-lightgrey.svg)]()
[![Build](https://img.shields.io/badge/build-passing-brightgreen.svg)]()
[![Version](https://img.shields.io/badge/version-1.0.0-blue.svg)]()

## ๐Ÿš€ 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!