Become a leader in the IoT community!
Join our community of embedded and IoT practitioners to contribute experience, learn new skills and collaborate with other developers with complementary skillsets.
Join our community of embedded and IoT practitioners to contribute experience, learn new skills and collaborate with other developers with complementary skillsets.
Still based on my project on home automation system that controls water pumps and taps based on motion detection using the Zephyr RTOS on an ESP32. How can i properly control a water pump based on motion detection from the PIR sensor?
Am hving an issue where my relay is not activating, i have tried checking the relay wiring, tested the relay with a simple `on/off` code and verified power supply to the relay module. But still have same issues
here’s my code
define RELAY_PIN 22
void main(void) {
const struct device relay_device = device_get_binding(DT_LABEL(DT_NODELABEL(gpio)));
gpio_pin_configure(relay_device, RELAY_PIN, GPIO_OUTPUT);
while (1) {
if (gpio_pin_get(pir_device, PIR_SENSOR_PIN)) {
gpio_pin_set(relay_device, RELAY_PIN, 1);
k_sleep(K_SECONDS(10)); // Pump runs for 10 seconds
gpio_pin_set(relay_device, RELAY_PIN, 0);
}
k_sleep(K_MSEC(500));
}
}
CONTRIBUTE TO THIS THREAD