2021-05-11 16:31:38 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "pico/stdlib.h"
|
|
|
|
|
|
|
|
#include "bme68x.hpp"
|
|
|
|
#include "common/pimoroni_i2c.hpp"
|
|
|
|
|
|
|
|
/*
|
|
|
|
Read a single reading from the BME688
|
|
|
|
*/
|
|
|
|
|
|
|
|
using namespace pimoroni;
|
|
|
|
|
|
|
|
I2C i2c(BOARD::BREAKOUT_GARDEN);
|
2021-05-21 10:14:41 +00:00
|
|
|
BME68X bme68x(&i2c);
|
2021-05-11 16:31:38 +00:00
|
|
|
|
|
|
|
int main() {
|
2023-01-26 15:11:57 +00:00
|
|
|
#ifdef PICO_DEFAULT_LED_PIN
|
2021-05-11 16:31:38 +00:00
|
|
|
gpio_init(PICO_DEFAULT_LED_PIN);
|
|
|
|
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
2023-01-26 15:11:57 +00:00
|
|
|
#endif
|
2021-05-11 16:31:38 +00:00
|
|
|
|
|
|
|
stdio_init_all();
|
|
|
|
|
|
|
|
bme68x.init();
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
sleep_ms(1000);
|
|
|
|
auto time_abs = get_absolute_time();
|
|
|
|
auto time_ms = to_ms_since_boot(time_abs);
|
|
|
|
|
|
|
|
bme68x_data data;
|
|
|
|
|
|
|
|
auto result = bme68x.read_forced(&data);
|
|
|
|
(void)result;
|
|
|
|
|
|
|
|
printf("%lu, %.2f, %.2f, %.2f, %.2f, 0x%x, %d, %d\n",
|
|
|
|
(long unsigned int)time_ms,
|
|
|
|
data.temperature,
|
|
|
|
data.pressure,
|
|
|
|
data.humidity,
|
|
|
|
data.gas_resistance,
|
|
|
|
data.status,
|
|
|
|
data.gas_index,
|
|
|
|
data.meas_index);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|