33 lines
775 B
C++
33 lines
775 B
C++
#include "bme280.h"
|
|
#include "hardware/i2c.h"
|
|
#include "pico/cyw43_arch.h"
|
|
#include "pico/stdlib.h"
|
|
#include <cstdio>
|
|
|
|
constexpr int i2cAddress{0x76};
|
|
|
|
int main() {
|
|
stdio_init_all();
|
|
sleep_ms(3000);
|
|
cyw43_arch_init();
|
|
|
|
bme280_handle_t handle;
|
|
int result{bme280_init(&handle, i2cAddress, INTERVAL_1000MS)};
|
|
printf("I2C scan...\n");
|
|
for (uint8_t addr = 0x08; addr < 0x78; addr++) {
|
|
uint8_t dummy;
|
|
int ret = i2c_read_blocking(i2c1, addr, &dummy, 1, false);
|
|
if (ret >= 0) {
|
|
printf("Gefunden: 0x%02X\n", addr);
|
|
}
|
|
}
|
|
|
|
while (true) {
|
|
int result{bme280_init(&handle, i2cAddress, INTERVAL_1000MS)};
|
|
printf("Init result: %d\n", result);
|
|
bme280_read_data(handle);
|
|
printf("%s\n", bme280_get_json(handle));
|
|
sleep_ms(3000);
|
|
}
|
|
}
|