NodeMCU is the firmware. What hardware are you using?
It doesn’t really matter if it is an ESP8266 or ESP32 based board. The program will be the same (more on that in a minute) however it does effect your best choice of pin to use.
For an ESP2866 board you can use any of these recommended output pins (scroll down to the table “Best Pins to Use – ESP8266” In short, D1 to D7 are all good choices for outputs.
Now, rather than swapping the pin mode from input to output as was done in video what you can do in ESPHome is use the open drain pin mode. For example if you use pin D5 (ESP2866 board):
When you switch the pin on it will short the output to ground. When you switch the pin off it will be an open circuit / very high resistance (no voltage). This is what you want to use to activate a capacitive sense (touch) switch and was what the video was accomplishing by toggling from input (= high resistance) to output with the pin grounded.
Thanks Tom for the prompt reply and great explanation
I can’t wait to test it tomorrow.
In the meantime how can I make it behave like a momentary switch or a relay so toggles on and off on one command?
Or is OUTPUT_OPEN_DRAIN is that function?
Also would like to know if we need to specify output voltage “HIGH/LOW”?
I have wrapped the other end with aluminium foil and made it as wide and flat as the finger and placed it on the button. I even tried on the phone but no luck
I don’t know what type of sensor is on the washing machine, all I know is that it’s a touch sensor.
I have noticed that when I tap the foil with the jumper wire without triggering open drain it triggered the washing machine (I use non conductive pliers when doing so). But when the jumper wire is already in place and I trigger the open drain on and off it doesn’t do anything. It’s as if the jumper wire is always “active”
I don’t have a voltage meter with capacitance function so there’s no real way to know what’s happening.
To clarify, here’s a photo of my meter
I assume you just cut the WIFI section of your code for security and that you see the switch in home assistant.
Put your meter in resistance measuring mode. Measure from the ESP ground pin to D5.
When the switch is on the resistance should be very small. When off the resistance should be large or open circuit. There’s a virtual reverse biased diode in the drain - source of the switch that may mess up this measurement so try it with the leads both ways round (red on D5, black on GND, then swap if not getting the result you expect). One of the ways (or maybe both) should give you this result.
The other way is to hook up a simple test circuit with an LED:
+3V DC -----[ 100 Ohms]—>|----- D5
This is the LED: Anode (+) ------>|------ (-) Cathode
The 100 Ohms isnt important, something around that value will do as long as you are using a red, orange or green LED. The forward voltage of a blue LED may be too much for it to light.
The LED should be on when the switch is on.
Assuming all this works you may have too much stray capacitance in the circuit. Try shortening the the connection between D5 and the foil.
Maybe try putting the circuit in place and power cycling the washing machine. It might have a calibration for the touch sensor on start up.
One last test. With the circuit in place and the switch on, touch the ground pin of the ESP module to the cold water tap.
Hopefully it isn’t a resistive touch sensor… The foil will always short it.
In the mean time, if the sensor hasn’t been blown yet (even though I’ve used foil on it in the past test) we can pretty much rule out it being a resistive sensor? You got me a little worries
By the way, yes the Wifi section was deleted due to security, I can see the switch in HA
Ok @tom_l
I have tested by setting the multimeter on (Ω) and attached one lead to D5 and one to ground and it’s constantly showing me 33.1Ohms whether the switch is on or off.
Tried multiple grounds and swaped the test leads but nothing changed… This confirms my experiences testing on the washing machine, as if the lead is always active
unfortunately I don’t have an LED to test but hopefully this continuity test worked?
Edit:
I found the problem!
My jumper cable was rubbish, I tried testing straight to the pins of the nodemcu and the reading now shows 0.34Ohms when the switch is on and 33.1Ohms when off…
Yes sorry, I noticed after I wrote that post, it’s 0.34M and it’s just 33.1, no K or M
Its getting frustrating but I just tested on washing machine using a coin, I know the coin is getting the Ohms correctly (because I have the multimeter connected on the other side of the coin) but the machine isn’t turning on.
Funny thing is, if I remove the jumper lead and just tap the coin it triggers the sensor no matter if the open drain is on or off. Maybe the change in the resistance isn’t quick enough to trigger the sensor? I say this also because I notice when turning the switch on/off, the mutimeter jumps around for a second or 2 till it settles on 0.34M/33.1Ohms
I’m starting to think I might need a servo with a jumper lead attached to act like a stylus (active or capacitive?) to make this work…
Connected tap to GND on pin to sensor (with coin and foil) didn’t work even though the multimeter is showing changes in Ohms
The stylus didn’t work earlier by direct contact to the sensor but just tried with a coin it’s working fine!
Luckily I ordered the servo over 10 days ago so shouldn’t be too much longer (damn china shipping)