Boss lady
Boss lady
DIIDevHeads IoT Integration Server
Created by Boss lady on 9/27/2024 in #middleware-and-os
Issue with Simultaneous Activation of Multiple Relays in Zephyr RTOS 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. I added more relay modules for each tap so i can control multiple taps based on the same motion detection But the Multiple relays not activating simultaneously how can i resolve this.
define TAP1_PIN 25
define TAP2_PIN 26

void main(void) {
gpio_pin_configure(relay_device, TAP1_PIN, GPIO_OUTPUT);
gpio_pin_configure(relay_device, TAP2_PIN, GPIO_OUTPUT);

while (1) {
if (gpio_pin_get(pir_device, PIR_SENSOR_PIN)) {
gpio_pin_set(relay_device, TAP1_PIN, 1);
gpio_pin_set(relay_device, TAP2_PIN, 1);
k_sleep(K_SECONDS(5)); // Taps run for 5 seconds
gpio_pin_set(relay_device, TAP1_PIN, 0);
gpio_pin_set(relay_device, TAP2_PIN, 0);
}
k_sleep(K_MSEC(500));
}
}
define TAP1_PIN 25
define TAP2_PIN 26

void main(void) {
gpio_pin_configure(relay_device, TAP1_PIN, GPIO_OUTPUT);
gpio_pin_configure(relay_device, TAP2_PIN, GPIO_OUTPUT);

while (1) {
if (gpio_pin_get(pir_device, PIR_SENSOR_PIN)) {
gpio_pin_set(relay_device, TAP1_PIN, 1);
gpio_pin_set(relay_device, TAP2_PIN, 1);
k_sleep(K_SECONDS(5)); // Taps run for 5 seconds
gpio_pin_set(relay_device, TAP1_PIN, 0);
gpio_pin_set(relay_device, TAP2_PIN, 0);
}
k_sleep(K_MSEC(500));
}
}
2 replies