ENTS-tock
Environmental NeTworked Sensor firmware on Tock OS
Loading...
Searching...
No Matches
main.c
Go to the documentation of this file.
2#include <libtock-sync/services/alarm.h>
3#include <ulog.h>
4
5int main(void) {
6 ulog_info("Example bme280 measurements");
7
8#ifdef BME280_DOUBLE_ENABLE
9 ulog_info("BME280_DOUBLE_ENABLE");
10#endif
11
12#ifdef BME280_64BIT_ENABLE
13 ulog_info("BME280_64BIT_ENABLE");
14#endif
15
16#ifdef BME280_32BIT_ENABLE
17 ulog_info("BME280_32BIT_ENABLE");
18#endif
19
20 BME280Status status = BME280Init();
21 if (status != BME280_STATUS_OK) {
22 ulog_error("Error initializing bme280: %d", status);
23 return -1;
24 }
25
26 while (1) {
27 BME280Data data = {};
28
29 status = BME280MeasureAll(&data);
30 if (status != BME280_STATUS_OK) {
31 ulog_error("Error measuring from bme280: %d", status);
32 continue;
33 }
34
35 printf("p: %ld, t: %ld, h: %ld\n", data.pressure, data.temperature,
36 data.humidity);
37
38 libtocksync_alarm_delay_ms(2000);
39 }
40
41 return 0;
42}
int main()
Definition main.c:4
BME280Status BME280Init(void)
BME280Status BME280MeasureAll(BME280Data *data)
Measures temperature, pressure, and humidity.
Sensor interface for the BME280 sensor.
BME280Status
BME280 error codes.
@ BME280_STATUS_OK
struct bme280_data BME280Data
Struct to store data from sensor.
const char data[]