Boss lady
Boss lady
DIIDevHeads IoT Integration Server
Created by Boss lady on 9/27/2024 in #firmware-and-baremetal
Resolving Device Not Found Error for PIR Sensor on ESP32 with Zephyr RTOS
Am working on a a home automation system that controls water pumps and taps based on motion detection using the Zephyr RTOS on an ESP32 microcontroller, how can i properly detect motion using a PIR (Passive Infrared) sensor with the ESP32? this is what i have tried
include <zephyr.h>
include <device.h>
include <drivers/gpio.h>

define PIR_SENSOR_PIN 23

void main(void) {
const struct device pir_device = device_get_binding(DT_LABEL(DT_NODELABEL(gpio)));
gpio_pin_configure(pir_device, PIR_SENSOR_PIN, GPIO_INPUT);

while (1) {
if (gpio_pin_get(pir_device, PIR_SENSOR_PIN)) {
// Motion detected
printk("Motion Detected!\n");
}
k_sleep(K_MSEC(500));
}
}
include <zephyr.h>
include <device.h>
include <drivers/gpio.h>

define PIR_SENSOR_PIN 23

void main(void) {
const struct device pir_device = device_get_binding(DT_LABEL(DT_NODELABEL(gpio)));
gpio_pin_configure(pir_device, PIR_SENSOR_PIN, GPIO_INPUT);

while (1) {
if (gpio_pin_get(pir_device, PIR_SENSOR_PIN)) {
// Motion detected
printk("Motion Detected!\n");
}
k_sleep(K_MSEC(500));
}
}
But am getting the error Device not found, how can i properly resolve this
3 replies