Boss lady
Boss lady
DIIDevHeads IoT Integration Server
Created by Boss lady on 9/27/2024 in #firmware-and-baremetal
Troubleshooting Relay Activation for Water Pump Control Based on PIR Sensor Detection on ESP32
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));
}
}
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));
}
}
1 replies