I have a spa-side switch with 4 buttons on it. I’d like each of these to control something in HA. There is a common lead, and then each of the buttons has its own lead. Pressing a button momentarily closes the contact. Releasing the button opens it again. I’m looking for some hardware I can connect this switch to, such that I can get notification in HA whenever a button is pressed. I can then use automation to control pumps, actuators, etc. The various pumps and actuators are already integrated into HA - the switch will just be providing a “manual” control via HA automation. Anyone have any ideas?
ESP8266 and ESP-Home.
Very simple and cheap
You can connect the button to an ESP and use an ESPHome binary sensor.
Probably need something like:
binary_sensor:
- platform: gpio
pin:
number: GPIO10
mode: INPUT_PULLUP # or Pulldown depending on what the common is
name: "Button 1"
Thank you for the help @Hellis81 and @parautenbach. I’m completely ignorant about this stuff! Can you give me an example of a particular board that would be good? I presume I have to flash esphome. Is that right? Can I then just connect the ground cable from the switch to the ground pin on the board, and then the other 4 cables to 4 other pins? I’ve seen some boards that say these pins are for digital inputs. Is that OK for this scenario?
I’m assuming with switch here you mean some hardware that is purely opening or closing a circuit and that there’s no other power involved.
In other words, closing the circuit with the switch is exactly the same as taking a GPIO pin and connecting it to ground. A digital input pin is appropriate, because you just want something electrically that will be either high (3.3V on an ESP) or low (0V). This is the binary part. The pull-up resistor setting Hellis81 included is important, since when you have an open circuit, you don’t want the pin to float. When closing the circuit, the current needs somewhere to flow and be disappeared (connecting two different voltages directly to one another never leads to a desired outcome; read: sparks).
Depending on the board you choose, be careful to choose a pin that does have an internal pull-up. Also make sure to stay away from special pins that have some meaning during boot-up. You can choose any that’s specified on the ESPHome website, but I use some ESP-WROOM-32 boards. Sounds like a D1 mini would be too small for you, since you’ll be connecting several switches.
We first need to know the voltage of the circuit and the polarity.
Is the common ground or vcc?
The ESP chip needs to be connected differently depending on these variables.
Especially if the voltage is more than 3 volts, which I think. If that is the case then the ESP will be destroyed if you just connect it, more parts will be needed to protect the ESP.
I think the best way to look at this is to imagine a simple doorbell button. 2 wires, press the button and the two wires are shorted. I guess my spa-side switch is like that, only it’s 4 push buttons in one enclosure, and uses a single ground wire shared between them all. There is no voltage involved at all. I’d just like to know, in HA, when a button is pressed. Thank you both for all your help.
Are you sure?
Have you used a multimeter and measured it?
It’s just basically 4 dumb mechanical push buttons. There is a cable running from it with 6 leads inside it (sort of like an Ethernet cable). The black one is common, and each of the 4 push buttons has its own coloured lead. Nothing is connected to it at all at the moment. I can put a multimeter across one of those coloured leads and the common, and when I push the appropriate button the circuit is completed. That’s it. Pure contact closure.
I was under the impression that these buttons was in use in the spa also.
If it’s just dead wires then it’s simple.
I would use the common as 3.3 volt and connect each lead to separate pins on the ESP, then use INPUT_PULLDOWN.
This should mean when you press a button the pin will go high/on
Ok - so would one of these do the trick https://www.jaycar.com.au/wifi-mini-esp8266-main-board/p/XC3802? Easy, because it’s available from my local electronics dealer down the road. I would put the common lead on 3v3 pin, and the other leads on to, say, D8, D7 and D6? The board would be powered via USB? Sorry I need so much hand holding in this - all a first for me!
I suppose then I need to find out how to flash esphome and configure it (from a Mac). Do you know of a good, easy to understand, tutorial for this? Also need to learn how to solder - sheesh!
Yes that would work. You just need to decide whether to pay Jaycar’s inflated prices, or go somewhere else!
Yeh, there is that! Although after a shipping fee not that much different. Plus a soldering iron, solder, PCB holder, cable, power supply etc. Should be fun though!
You never buy one ESP.
I’m fairly sure there is a law against that.
But if I’m wrong, it makes no sense to only buy one. You always find new places to put them.
Or you accidentally break one, like I did a few weeks ago.
I had just finished everything and it was screwed in to place, and something happened and I needed to reboot the device.
I couldn’t reach the other end of the USB so I pulled out the micro USB side and the connector broke off.
I could grab a new one and flash it and it was up and running again.
Sure, you could run down the street and buy a new one for the price of, I don’t know the price where you are but it’s about four/five times the normal price here.
Do you want a hard wired solution or wireless based? I did build zigbee doorbell connection using an aquara push button. But needs soldering skills.
Yeh, I just got impatient and went to Jaycar! About twice the price of somewhere online I found, but oh well. Not exactly expensive thankfully.
Any pointers on flashing etc? Not managed to find a good tutorial yet…
You mean having a wireless pushbutton? The switches I’m trying to integrate have a 6-core cable attached.
Only twice as expensive?
I can usually buy them for about $5-6 still not in China
Just start a new device in ESP-Home and flash it using the option “connected with USB to this computer” or whatever it says.