Jump to content

Simulate a button press via Arduino

Ariyala

Hey,

 

I have a controller that has a button to toggle the state of the device it is connected to.
 

Now I's like to use an Arduino to control the device instead, and figured the easiest would be to just simulate the button press on that controller board. 
 

IMG_2799.thumb.jpeg.0412500ff7ba16c092a20d59542984d8.jpeg


The button two sides of the button when not pressed have 3.3v, if I press it that goes down to 0v.

 

I have no clue how much amperage the device allows to be drawn by the controller, so my plan was to use an Optocoupler and have my Arduino use it's own power source, instead of powering it from the controller. Does that sound reasonable and make sense?

 

Also, is there a way to simulate the button press AND have that actual physical button still there and work? I guess not since it cuts the voltage when pressed, right?

 

If it were the other way around where there is no voltage when not pressed, and only if pressed - then it would be no problem ..

 

Amy help or tips would be welcome, I am still new to electronics 🙂

 

Cheers,

Ari

Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, Ariyala said:

plan was to use an Optocoupler and have my Arduino use it's own power source, instead of powering it from the controller. Does that sound reasonable and make sense?

 

That is probably the best way, since the Arduino can only output something like 40mA, and only at 5V.

3 minutes ago, Ariyala said:

Also, is there a way to simulate the button press AND have that actual physical button still there and work? I guess not since it cuts the voltage when pressed, right?

You could just put the Optocoupler in parallel to the button, so you can use the button when the Arduino is powered off or not doing anything.

English is not my first language, so please excuse any confusion or misunderstandings on my end.

I like to edit my posts a lot.

 

F@H-Stats

The Folding rig:

CPU: Core i7 4790K

RAM: 16 8GB (2x4GB) DDR3-1600

GPU 1: RTX 2070 Super

GPU 2: GTX 1060 3GB

PSU: Gigabyte P450B EVGA 600BR EVGA 750BR

OS: Windows 11 Home

 

Linux let me down.

.- -- --- --. ..- ...         

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Hello!

Link to comment
Share on other sites

Link to post
Share on other sites

16 minutes ago, Average Nerd said:

That is probably the best way, since the Arduino can only output something like 40mA, and only at 5V.

21 minutes ago, Ariyala said:

What if I were to use an ESP8266? Since I don't know how much I can safely draw it'd still be safer to use a separate circuit with an Optocoupler, right?

 

 

16 minutes ago, Average Nerd said:

You could just put the Optocoupler in parallel to the button, so you can use the button when the Arduino is powered off or not doing anything.

Oh, how would I do that?

Wouldn't the button still let the 3.3v through, no matter what I do in my parallel wiring with the Optocoupler?

 

Link to comment
Share on other sites

Link to post
Share on other sites

Also, I forgot to mention - that Controller is powered by 12V. So technically I could use that 12V to power my Arduino/ESP, but since I don't know how much draw is allowed, I am hesitant to do that :/

Link to comment
Share on other sites

Link to post
Share on other sites

A button is usually pulled up with a high-value resistor, say 1k or more. If the button is sourced by 3.3V, at most you would be dealing with 3.3 mA. The Arduino microcontroller should easily be able to handle at least 10 or 15 mA sinking current per pin.

 

All you'd need to do is sink the current through a low IO pin and couple the Arduino's GND to the button board's GND.

 

The button will also still work this way.

Link to comment
Share on other sites

Link to post
Share on other sites

46 minutes ago, Ariyala said:

What if I were to use an ESP8266? Since I don't know how much I can safely draw it'd still be safer to use a separate circuit with an Optocoupler, right?

Same Story. Optocouplers draw barely any current, but you need to use one made for the output voltage of the microcontroller you're using. Otherwise the Optocoupler won't work or burn out.

46 minutes ago, Ariyala said:

Oh, how would I do that?

Wouldn't the button still let the 3.3v through, no matter what I do in my parallel wiring with the Optocoupler?

With 99,9% certainty that is a NO-button (normally open), if it isn't pressed, the difference in potential (meaning the voltage) across it will be greater than 0, if it is pressed, the difference in potential drops to 0.

Edit: In short, no, it won't let anything through unless it's pressed.

In terms of wiring, simply solder wires to the contacts of the button that connect to the optocoupler.

43 minutes ago, Ariyala said:

Also, I forgot to mention - that Controller is powered by 12V. So technically I could use that 12V to power my Arduino/ESP, but since I don't know how much draw is allowed, I am hesitant to do that 😕

As long as you use a power source that can supply enough power it should be fine. Microcontrollers draw very little power, usually only a few watts.

Edited by Average Nerd

English is not my first language, so please excuse any confusion or misunderstandings on my end.

I like to edit my posts a lot.

 

F@H-Stats

The Folding rig:

CPU: Core i7 4790K

RAM: 16 8GB (2x4GB) DDR3-1600

GPU 1: RTX 2070 Super

GPU 2: GTX 1060 3GB

PSU: Gigabyte P450B EVGA 600BR EVGA 750BR

OS: Windows 11 Home

 

Linux let me down.

.- -- --- --. ..- ...         

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Hello!

Link to comment
Share on other sites

Link to post
Share on other sites

7 minutes ago, Average Nerd said:

With 99,9% certainty that is a NO-button (normally open), if it isn't pressed, the difference in potential (meaning the voltage) across it will be greater than 0, if it is pressed, the difference in potential drops to 0.

In terms of wiring, simply solder wires to the contacts of the button that connect to the optocoupler.

44 minutes ago, Ariyala said:

 

In this picture I measured the Voltage between A and B with a Multimeter. When the button is not pressed it measured 3.3V. When I press it the measurement is 0V. That means the button is a NC (normally closed) button, right?

 

If so, no matter what I do on a parallel wiring to A and B, there is no way for me to stop the flow through the switch, or am I missing something?

 

controller.thumb.jpg.a300b1a9a30ef67fef7ffb024921e863.jpg

 

 

9 minutes ago, Average Nerd said:

As long as you use a power source that can supply enough power it should be fine. Microcontrollers draw very little power, usually only a few watts.

The Power Supply is inside the HRV (Heat Recovery Ventilator) system that this Controller is connected to. The 110V power supply of the HRV itself can most likely handle the few extra watt of an Arduino or ESP, but how do I know if whatever they use to convert to 12V for this controller can also handle it? Or any other circuit along the chain?

Link to comment
Share on other sites

Link to post
Share on other sites

As a very crude schematic, this will work.

 

Naamloos.png.7b84675798ac082ec8f3ec1cb98b0184.png

 

If you couple both boards' GND, you can pull the switch signal down directly using the Arduino's IO-pin by driving it low.

 

You can include a protection diode that prevents you from driving the switch signal high with your Arduino, but personally I'd say that once you finish experimentation, the chances of accidentally driving a pin high are... low so it's optional.

 

This way, you can safely complete the current path for the switch signal to GND using both the button and the Arduino IO pin. No optocouplers necessary.

 

There are upsides to optocouplers, which include galvanic isolation. This is useful if you have high voltage or current spikes. I doubt that will be the case in this system. I also think driving the optocoupler will cost more current than to just sink the current directly.

Link to comment
Share on other sites

Link to post
Share on other sites

9 minutes ago, Ariyala said:

In this picture I measured the Voltage between A and B with a Multimeter. When the button is not pressed it measured 3.3V. When I press it the measurement is 0V. That means the button is a NC (normally closed) button, right?

No, that isn't the case. The multimeter measures the voltage drop across the button, when the button isn't pressed, so open, the voltage drop is theoretically infinite, in practice it caps out at the supply voltage. If the button is pressed, the voltage drop across it drops to a very low value, which the multimeter reads as a voltage very close to 0.

Edit: To verify that, set the multimeter to continuity, and repeat the same test with the board powered off.

Edited by Average Nerd

English is not my first language, so please excuse any confusion or misunderstandings on my end.

I like to edit my posts a lot.

 

F@H-Stats

The Folding rig:

CPU: Core i7 4790K

RAM: 16 8GB (2x4GB) DDR3-1600

GPU 1: RTX 2070 Super

GPU 2: GTX 1060 3GB

PSU: Gigabyte P450B EVGA 600BR EVGA 750BR

OS: Windows 11 Home

 

Linux let me down.

.- -- --- --. ..- ...         

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Hello!

Link to comment
Share on other sites

Link to post
Share on other sites

5 minutes ago, Mojo-Jojo said:

There are upsides to optocouplers, which include galvanic isolation. This is useful if you have high voltage or current spikes. I doubt that will be the case in this system. I also think driving the optocoupler will cost more current than to just sink the current directly.

I generally agree, but if they want to be extra sure that the microcontroller is safe, an optocoupler is the way.

English is not my first language, so please excuse any confusion or misunderstandings on my end.

I like to edit my posts a lot.

 

F@H-Stats

The Folding rig:

CPU: Core i7 4790K

RAM: 16 8GB (2x4GB) DDR3-1600

GPU 1: RTX 2070 Super

GPU 2: GTX 1060 3GB

PSU: Gigabyte P450B EVGA 600BR EVGA 750BR

OS: Windows 11 Home

 

Linux let me down.

.- -- --- --. ..- ...         

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Hello!

Link to comment
Share on other sites

Link to post
Share on other sites

11 minutes ago, Ariyala said:

but how do I know if whatever they use to convert to 12V for this controller can also handle it? Or any other circuit along the chain?

Look for a TO-220 package (looks like a power transistor) on the PSU, and google the part number. I suspect sooner or later you'll find a 12V voltage regulator on there, and the datasheet should reveal what its rating is.

English is not my first language, so please excuse any confusion or misunderstandings on my end.

I like to edit my posts a lot.

 

F@H-Stats

The Folding rig:

CPU: Core i7 4790K

RAM: 16 8GB (2x4GB) DDR3-1600

GPU 1: RTX 2070 Super

GPU 2: GTX 1060 3GB

PSU: Gigabyte P450B EVGA 600BR EVGA 750BR

OS: Windows 11 Home

 

Linux let me down.

.- -- --- --. ..- ...         

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Hello!

Link to comment
Share on other sites

Link to post
Share on other sites

12 minutes ago, Average Nerd said:

No, that isn't the case. The multimeter measures the voltage drop across the button, when the button isn't pressed, so open, the voltage drop is theoretically infinite, in practice it caps out at the supply voltage. If the button is pressed, the voltage drop across it drops to a very low value, which the multimeter reads as a voltage very close to 0.

 

Oh I see, right that makes sense.

 

 

Thank you both, I'll give this a try tomorrow 😄

Link to comment
Share on other sites

Link to post
Share on other sites

7 minutes ago, Average Nerd said:

Look for a TO-220 package (looks like a power transistor) on the PSU, and google the part number. I suspect sooner or later you'll find a 12V voltage regulator on there, and the datasheet should reveal what its rating is.

Its either that or a switching power supply. But even if you find something like a 7812 on there, that doesn`t mean it can output its maximum current in this application. Because thats very dependent on how well its cooled and the voltage drop.

 

But you can just try. If it works and nothing gets too warm, it works. If not, it will almost certainly just switch off due to overload or overtemperature.

Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, Heats with Nvidia said:

But you can just try. If it works and nothing gets too warm, it works. If not, it will almost certainly just switch off due to overload or overtemperature.

I don't really have access to the internals of the HRV, only to the external ports where the controller from my pictures is wired into.

So I have no real way to check if something in there gets too warm 😕

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, Ariyala said:

I don't really have access to the internals of the HRV, only to the external ports where the controller from my pictures is wired into.

So I have no real way to check if something in there gets too warm 😕

If it suddenly powers off, it overheated/overloaded. If it doesn't, it's most likely fine.

English is not my first language, so please excuse any confusion or misunderstandings on my end.

I like to edit my posts a lot.

 

F@H-Stats

The Folding rig:

CPU: Core i7 4790K

RAM: 16 8GB (2x4GB) DDR3-1600

GPU 1: RTX 2070 Super

GPU 2: GTX 1060 3GB

PSU: Gigabyte P450B EVGA 600BR EVGA 750BR

OS: Windows 11 Home

 

Linux let me down.

.- -- --- --. ..- ...         

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Hello!

Link to comment
Share on other sites

Link to post
Share on other sites

Easiest would be to just use a mechanical relay - you get automatic isolation, you short the pins physically and then unshort them when relay turns off ... and you don't care if button is with pullups or pull downs... you really simulate the button press

 

you can get small 5v signal relays easily.

 

otherwise ... a simple npn transistor will pull a button to ground as if pressed...

Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, mariushm said:

Easiest would be to just use a mechanical relay

Isn't that basically what an optocoupler does? Also relays can kill microcontrollers by drawing too much current or with the high-voltage spike that forms when it turns off and there's no protection in place.

English is not my first language, so please excuse any confusion or misunderstandings on my end.

I like to edit my posts a lot.

 

F@H-Stats

The Folding rig:

CPU: Core i7 4790K

RAM: 16 8GB (2x4GB) DDR3-1600

GPU 1: RTX 2070 Super

GPU 2: GTX 1060 3GB

PSU: Gigabyte P450B EVGA 600BR EVGA 750BR

OS: Windows 11 Home

 

Linux let me down.

.- -- --- --. ..- ...         

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Hello!

Link to comment
Share on other sites

Link to post
Share on other sites

A mechanical relay  is bi-directional, it just creates a connection between the two points and doesn't care how electricity flows through the connection. 

 

An optocoupler is one way only, it's basically a npn transistor (unless the optocoupler uses mosfets or triacs) that's activated and lets electricity from from collector to emitter

 

the board could have the button wired in two ways :

 

IO pin --- resistor to 3.3v to pull pin up to 3.3v --- [ button ] ----- ground  

 

when button is pressed, the pin is pulled down to ground because the resistance between pin and ground through the button is lower than the resistor pulling up to 3.3v

Resistor could be internal, inside microcontroller, often in the 2-10k range.

 

IO pin  ---- resistor to ground ---- [ button ] --- 3.3v 

 

IO pin is held down to ground by the resistor (whatever internal capacitance there is, it's discharged through the resistor) and when button is pressed  IO pin sees 3.3v as a digital 1.

 

The first is more common but the second method is often present with chips that are mix of led segment drivers / key scan .. send power one way to light up segment, flip the pins to detect if button is pressed (led won't light up because it's a diode, only lights when electricity goes one way)...

 

An npn transistor will pull a pin down to ground when it's turned but if the voltage on the emitter is higher than collector it won't do anything.

 

You normally don't power relays directly from IO pins of microcontrollers, you connect the relay directly to your power (5v, 12v,24v, whatever, even if your micro runs on lower voltage like let's say 3.3v) and  you use a npn transistor or a mosfet as an on/off switch, connecting the relay's primary winding to ground to complete the circuit

 

See this tutorial where the guy turns on a solenoid (it's basically just like a relay)  using a npn transistor, personally think it's very easy to understand

 

 

image.thumb.png.0f3a6f9ae66ec342563d41348b4498f4.png

 

example of relays

 

5v  : https://www.digikey.com/en/products/detail/cui-devices/SR7-5V-200-1C/16602087

12v : https://www.digikey.com/en/products/detail/cui-devices/SR5-12V-200-1C/16602099

 

you can also get solid state relays , for example this one's basically optocoupler plus triac in a small package : https://www.digikey.com/en/products/detail/panasonic-electric-works/AQH1213AX/646009

 

It will work with as little as 1.3v (the forward voltage of the led inside), make sure you use a resistor to limit current and drop the extra voltage ex input voltage - dropout voltage = current x resistor  ... 20mA will be plenty (it's max 50mA) , so for example 5v - 1.3v = 0.02A x R = > R = 185 ohm .. so a 150...220 ohm resistor will work.

 

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

Personally I think using a relay is overkill and overcomplicated for the task. It requires more discrete components and more power. You need to deal with induction spikes and the added benefit (bidirectional current) doesn't add anything to the application.

 

It's a valid method, but I don't think it's suitable for OP's project per se.

 

Solid state relay is a nice choice.

Link to comment
Share on other sites

Link to post
Share on other sites

Thanks a lot for the great help so far everyone, I am learning a lot 🙂

 

Going on a tangent, I was thinking: I could probably also mimik what that controller does, instead of just pressing the button, right?

 

Those three large circles are where this controller gets hooked up to the HRV System. By pressing the button I can cycle between Off, Low and High. 
 

I did some measurements with the multimeter, between circle 1 and 3 it shows 12V. Between circle 1 and 2 it shows 0.9V when set to High, 0.6V when set to Off and 0.2V when set to Low - all values fluctuating a little bit up and down.

 

So I guess this means Circle 1 is GND, Circle 3 is VCC and Circle 2 is some kind of signal. It's a bit weird that the value for off seems to be in-between low and high though, doesn't it?

 

Would I be able to simulate that by basically just putting a resistor between my own Circle 1 and 2? Or how does this stuff work?

Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, Ariyala said:

Thanks a lot for the great help so far everyone, I am learning a lot 🙂

 

Going on a tangent, I was thinking: I could probably also mimik what that controller does, instead of just pressing the button, right?

 

Those three large circles are where this controller gets hooked up to the HRV System. By pressing the button I can cycle between Off, Low and High. 
 

I did some measurements with the multimeter, between circle 1 and 3 it shows 12V. Between circle 1 and 2 it shows 0.9V when set to High, 0.6V when set to Off and 0.2V when set to Low - all values fluctuating a little bit up and down.

 

So I guess this means Circle 1 is GND, Circle 3 is VCC and Circle 2 is some kind of signal. It's a bit weird that the value for off seems to be in-between low and high though, doesn't it?

 

Would I be able to simulate that by basically just putting a resistor between my own Circle 1 and 2? Or how does this stuff work?

This would be more complicated. You're probably looking at some sort of PWM signal, an analog control value would be quite rare these days so I suspect a resistor divider wouldn't work. You'd have to reverse engineer exactly what the control signal is and then reproduce. But it should be possible, given the proper tools to do it.

Link to comment
Share on other sites

Link to post
Share on other sites

26 minutes ago, Mojo-Jojo said:

This would be more complicated. You're probably looking at some sort of PWM signal, an analog control value would be quite rare these days so I suspect a resistor divider wouldn't work


I found this thread in another forum where they are discussing a similar control method for a slightly older version of my HRV:

 

https://cocoontech.com/threads/control-of-broan-venmar-hrv-or-erv-info.28397/

 

So I think there is a chance that it still just uses resistances 🙂

 

I guess I could just try it with a resistor and see what happens, right?

 

How do I calculate the resistor needed to go from 12V to something like 0.9V?

Link to comment
Share on other sites

Link to post
Share on other sites

12 hours ago, Mojo-Jojo said:

You can include a protection diode that prevents you from driving the switch signal high with your Arduino,

Not needed with three state logic.

People never go out of business.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×