Controlling PWM fan w/ pwm pin from ESP32

I'm trying to set the duty cycle of a 25kHz signal to control the speed on a 12volt 4-pin computer PWM cooling fan. But my fan seems to be running full speed regardless of the pwm duty cycle.

I don't have an oscilliscope to verify the frequency or the duty cycle my code generates, but when I put a voltmeter to the PWM pin (GPIO4), I see:

ledcWrite(4,dutycycle)

  • 0.64V at dutycycle=50
  • 1.9V at dutycycle=150
  • 3.19V at dutycycle=250

So the code's duty cycle seems to work to change the rms voltage read on the voltmeter.

I have 12VDC on the connector, and the fan seems to blow at full speed. The pin I've been reading the voltage on is connected to the last hole in the fan connector, the PWM pin. But varying the duty cycle hasn't change the fan speed. I don't have the tach pin connected to anything.

I've also joined the GND pin of the ESP32 to the negative pin of the 12V DC supply, so they're at the same potential. The 3.3V PWM signal should also be 3.3V relative to the fan's 12V supply. I've also tried this on two PWM fans, same result.

I was told that the PWM pin on the fan should take logic level (3.3V). Is that incorrect? Do I need to buy a logic shifter to apply 12V to the fan PWM pin? Or is there some tricky pullup/pulldown I'm missing on the PWM fan input?

code:

#include <esp32-hal-ledc.h>
void setup() {
  Serial.begin(9600);   //ESP8266 default serial on UART0 is GPIO1 (TX) and GPIO3 (RX)


  // put your setup code here, to run once:
  pinMode(4,OUTPUT);
  ledcAttach(4, 25000, 8);
  //ledcWrite(4,127);
  Serial.println("setup complete");
}

void loop() {
  // put your main code here, to run repeatedly:
  delay(1000);
  int dutycycle=50;
  ledcWrite(4,dutycycle);
}

Believe nothing you hear, and half you see. Verify everything

Use an Android app "spectrum analyzer"...

Be sure to connect terminal 3 of the fan to another pin on the Arduino. I don't know enough about electronics to know why, but it worked for me.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.