RPM of Fan speed?

Hello, I have a 92MM fan. It is a 4 pin Pwm with Tac on it. At this moment I just want to run the fan flat out and see the speed on it. I searched online and found https://www.digikey.com/en/products/detail/delta-electronics/QFR0912GJ-00P0/21556246?s=N4IgTCBcDaIGwAYDMBaAigMQEoIJwEYwBxAKRQQQAUEUA5AERAF0BfIA this website. I study the schmetic and code But ran into a problem with reading the RPM in serial monitor reads 10006. My fan doesn't go to 5040 thousand RPM. The fan I'm using is 5400 RPM. I'm not sure what to do to read out the correct RPM. The code is listed below. Can someone please help me?

Edit: They also require a 560ohm resistor to go to 3.3v. Also the fan I'm using is from digikey. https://www.digikey.com/en/products/detail/delta-electronics/QFR0912GJ-00P0/21556246?s=N4IgTCBcDaIGwAYDMBaAigMQEoIJwEYwBxAKRQQQAUEUA5AERAF0BfIA

Joseph

//project done by www.theorycircuit.com
//code by Crenn from http://thebestcasescenario.com  thank you!
//Varibles used for calculations
int NbTopsFan; int Calc;
 
//The pin location of the sensor
int hallsensor = 2; typedef struct{
 
//Defines the structure for multiple fans and 
//their dividers 
char fantype;
unsigned int fandiv; }fanspec;
 
//Definitions of the fans
//This is the varible used to select the fan and it's divider,
//set 1 for unipole hall effect sensor
//and 2 for bipole hall effect sensor
fanspec fanspace[3]={{0,1},{1,2},{2,8}}; char fan = 1;
 
void rpm ()
//This is the function that the interupt calls
{ NbTopsFan++; }
 
//This is the setup function where the serial port is initialised,
//and the interrupt is attached
void setup()
{ pinMode(hallsensor, INPUT);
Serial.begin(9600);
attachInterrupt(0, rpm, RISING); }
 
void loop ()
//Set NbTops to 0 ready for calculations
{ NbTopsFan = 0;
 
//Enables interrupts
sei();
 
//Wait 1 second
delay (1000);
 
//Disable interrupts
cli();
 
//Times NbTopsFan (which is apprioxiamately the fequency the fan 
//is spinning at) by 60 seconds before dividing by the fan's divider
Calc = ((NbTopsFan * 60)/fanspace[fan].fandiv);
 
//Prints the number calculated above
Serial.print (Calc, DEC);
 
//Prints " rpm" and a new line
Serial.print (" rpm\r\n");
} 

Remove the resistor and use INPUT_PULLUP
Declare volatile int NbTopsFan;
Divide NbTopsFan by 3

The data sheet for your fan shows the reading is correct and is TWICE the rpm value.

Hello @jim-p, I'm not sure how to do the Divide NbTopsFan by 3? Coding isn't my strong point. Do I need to add the volatile int NbTopsFan = 0; or volatile int NbTopsFan; ? I had to look that part up as well. But I did add the pinMode(2, INPUT_PULLUP);.

So you did not write that code?
Is the different fan configurations with the structure you created necessary?

I did not write any of the code. it is from that website. it has code in there that goes to https://content.instructables.com/FPQ/O4OA/IZ6BIZUM/FPQO4OAIZ6BIZUM.txt

Try this code it's simpler and easier to understand:

volatile int pulseCount;
float Calc;

int hallsensor = 2; //The pin location of the sensor

//This is the function that the interupt calls
void rpm ()
{
  pulseCount++;
}


void setup()
{
  pinMode(hallsensor, INPUT_PULLUP);
  Serial.begin(9600);
  attachInterrupt(digitalPinToInterrupt(hallsensor), rpm, RISING);
}

void loop ()
{
  pulseCount = 0; //Set count to 0 ready for calculations

  sei();//Enables interrupts
  delay (1000);//Wait 1 second
  cli();//Disable interrupts

  //Multiply pulseCount (which is apprioxiamately the fequency the fan
  //is spinning at) by 60 seconds before dividing by the fan's divider
  Calc = float(pulseCount * 60) / 2.0;

  //Prints the number calculated above
  Serial.print (Calc);
  Serial.println (" RPM");
}

hello, @jim-p Sorry I did not check this yet. I have been dealing with my father death and burying him. It's been rough on my family. more to my mom and me. I will try this as soon as I can get home sometime this week. Thank you.

No hurry.