Hey,
I've trying to get the RPM with esp32 and a A3144 Hall Effect Sensor.
When I start the Sketch, I'm getting back the "count" (rounds) but the RPM are only in 60x steps
I've tried several devices like a fidget spinner with magnet or a small fan. Also when I move the magnet with the hand I'm getting back "60"?
Do you have a clue what I'm missing here?
Wiring
const byte hallPin = 26;
float value=0;
float rev=0;
int rpm,count=0;
int oldtime=0;
int _time;
void IRAM_ATTR ISR()
{
rev++;
count++;
}
void setup()
{
Serial.begin(115200);
attachInterrupt(hallPin, ISR, RISING); // Interrupts are called on Rise of Input
}
void loop()
{
delay(1000);
detachInterrupt(hallPin); // detaches the interrupt
_time = millis() - oldtime; // finds the time
rpm = (rev / _time) * 60000; // calculates rpm
oldtime = millis(); // saves the current time
rev = 0;
attachInterrupt(hallPin, ISR, RISING);
Serial.print(rev);
Serial.print(" | ");
Serial.print(count);
Serial.print(" | ");
Serial.println(rpm);
}
My Serial.print
0.00 | 1 | 57
0.00 | 1 | 0
0.00 | 1 | 0
0.00 | 2 | 60
0.00 | 2 | 0
0.00 | 4 | 120
0.00 | 7 | 180
0.00 | 8 | 60
0.00 | 8 | 0
0.00 | 8 | 0
0.00 | 8 | 0
0.00 | 8 | 0