Controlling desk fan using a D1 mini

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
backslashv
 
Posts: 45
Joined: Fri Mar 27, 2020 11:48 pm

Controlling desk fan using a D1 mini

Post by backslashv »

Hi,
I have connected a PMOS to a D1 mini flashed with ESPHome. The source is connected to the D7 port. The drain is connected to the negative end of a switch on my desk fan's pcb. I'm trying to trigger the fan remotely as opposed to using the push button on the PCB. I have added the PMOS as a GPIO switch. When the drain is connected to the negative terminal as shown here , and I toggle the switch from Home Assistant, the fan turns on and off as expected but only once. I have to detach the wire and attach it again for it to work one more time. Can anyone point out to me why I am seeing such a behavior?

User avatar
Franklin97355
 
Posts: 23910
Joined: Mon Apr 21, 2008 2:33 pm

Re: Controlling desk fan using a D1 mini

Post by Franklin97355 »

Can you show the schematic of your circuit and the code you are using? It might help.

User avatar
backslashv
 
Posts: 45
Joined: Fri Mar 27, 2020 11:48 pm

Re: Controlling desk fan using a D1 mini

Post by backslashv »

Franklin97355 wrote: Fri Mar 10, 2023 2:29 am Can you show the schematic of your circuit and the code you are using? It might help.
Please see my attempt at drawing the circuit here: https://imgur.com/a/E8zvG3u

User avatar
backslashv
 
Posts: 45
Joined: Fri Mar 27, 2020 11:48 pm

Re: Controlling desk fan using a D1 mini

Post by backslashv »

Bump!

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Controlling desk fan using a D1 mini

Post by adafruit_support_mike »

Let's step back for a moment: have you measured the voltage on the tact switch's pins when you press the button?

The circuit you've shown assumes a pull-down resistor and a switch that pulls the free end of the resistor high when closed.

User avatar
backslashv
 
Posts: 45
Joined: Fri Mar 27, 2020 11:48 pm

Re: Controlling desk fan using a D1 mini

Post by backslashv »

adafruit_support_mike wrote: Wed Mar 15, 2023 3:41 am Let's step back for a moment: have you measured the voltage on the tact switch's pins when you press the button?

The circuit you've shown assumes a pull-down resistor and a switch that pulls the free end of the resistor high when closed.
Thank you for your response. This is a 2-step switch. When plugged in and the fans off, the switch voltage is about 5.135V. When pressed once (high fan rpm), the voltage drops to 4.913V, and when pressed again (low fan rpm), the voltage rises to 5V.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Controlling desk fan using a D1 mini

Post by adafruit_support_mike »

Where are you measuring those voltages? I'm specifically interested in the voltages on the + and - pins of the switch.

User avatar
backslashv
 
Posts: 45
Joined: Fri Mar 27, 2020 11:48 pm

Re: Controlling desk fan using a D1 mini

Post by backslashv »

adafruit_support_mike wrote: Mon Mar 20, 2023 2:55 am Where are you measuring those voltages? I'm specifically interested in the voltages on the + and - pins of the switch.
That's exactly where I measured.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Controlling desk fan using a D1 mini

Post by adafruit_support_mike »

Okay, thank you.

The changes in voltage sound more like the effects of varying load on the power supply than signal voltages. They also don't tell us how the switch operates.

What voltages do you see on the + and - pins when you press and hold the button?

User avatar
backslashv
 
Posts: 45
Joined: Fri Mar 27, 2020 11:48 pm

Re: Controlling desk fan using a D1 mini

Post by backslashv »

adafruit_support_mike wrote: Tue Mar 21, 2023 2:10 am Okay, thank you.

The changes in voltage sound more like the effects of varying load on the power supply than signal voltages. They also don't tell us how the switch operates.

What voltages do you see on the + and - pins when you press and hold the button?
The same set of voltages depending on the fan speed.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Controlling desk fan using a D1 mini

Post by adafruit_support_mike »

If the voltages on the pins don't change when the switch is pressed, the switch does nothing.

There has to be a detectable change in voltage for the switch to do anything useful.

User avatar
backslashv
 
Posts: 45
Joined: Fri Mar 27, 2020 11:48 pm

Re: Controlling desk fan using a D1 mini

Post by backslashv »

adafruit_support_mike wrote: Fri Mar 24, 2023 5:41 am If the voltages on the pins don't change when the switch is pressed, the switch does nothing.

There has to be a detectable change in voltage for the switch to do anything useful.
The voltage changes depending on the fan speed. I had provided the numerical values before.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Controlling desk fan using a D1 mini

Post by adafruit_support_mike »

If that's the case, the device in question isn't a normal switch, and nothing you do connecting a mosfet to it will likely have any useful effect on changing the circuit's behavior.

A typical switch has either a pull-up resistor that holds one side at VCC, or a pull-down resistor that holds the side at GND while the switch is open. The other side of the switch is connected to the opposite supply rail. Closing the switch either sets the voltage at the switch end of the pull-down resistor to VCC or the switch end of a pull-up resistor to GND. The circuit connected to that side of the switch detects the change and responds accordingly.

If the device you're using only cycles through minor voltage changes near VCC, it's significantly more complex than a plain switch, and it isn't obvious how to add a second control circuit in tandem with it.

User avatar
backslashv
 
Posts: 45
Joined: Fri Mar 27, 2020 11:48 pm

Re: Controlling desk fan using a D1 mini

Post by backslashv »

adafruit_support_mike wrote: Sat Mar 25, 2023 12:31 am If that's the case, the device in question isn't a normal switch, and nothing you do connecting a mosfet to it will likely have any useful effect on changing the circuit's behavior.

A typical switch has either a pull-up resistor that holds one side at VCC, or a pull-down resistor that holds the side at GND while the switch is open. The other side of the switch is connected to the opposite supply rail. Closing the switch either sets the voltage at the switch end of the pull-down resistor to VCC or the switch end of a pull-up resistor to GND. The circuit connected to that side of the switch detects the change and responds accordingly.

If the device you're using only cycles through minor voltage changes near VCC, it's significantly more complex than a plain switch, and it isn't obvious how to add a second control circuit in tandem with it.
That's a bummer. Thanks for the explanation.

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”