Two switches in one node
-
- Posts: 2
- Joined: Tue Dec 14, 2021 8:38 pm
Two switches in one node
I'm new to ESP-IDF would like to know how to add two keys on a single node, if anyone can share the files it would be a great help.
-
- Posts: 309
- Joined: Wed Feb 20, 2019 7:02 am
Re: Two switches in one node
Hello,
If you want to create a single device with 2 controlled GPIOs, please refer to the GPIO Example
If you want to create 2 virtual switch devices in a single node, please refer to the Multi Device Example. The multi device example has 1 switch, 1 fan, 1 light and 1 temperature sensor on the same node. You can use similar logic to have 2 switches.
If you want help with configuring 2 buttons to control 2 switches, you can use the below snippet for reference, which is similar to what we have in the example here.
If you want to create a single device with 2 controlled GPIOs, please refer to the GPIO Example
If you want to create 2 virtual switch devices in a single node, please refer to the Multi Device Example. The multi device example has 1 switch, 1 fan, 1 light and 1 temperature sensor on the same node. You can use similar logic to have 2 switches.
If you want help with configuring 2 buttons to control 2 switches, you can use the below snippet for reference, which is similar to what we have in the example here.
Code: Select all
button_handle_t btn_handle = iot_button_create(BUTTON_GPIO, BUTTON_ACTIVE_LEVEL);
if (btn_handle) {
/* Register a callback for a button tap (short press) event */
iot_button_set_evt_cb(btn_handle, BUTTON_CB_TAP, push_btn_cb, NULL);
}
-
- Posts: 2
- Joined: Tue Dec 14, 2021 8:38 pm
Re: Two switches in one node
Reading a thread I found an example with 4 switch, now I know the changes I need to make to get what I need.Thanks
Re: Two switches in one node
Hi Lucas, I am having this problem, do you mind sharing the solution or posting/sending me a link of that thread with the 4 switches? Thankslucasdalmarco wrote: ↑Wed Dec 15, 2021 8:28 pmReading a thread I found an example with 4 switch, now I know the changes I need to make to get what I need.Thanks
Who is online
Users browsing this forum: No registered users and 56 guests