2021-05-14 12:39:46 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "pico/stdlib.h"
|
|
|
|
|
|
|
|
#include "bme280.hpp"
|
|
|
|
#include "common/pimoroni_i2c.hpp"
|
|
|
|
|
|
|
|
using namespace pimoroni;
|
|
|
|
|
|
|
|
I2C i2c(BOARD::BREAKOUT_GARDEN);
|
|
|
|
BME280 bme280(&i2c);
|
|
|
|
|
|
|
|
|
|
|
|
int main() {
|
2023-01-26 15:11:57 +00:00
|
|
|
#ifdef PICO_DEFAULT_LED_PIN
|
2021-05-14 12:39:46 +01: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-14 12:39:46 +01:00
|
|
|
|
|
|
|
stdio_init_all();
|
|
|
|
|
|
|
|
if(!bme280.init()) {
|
|
|
|
printf("Failed to init bme280!\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
BME280::bme280_reading result = bme280.read_forced();
|
|
|
|
printf("%s %0.2lf deg C, %0.2lf hPa, %0.2lf%%\n", result.status == BME280_OK ? "OK" : "ER", result.temperature, result.pressure, result.humidity);
|
|
|
|
sleep_ms(1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|