Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Read data from a sensor and print values periodically.
#include <zephyr.h>
#include <device.h>
#include <drivers/sensor.h>
void main(void)
{
struct device *dev = device_get_binding("SENSOR_0");
struct sensor_value val;
while(1) {
sensor_sample_fetch(dev);
sensor_channel_get(dev, SENSOR_CHAN_ALL, &val);
printk("Sensor value: %d\n", val.val1);
k_sleep(K_SECONDS(2));
}
}Zephyr RTOS is a scalable, open-source real-time operating system designed for resource-constrained embedded devices. It provides a small, configurable kernel, drivers, and networking stacks to enable IoT, wearable, and sensor-based applications with predictable timing and low memory footprint.
Origin & Creator
Initially developed by Wind River and now governed by the Linux Foundation, Zephyr was created to provide a lightweight, open-source RTOS for embedded devices and IoT applications.
Industrial Note
Critical for embedded developers who require a deterministic, low-memory RTOS for safety-critical, battery-powered, or connected devices, enabling rapid development and robust device behavior.