UNO R4 wifi PWM, Sense Control of Fan

I have 4 wire 12 V "PC" type fan with

Pin Function Wire color
1 GND Black
2 12V Yellow
3 Sense (tach) Green
4 Control (PWM) Blue

I am using a relay, operated from one of the pins on the Arduino and external 12 V source to power fans.

I need to start the fan, increase the speed slowly based some logic and use "Sense" control the speed of the fan.

I have tried many of the articles but seems they are either different than the uno r4 wifi or do not make use of the "Sense" pin on the fan.

Any ideas?

4-wire fans with PWM control input have the MOSFET built in to the fan itself

How is the relay connected to the R4? How is the relay coil powered ?
Post a link to the fan's datasheet or it's brand name and exact part number.

How is the relay connected to the R4?
I use one of the Digital pins to activate the relay coil which is 5V.

Post a link to the fan's datasheet or it's brand name and exact part number.
https://www.amazon.com/dp/B0CMD47XYG
Okinos, 67CFM, 1500RPM, 4Pin PWM, Hurricane Series, 120mm Case Fan 5 Packs, High Airflow

I could not find the exact datasheet.

I could change to almost any fan as long as they are reasonable. (I need four of them)

Thanks for the help.

Can you post info on the relay?

The relay is not an issue as I should be able to control the fan even if it were wired direct to a power source.

Coil Side

PINS J1

  • VCC - VCC for Relay One Not Sure
  • VCC - Common to J2 VCC
  • GND - GND

PINS J2

  • GND - GND
  • IN1 - When GND the relay ONE is on.
  • IN2 - When GND the relay TWO is on.
  • VCC - Voltage to power coil 5V

Contact Side

Each relay is noted as K1 or K2 at the top.

  • NO Open
  • Common - (Wiper)
  • NC - Normally Closed

Appears there is some sort of action happening as if I wire the use
int PWM_PIN = 6;

And wire this to the PWM pin on the fan, the fan is not at Full speed.
I assume this maybe due to a difference in the PWM_PIN on the Arduino and the fan being different KHz for PWM.

There appears to be no change in fan speed regardless of what I Write to the PWM_PIN, but I have no tools to red the RPM.

Trying to read the SENSE_PIN A5 gives values even when the Fan has no power.

I have put a shared GRD for Arduino and external power supply.

Thanks again for your help.

Do you have the Arduino GND connected to the 12V GND?
Where does the relay board's Vcc power come from?
How is the R4 powered?

Do you have the Arduino GND connect to the 12V GND?
Yes

Where does the relay board's Vcc power come from?
The relay coil is powered from the Arduino's VCC 5V connected to the Digital PINs.
The relay's contacts use a 12V external power cube.

How is the R4 powered?
Currently it is powered by USB, but I have also used an external power Cube.

Extensive documentation on the overall project is at:

But be careful this is a small part of that much larger overall project.

Thanks again for your help.

If there is 12V power to the fan and PWM signal from the R4 it should work. I'm not familiar with UNO R4 so, like you say, it's PWM frequency may be too low for the fan (I believe that's usually 25kHz).

I have tried many different ones with no success.

This is my simplest and current attempt:



#define SENSE_PIN A5  //where we connected the fan sense pin to read value
int PWM_PIN = 6; // where we write the PWM duty_cycle Must be a PWM capable pin on Arduino

int output_start = 25;
int output_end = 256;

unsigned long volatile ts1 = 0, ts2 = 0;

double round(double d) {
  return floor(d + 0.5);
}

void setup() {
  pinMode(SENSE_PIN, INPUT);  //set the sense pin as input with pullup resistor
  pinMode(PWM_PIN, OUTPUT);
  Serial.begin(115200);
}

int duty_cycle = 5;
void loop() {

  if (duty_cycle < 256) {
    Serial.print("SENS RPM:");
    unsigned long snese_reading= analogRead(SENSE_PIN);
    Serial.print(snese_reading);
    // duty_cycle = map(duty_cycle, 25, 100, 0, 100);
    duty_cycle = duty_cycle + 50;
    analogWrite(PWM_PIN, duty_cycle);
    Serial.print(" duty_cycle:");
    Serial.println(duty_cycle);
    delay(5000);
  }
  else {
    duty_cycle = 25;
  }
}

Thanks for helping with this.