Why would a button connected to a MCU be switching a 16KHz signal? - Page 1
Forum section: electronics / general

author: mchahn
author_rank: Newbie
timestamp: March 02, 2024, 05:09:06 am
content: I am adding wifi to an old thermostat. I'm using an esp32. Luckily there are test points next to each button in the thermostat so I'll have no trouble attaching wires.Several of the switch inputs have the usual design of a switch with a pullup such that the output goes to zero when the switch is pressed. I can simulate a press by just pulling the output down with a gpio pinHowever, there are some snap-action dome switches that are baffling me. Even though they are domes they just make a connection between two wires like any switch. When the switch is open the output is low. When the switch is closed the output shows a 16KHz square-wave. At first I thought that it my be a capacitive-touch sensor. But that makes no sense since the switch is making a normal electrical contact.I'm not sure how to simulate a press on this. I could drive the output with a gpio pin using a square wave. But this makes me nervous since I don't understand the circuit I'm dealing with.Does anyone have a clue why the switch has the square wave?

author: amyk
author_rank: Super Contributor
timestamp: March 02, 2024, 05:40:00 am
content: They may be multiplexed and you're seeing the scanning frequency. A relay may be the best way to simulate pressing them.

author: mchahn
author_rank: Newbie
timestamp: March 02, 2024, 05:49:36 am
content: Quote from: amyk on March 02, 2024, 05:40:00 amInteresting. I'm going to have to give some thought to this so I can figure out what is going on.Quote from: amyk on March 02, 2024, 05:40:00 amUnfortunately I only have access to one side of the switch, the side I'm calling the output. Luckily the output does change when I press the switch. That side could have been a ground.I can defnitely detect when the switch is pressed which is half the battle. I'd really like to be able to simulate a press though so I could remotely press the button.

author: pcprogrammer
author_rank: Super Contributor
timestamp: March 02, 2024, 07:18:42 am
content: Post some pictures of the inside of the thermostat and especially the part with the dome buttons. It might be a scanning matrix and to simulate these you can use analog switches like in the 4066 ic. Another option is to use the IO of the ESP32 directly, but requires the matrix to be on the same voltage level.Old stuff probably works on 5V, so the latter option won't do unless using level converters.A matrix scan has a couple of outputs going into the matrix and a couple of inputs coming from the matrix. To simulate a specific key press your system has to make a connection between it's so called scan line and the data line.Take a lookherefor more info on how it works.

author: ejeffrey
author_rank: Super Contributor
timestamp: March 02, 2024, 05:47:37 pm
content: Is it a 50/50 duty cycle square wave or is it a pulse train? How many buttons are there like this? If it is something like a 3x4 numper pad, you would expect the duty cycle of the pulse to be 25% or 33% not 50%. I wouldmt expect a scanning for fewer buttons than that.If it's a scanning multiplexer you are going to have a hard time simulating it without access to the other side of the switch or being able to synchronize with the scan rate. If you had access to both sides of the switch a MOSFET would do the job easily.

author: mchahn
author_rank: Newbie
timestamp: March 02, 2024, 06:00:27 pm
content: Quote from: pcprogrammer on March 02, 2024, 07:18:42 amUnfortunately every signal goes immediately into a 4-layer board so there isn't anything to see.Quote from: pcprogrammer on March 02, 2024, 07:18:42 amIt is all 3.3V so using the esp32 gpio is no problem.But it does not appear to be a matrix.I have one test point per button and that point puts out a wave only when that specific button is pressed and not when any other button is pressed. In other words there is never more than one test point active. If it was a matrix then multiple points would be on one row heading into the mcu and I would get a signal on more than one test point when only one button is pressed.This still leaves me wondering why there is a wave instead of a simple level.So I can detect when a specific button is pressed. Now I'm just left with the press simulation problem.When I get the esp32 gpios conected I'll try driving those points. I'll check immediately to see if the signal is ever anything other than 3.3V or ground. I know from experience that two drivers conflicting causes an intermediate voltage so I'll know if it is safe to drive. If safe then I can try sending various waveforms in.Wish me luck.

author: mchahn
author_rank: Newbie
timestamp: March 02, 2024, 06:06:47 pm
content: Quote from: ejeffrey on March 02, 2024, 05:47:37 pmIt is close to 50/50 but not exactly. Maybe 60/40. And that signal is unchanging the whole time the button is pressed.Quote from: ejeffrey on March 02, 2024, 05:47:37 pmSix buttons. A 3x2 matrix would only save one connection which would be unlikely.So all this again points to it not being a matrix.

author: ejeffrey
author_rank: Super Contributor
timestamp: March 02, 2024, 06:12:50 pm
content: Maybe for some reason they needed DC isolation and the button signals are capacitively coupled?Are the signals for each button the same frequency? Maybe it was intended to be or originated from some frequency modulation signalling like touch tone phones? Maybe for communication between thermostats in a multi zone setup over the existing thermostat wiring?

author: mchahn
author_rank: Newbie
timestamp: March 02, 2024, 06:23:46 pm
content: Quote from: ejeffrey on March 02, 2024, 06:12:50 pmI thought the same thing. Most MCUs have capacitive touch sensor inputs. Maybe the top part of the dome doesn't touch the bottom part. Or maybe it is an unreliable connection. The dome has to be made of spring metal which may not make good contact.Quote from: ejeffrey on March 02, 2024, 06:12:50 pmAgain, I would see a signal on multiple test points. Also I don't see why anyone would go to that trouble. I don't see a reason. But I will check the frequencies.Quote from: ejeffrey on March 02, 2024, 06:12:50 pmThis is not the case. The only connections to the outside world are the 24VAC lines driven by relays.

author: pcprogrammer
author_rank: Super Contributor
timestamp: March 02, 2024, 08:06:45 pm
content: Quote from: mchahn on March 02, 2024, 06:00:27 pmThat does not sound like an old thermostat. Still pictures would be nice because we love pictures.If every key has it's own test point and there is no coupling found between the keys then it might indeed be that there is a capacitor in play. Can you post a picture of what the signal you see on the scope looks like.If you have a signal generator you can test if the key press is seen when you apply a 16KHz signal to the test point. Use a series resistor of say 100 Ohms to protect the generator and the thermostat.When this works, then you can simply output this 16KHz signal from your ESP32 to simulate the key press.

author: mchahn
author_rank: Newbie
timestamp: March 03, 2024, 01:14:41 am
content: Quote from: pcprogrammer on March 02, 2024, 08:06:45 pmI shouldn't have said old. It is only a few years old but I got a newer one so it was old to me. It has all the fancy programming stuff. If I get everything to work then it will be the new one.Quote from: pcprogrammer on March 02, 2024, 08:06:45 pmIt is a plain digital signal from 0 to 3.3 volts. It is up for 40ms and then down for 20 ms. This repeats as long as the key is held down. Sorry to disappoint but I'm too lazy to take a pic.Quote from: pcprogrammer on March 02, 2024, 08:06:45 pmI don't have a signal generator but I could whip out an eps32 signal if I took the trouble. My PCB with the esp32 and all the interface circuitry is due soon. It would be easiest to just use that.Quote from: pcprogrammer on March 02, 2024, 08:06:45 pmI sure hope so.In case anyone is interested I'll describe the complete setup.I've soldered fine wires to all the test points. The points were only about one mm square pads so it was quite hard to do. Halfway through I figured I couldn't do it and I would probably also kill the unit but everything worked well at the end.My custom board is due in next week. It has the esp32 with direct gpio connections to each test point that I can sense and also hopefully drive.The board also has the 24vac signals G, W1, W2, Y1, Y2, and C connected to io circuitry. The ac signals are half-wave rectified to a giant cap which then drives the input to an opto-isolator. The output of the isolator then goes in to more gpio pins. These are only sensed, I don't need to drive them.I'll post the final results here. I bought the minimum of five boards so I will have 3 or 4 left. If anyone wants to also wire up a thermostat I'll give away free boards. The design is very general and would work with any thermostat.Wish me luck.

author: mchahn
author_rank: Newbie
timestamp: March 05, 2024, 11:49:34 pm
content: In case anyone cares, I'm giving up on controlling the buttons on the thermostat. I can't simulate a press and detecting a physical button press is unreliable. It turns out the buttons use a very high impedance which means it probably is a type of touch sensor. I'll still use my custom board to monitor the 24vac system control activity over wifi.Thanks everyone for the help.