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?
Controlling desk fan using a D1 mini
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- Franklin97355
- Posts: 23940
- Joined: Mon Apr 21, 2008 2:33 pm
Re: Controlling desk fan using a D1 mini
Can you show the schematic of your circuit and the code you are using? It might help.
- backslashv
- Posts: 45
- Joined: Fri Mar 27, 2020 11:48 pm
Re: Controlling desk fan using a D1 mini
Please see my attempt at drawing the circuit here: https://imgur.com/a/E8zvG3uFranklin97355 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.
- backslashv
- Posts: 45
- Joined: Fri Mar 27, 2020 11:48 pm
- adafruit_support_mike
- Posts: 67485
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Controlling desk fan using a D1 mini
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.
The circuit you've shown assumes a pull-down resistor and a switch that pulls the free end of the resistor high when closed.
- backslashv
- Posts: 45
- Joined: Fri Mar 27, 2020 11:48 pm
Re: Controlling desk fan using a D1 mini
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.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.
- adafruit_support_mike
- Posts: 67485
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Controlling desk fan using a D1 mini
Where are you measuring those voltages? I'm specifically interested in the voltages on the + and - pins of the switch.
- backslashv
- Posts: 45
- Joined: Fri Mar 27, 2020 11:48 pm
Re: Controlling desk fan using a D1 mini
That's exactly where I measured.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.
- adafruit_support_mike
- Posts: 67485
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Controlling desk fan using a D1 mini
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 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?
- backslashv
- Posts: 45
- Joined: Fri Mar 27, 2020 11:48 pm
Re: Controlling desk fan using a D1 mini
The same set of voltages depending on the fan speed.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?
- adafruit_support_mike
- Posts: 67485
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Controlling desk fan using a D1 mini
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.
There has to be a detectable change in voltage for the switch to do anything useful.
- backslashv
- Posts: 45
- Joined: Fri Mar 27, 2020 11:48 pm
Re: Controlling desk fan using a D1 mini
The voltage changes depending on the fan speed. I had provided the numerical values before.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.
- adafruit_support_mike
- Posts: 67485
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Controlling desk fan using a D1 mini
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.
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.
- backslashv
- Posts: 45
- Joined: Fri Mar 27, 2020 11:48 pm
Re: Controlling desk fan using a D1 mini
That's a bummer. Thanks for the explanation.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.
Please be positive and constructive with your questions and comments.