Two switches in one node

lucasdalmarco
Posts: 2
Joined: Tue Dec 14, 2021 8:38 pm

Two switches in one node

Postby lucasdalmarco » Tue Dec 14, 2021 11:44 pm

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.

ESP_Piyush
Posts: 309
Joined: Wed Feb 20, 2019 7:02 am

Re: Two switches in one node

Postby ESP_Piyush » Wed Dec 15, 2021 5:26 pm

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.

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);
    }

lucasdalmarco
Posts: 2
Joined: Tue Dec 14, 2021 8:38 pm

Re: Two switches in one node

Postby lucasdalmarco » Wed Dec 15, 2021 8:28 pm

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

d9lan_
Posts: 1
Joined: Sat Feb 26, 2022 4:41 am

Re: Two switches in one node

Postby d9lan_ » Sat Feb 26, 2022 5:19 am

lucasdalmarco wrote:
Wed Dec 15, 2021 8:28 pm
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
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? Thanks

Who is online

Users browsing this forum: No registered users and 6 guests