Skip to content

HTTP Based API's for common sensors to simplify interfacing with the sensors

Notifications You must be signed in to change notification settings

Zalgar/sensor-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sensor API

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.

Project Structure

.gitignore
bme280/
    Cargo.lock
    Cargo.toml
    src/
        main.rs
    target/
pmsa003i/
    Cargo.lock
    Cargo.toml
    src/
        main.rs
    target/
README.md

BME280 Sensor Application

The BME280 application reads temperature, humidity, pressure, and altitude data from a BME280 sensor.

How to Run

  1. Navigate to the bme280 directory:

  2. Navigate to the bme280 directory:

    cd bme280
  3. Build the project:

    cargo build
  4. Run the project:

    cargo run

API Endpoint

  • GET /sensor_data: Returns the sensor data in JSON format.

Example Response

{
    "timestamp": "2023-10-01T12:00:00Z",
    "model": "BME280",
    "temperature": 25.0,
    "humidity": 40.0,
    "pressure": 1013.25,
    "altitude": 100.0
}

PMSA003I Sensor Application

The PMSA003I application reads particulate matter concentrations (PM1.0, PM2.5, PM10) from a PMSA003I sensor.

How to Run

  1. Navigate to the pmsa003i directory:

    cd pmsa003i
  2. Build the project:

    cargo build
  3. Run the project:

    cargo run

API Endpoint

  • GET /sensor_data: Returns the sensor data in JSON format.

Example Response

{
    "timestamp": "2023-10-01T12:00:00Z",
    "model": "PMSA003I",
    "pm1_0": 10,
    "pm2_5": 20,
    "pm10": 30
}

Common Dependencies

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.

About

HTTP Based API's for common sensors to simplify interfacing with the sensors

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages