First post here and I tried searching for this first, so apologies if this has already been answered.
I have a project where I would like to use an ESP32/8266 to control a relay briefly. I want to be able to remotely activate a momentary push button to turn on a device.
I’ve been working off of this instructable: https://tinyurl.com/yckzz7y9
I was going to edit the code to replace the on/off to just a single button that actives the relay for half a second.
I’m still investigating this route, but the user interface isn’t the cleanest
Then I came across this post WLED Phone App | Control Addressable LEDs with an ESP32 or ESP8266 - Tutorial Australia
and it looks a lot more promising.
As per this, Control a Relay - WLED Project you can use WLED to control a relay.
I don’t have the hardware available to me at the moment to mess around with it, but i’d like to essentially use WLED to address this relay and have two functions.
1- tap to activate this relay momentarily (when it closes the relay, its a power button press and the system its connected to fires up)
2- another function to activate the relay for 10-ish seconds (would probably need to be configurable). this will force shutdown the system.
This relay will be put in parallel with the existing power button. I want remote control to turn on the system from the other side of the room.
thanks in advance
WLED will do the job, but is more complex than you need.
Ther are many examples available for controlling a device from a web page, with different styles of user interface. The code is relatively simple, and modifying an example for on/off or momentary operation would require only a few changes. The example you have found is the simplest and easiest to modify, but clunky. Note that you can set each command as a separate shortcut, with an icon, so you can select the different functions by selecting that icon, without worrying about the format of the command.
An example with a different user interface, slightly more complex is :
ESP8266 NodeMCU Async Web Server – Control Outputs | Random Nerd Tutorials
Welcome to the forum!!
Jeff has hit the nail on the head.
If your system is just running around the room you could also use a wireless link kit such as this: Gravity: Digital Wireless Switch Kit - Transmit and Receive (433MHz) | DFRobot TEL0140-1 | Core Electronics Australia
A kit like this would let you rule out a controller in between sine the logic is copied from end to end.
Thanks for the tips guys.
A little more info for you:
I need this to control (whether through a web page or phone app) to be accessible for the other members of my team. Even though WLED is probably far too much power and complex, it is free. I’m trying to put this all together with parts we already have lying around the electronics lab.
Coding is not my strong suit, but I can fumble around and edit stuff that has already been written.
I may explore the WLED a little bit more.
The example I linked sets the ESP up as a webserver on your local WiFi network. Anyone who can access the local LAN with a browser can get to the server and select the options on the page to operate the relay. This includes desktops, laptops and phones, with any OS. No special software is required for the user - it is all managed as a web page served up by the ESP that works with any browser. All that’s required is access to the local LAN. The coding change you need to make for that example is to change the ‘On’ and ‘Off’ commands from a single switching of the output pin to code that turns it on, loops until 10s (or whatever) has elapsed, and turns it off. It’s just a few lines.
I was getting hung up on how they were creating the buttons and using the functions in that example you provided. At the bottom of that post there was an example for a momentary button press that works exactly how i want it. the button click mimics a finger press 100%
Thanks for all your help guys.