This project contains two Rust applications for reading sensor data from BME280 and PMSA003I sensors using the I2C bus and exposing the data through a web API using Actix-web.
.gitignore
bme280/
Cargo.lock
Cargo.toml
src/
main.rs
target/
pmsa003i/
Cargo.lock
Cargo.toml
src/
main.rs
target/
README.md
The BME280 application reads temperature, humidity, pressure, and altitude data from a BME280 sensor.
-
Navigate to the bme280 directory:
-
Navigate to the bme280 directory:
cd bme280
-
Build the project:
cargo build
-
Run the project:
cargo run
- GET /sensor_data: Returns the sensor data in JSON format.
{
"timestamp": "2023-10-01T12:00:00Z",
"model": "BME280",
"temperature": 25.0,
"humidity": 40.0,
"pressure": 1013.25,
"altitude": 100.0
}
The PMSA003I application reads particulate matter concentrations (PM1.0, PM2.5, PM10) from a PMSA003I sensor.
-
Navigate to the pmsa003i directory:
cd pmsa003i
-
Build the project:
cargo build
-
Run the project:
cargo run
- GET /sensor_data: Returns the sensor data in JSON format.
{
"timestamp": "2023-10-01T12:00:00Z",
"model": "PMSA003I",
"pm1_0": 10,
"pm2_5": 20,
"pm10": 30
}
Both applications use the following common dependencies:
actix-web
: For building the web server and handling HTTP requests.- linux_embedded_hal: For hardware abstraction layer (HAL) implementations.
- serde: For serializing and deserializing data.
- chrono: For handling date and time.