| /* |
| * Copyright (c) 2012-2014 Wind River Systems, Inc. |
| * |
| * SPDX-License-Identifier: Apache-2.0 |
| */ |
| |
| #include <zephyr.h> |
| #include <device.h> |
| #include <sensor.h> |
| #include <stdio.h> |
| |
| void main(void) |
| { |
| struct device *dev = device_get_binding("BME280"); |
| |
| printf("dev %p name %s\n", dev, dev->config->name); |
| |
| while (1) { |
| struct sensor_value temp, press, humidity; |
| |
| sensor_sample_fetch(dev); |
| sensor_channel_get(dev, SENSOR_CHAN_TEMP, &temp); |
| sensor_channel_get(dev, SENSOR_CHAN_PRESS, &press); |
| sensor_channel_get(dev, SENSOR_CHAN_HUMIDITY, &humidity); |
| |
| printf("temp: %d.%06d; press: %d.%06d; humidity: %d.%06d\n", |
| temp.val1, temp.val2, press.val1, press.val2, |
| humidity.val1, humidity.val2); |
| |
| k_sleep(1000); |
| } |
| } |