balcony_weather_station/bme280.h

44 lines
872 B
C

#ifndef BME280_H
#define BME280_H
#include "hardware/i2c.h"
typedef struct {
// temperature params
uint16_t dig_t1;
int16_t dig_t2;
int16_t dig_t3;
// pressure params
uint16_t dig_p1;
int16_t dig_p2;
int16_t dig_p3;
int16_t dig_p4;
int16_t dig_p5;
int16_t dig_p6;
int16_t dig_p7;
int16_t dig_p8;
int16_t dig_p9;
// humidity params
uint16_t dig_h1;
int16_t dig_h2;
int16_t dig_h3;
int16_t dig_h4;
int16_t dig_h5;
} bme280_compensation_params;
typedef struct {
i2c_inst_t *i2c;
bme280_compensation_params params;
} bme280_config;
typedef struct {
float temperature;
int32_t pressure;
int32_t humidity;
} bme280_reading;
void bme280_init(bme280_config *config, i2c_inst_t *i2c,
uint8_t sda_pin, uint8_t scl_pin);
bme280_reading bme280_read(bme280_config *config);
#endif /* BME280_H */