listwokay
Posts: 3
Joined: Fri Aug 12, 2022 9:27 am

Using a Pi 4 GPIO as a toggle switch?

Fri Aug 12, 2022 9:30 am

Hi, I have a Pi 4, and I look to utilize the GPIO pins as a way to toggle a usb light and a usb fan on/off. The fan is powered from a 5V USB, and there is a middle "remote" buttons that can turn it on/off, toggle speed and whatnot. Is is possible to substitute the remote with the GPIO pins to achieve this?

I appreciate all the help i can get! :D

drgeoff
Posts: 13229
Joined: Wed Jan 25, 2012 6:39 pm

Re: Using a Pi 4 GPIO as a toggle switch?

Fri Aug 12, 2022 11:00 am

It is probably possible but a definite answer and help with doing it will require a lot more information than you have provided.
Quis custodiet ipsos custodes?

User avatar
neilgl
Posts: 4965
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near The National Museum of Computing

Re: Using a Pi 4 GPIO as a toggle switch?

Fri Aug 12, 2022 11:04 am

Yes, "there is a middle "remote" buttons " - are these buttons on the fan or a remote control like a TV?

memjr
Posts: 2164
Joined: Fri Aug 21, 2020 5:59 pm

Re: Using a Pi 4 GPIO as a toggle switch?

Fri Aug 12, 2022 2:43 pm

People have done it before

https://www.hackster.io/jeremy-gillula/ ... -pi-734460

You'll need to make adjustments for any voltage differences between the IO pin and whatever you're trying to connect to.

pcmanbob
Posts: 13180
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Using a Pi 4 GPIO as a toggle switch?

Sat Aug 13, 2022 9:27 am

It is most probably possible using either relays , transistors or opto isolators but as has already be stated we would need to know a lot more about the circuit and its operating voltages before recommendation or even example circuits could be provided.

I would recommend either relays or opto isolators as they would provide isolation for the pi gpio from the existing controller circuit and so protect the pi from any voltage higher that 3.3V
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

listwokay
Posts: 3
Joined: Fri Aug 12, 2022 9:27 am

Re: Using a Pi 4 GPIO as a toggle switch?

Sun Aug 14, 2022 10:18 am

Hi, apologies for the late reply, here is the item in particular:

Image

It has that remote in the middle of the wire's length. For voltages and etc, im not really sure about it, other than it uses USB power only. Would probably be 5V right? I will need more research on it.

What the button does, is that it changes brightness, and also turns it on/off.

pcmanbob
Posts: 13180
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Using a Pi 4 GPIO as a toggle switch?

Sun Aug 14, 2022 10:25 am

You are going to need to open up the remote and investigate the switches to see how they work and what type they are, so you can get some idea on how you need to interface to them.

I doubt you will find a circuit diagram for the controller so you are going to need to do a lot of investigation yourself to figure out how it works and voltages etc.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

ame
Posts: 5711
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Using a Pi 4 GPIO as a toggle switch?

Sun Aug 14, 2022 10:45 am

Most likely there is a PWM circuit in there which drives a MOSFET or some other buffer. The PWM will probably be generated by a dedicated micro in response to button presses.

I can see two approaches. One, cut the PWM output from the micro and attach a Pi GPIO instead. Or two, remove the whole lot and replace it with a MOSFET module driven by a GPIO.

Then you get software control of on/off/brightness.
Hmm. What can I put here?

ame
Posts: 5711
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Using a Pi 4 GPIO as a toggle switch?

Sun Aug 14, 2022 10:46 am

I suppose a third option is to drive the pushbuttons with GPIO signals.
Hmm. What can I put here?

listwokay
Posts: 3
Joined: Fri Aug 12, 2022 9:27 am

Re: Using a Pi 4 GPIO as a toggle switch?

Wed Aug 17, 2022 4:41 am

ame wrote:
Sun Aug 14, 2022 10:46 am
I suppose a third option is to drive the pushbuttons with GPIO signals.
This, any guide on how can i pursue this? This is exactly what I'm aiming for! I want GPIO signals to replace the button-pushing, as the remote is tucked away in my setup. :D

pcmanbob
Posts: 13180
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Using a Pi 4 GPIO as a toggle switch?

Wed Aug 17, 2022 8:24 am

So here is an example of how you would do it using an opto isolator

Image

Now you do have to know or be able to work out which way the current is flowing in the switch circuit or to put it another way which is the high side of the switch circuit.

Doing it with a relay would be similar but first you need to get a relay board to work with the 3.3V of the pi as many of the cheap ones are designed for 5V operation for the Arduino.
When using a relay you don't have to worry about the existing switch circuit as a relay is just an electrically operated switch.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Return to “Beginners”