https://github.com/frytg/sensory
ESP32 test project with sensors and Embedded Rust
https://github.com/frytg/sensory
embedded-rust esp32 esp32c6 rust
Last synced: 4 months ago
JSON representation
ESP32 test project with sensors and Embedded Rust
- Host: GitHub
- URL: https://github.com/frytg/sensory
- Owner: frytg
- License: mit
- Created: 2025-05-02T08:26:27.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-09-07T15:29:14.000Z (10 months ago)
- Last Synced: 2025-09-07T17:33:49.799Z (10 months ago)
- Topics: embedded-rust, esp32, esp32c6, rust
- Language: Rust
- Homepage:
- Size: 97.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Sensory Firmware
This is the firmware for an ESP32 microcontroller written in Embedded Rust. It connects to sensor(s) and sends data to a local server.
For the most part this was a learning exercise for me to get more familiar with Embedded Rust and the ESP32 microcontroller. I have several sensors using this setup running at home.
## ESP32
This is currently setup to run on the ESP32-C6 microcontroller. I am using the [NanoC6 Dev Kit](https://shop.m5stack.com/products/m5stack-nanoc6-dev-kit) from M5Stack, which is useful dev board with a tiny footprint, LED, USB-C, and a few other features.
The primary sensor is the [SCD40](https://sensirion.com/products/catalog/SCD40) from Sensirion, which also has a useful [M5Stack board](https://shop.m5stack.com/products/co2-unit-with-temperature-and-humidity-sensor-scd40) that can be connected to the ESP32-C6 via the M5Stack grove/ JST connector. It communicates over I2C.
## Running the firmware
You will need to have the [`just`](https://github.com/casey/just) and [`sops`](https://github.com/getsops/sops) commands installed. It will use `.env.sops.yaml` or whatever is configured in the `SOPS_ENV_FILE` environment variable.
Run directly on the ESP32 microcontroller:
```bash
just run scd40
```
Build for release:
```bash
just release scd40
```
Flash to the ESP32 microcontroller:
```bash
just flash scd40
```
## Kudos
This project uses snippets and was inspired by projects and their examples like [`esp-rs/esp-hal`](https://github.com/esp-rs/esp-hal).
## Server Endpoint
The server endpoint is a simple HTTP server that accepts POST requests with JSON data.
```bash
curl -X POST http://localhost:8081/sensor/intake \
-H "Content-Type: application/json" \
-d '{"serial":111111111111111,"mac":"11:11:11:11:11:11","cycle":1,"co2":555,"temperature":22.48188,"humidity":48.8426}'
```
```json
{
"serial": 111111111111111,
"mac": "11:11:11:11:11:11",
"cycle": 1,
"co2": 555,
"temperature": 22.48188,
"humidity": 48.8426
}
```
## Docs
- `embassy`: [embassy.dev](https://embassy.dev) / [embassy.dev/book](https://embassy.dev/book/)
- `esp-rs` docs overview [docs.espressif.com/projects/rust/](https://docs.espressif.com/projects/rust/)
- `esp-hal` [docs.espressif.com/projects/rust/esp-hal/1.0.0-beta.0](https://docs.espressif.com/projects/rust/esp-hal/1.0.0-beta.0/index.html)
- ESP32-C6: [docs.espressif.com/projects/rust/esp-hal/1.0.0-beta.0/esp32c6/esp_hal](https://docs.espressif.com/projects/rust/esp-hal/1.0.0-beta.0/esp32c6/esp_hal/index.html)
- `esp-wifi` [docs.espressif.com/projects/rust/esp-wifi/0.13.0](https://docs.espressif.com/projects/rust/esp-wifi/0.13.0/index.html)
- ESP32-C6: [docs.espressif.com/projects/rust/esp-wifi/0.13.0/esp32c6/esp_wifi](https://docs.espressif.com/projects/rust/esp-wifi/0.13.0/esp32c6/esp_wifi/index.html)
- `scd4x` [docs.rs/scd4x/0.4.0/scd4x/](https://docs.rs/scd4x/0.4.0/scd4x/) / [github.com/hauju/scd4x-rs](https://github.com/hauju/scd4x-rs)
- `smoltcp` [docs.rs/smoltcp/latest/smoltcp/index.html](https://docs.rs/smoltcp/latest/smoltcp/index.html)
- M5Stack NanoC6: [docs.m5stack.com/en/core/M5NanoC6](https://docs.m5stack.com/en/core/M5NanoC6)
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.