Hi, I have connected an ESP32 via MQTT to Ubidots. I have configured a switch button to switch a relay on and off. Is there any possibility to change the state of the switch by software, ie the ESP32 client?
Example could be a door buzzer that would unlock a door until the door is opened by somebody. Alternatively this could be implemented by a timed “open” signal to the buzzer (eg for 5 seconds). However, I understand from posts here on the forum (2 years ago) that a timed change does not work yet with Ubidots.
Hello @ollip,
If I understood you correctly, you’d like to have Ubidots send to the ESP32 a signal after 5 seconds of manually changing the state of the buzzer or doing it from Ubidots? For example, you manually press the switch button, or you press a button within Ubidots and that will open the buzzer, and then you’d like for it to automatically turn off the relay after 5 seconds?
If that is the case, then making changes from Ubidots to the ESP32 shouldn’t be hard using MQTT’s Subscribe method. Just have the ESP32 Subscribe to a variable in Ubidots and whenever a 0 or a 1 is sent to that variable, then the ESP32 will also receive the value (activating or deactivating the relay). Parallel to that, you could have an event that monitors this control variable, and say if the value has been 1 for 5 seconds, then send a 0 to that same variable, this way, changing the state of the relay.
Does this make sense?
For more information on MQTT Subscribe for ESP32 please view this article,. and for more information on Events, view this other article.
I’ll be attentive to your response.
Best regards,
Sebastián
Hello Sebastian
thank you for taking time to answer my question.
No, this is not really what I was saying. Sorry if my question wasn’t clear.
I have no hardware button or switch connected to my ESP32. I want to control it entirely through the Ubidots dashboard.
What I basically need is either:
- a push button on Ubidots that sends a signal to the ESP32 for as long as I hold the button down on the app. That doesn’t seem to be available on the Ubidots widgets panel.
or
- using the Ubidots “Switch” widget: I push the switch on the dashboard, it changes from “on” to “off” and stays “off” until I push the switch on the dashboard again. But I need it to automatically change back to “on” automatically after 5 seconds. Since this function doesn’t seem to be available on Ubidots, I thought the ESP32 could send a signal to Ubidots after 5 seconds to toggle the Switch on Ubidots from “off” back to “on”.
Thank you
Oliver