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));
}
}
1 Reply
melta101
melta1013mo ago
From the snippet, it looks sequential, When you mean simultaneously, To what degree do you want?(exactly at the same time or nearly same, cant distinguish from human eye) Could you maybe Log, during the activation, Add timestamps to help find how much time is it taking between each GPIO_set function call
Want results from more Discord servers?
Add your server