43 lines
999 B
C
43 lines
999 B
C
#ifndef SCD30_H
|
|
#define SCD30_H
|
|
|
|
#include <stdint.h>
|
|
#include "driver/i2c.h"
|
|
|
|
// Data structure to hold SCD30 sensor data
|
|
typedef struct {
|
|
float co2; // CO2 concentration in ppm
|
|
float temp; // Temperature in degrees Celsius
|
|
float humidity; // Relative humidity in percentage
|
|
} scd30_data_t;
|
|
|
|
typedef struct {
|
|
i2c_port_t i2c_port;
|
|
} scd30_handle_t;
|
|
|
|
/**
|
|
* @brief Initialize the SCD30 sensor
|
|
*
|
|
* @param sda_gpio SDA GPIO number
|
|
* @param scl_gpio SCL GPIO number
|
|
* @return scd30_handle_t* Pointer to the sensor handle
|
|
*/
|
|
scd30_handle_t *scd30_init(int sda_gpio, int scl_gpio);
|
|
|
|
/**
|
|
* @brief Start continuous measurement
|
|
*
|
|
* @param handle Sensor handle
|
|
*/
|
|
void scd30_start_measurement(scd30_handle_t *handle);
|
|
|
|
/**
|
|
* @brief Read data from the SCD30 sensor
|
|
*
|
|
* @param handle Sensor handle
|
|
* @param data Pointer to store the read data
|
|
* @return int 0 on success, -1 on error
|
|
*/
|
|
int scd30_read_data(scd30_handle_t *handle, scd30_data_t *data);
|
|
|
|
#endif // SCD30_H
|