Here we look at the 3144 hall effect sensor and how it can be used to make a simple tachometer with the Arduino Uno and a 1602 LCD display
Here’s the code for the UNO. IMPORTANT – Utube won’t let me include angled brackets in the description so when you paste the code into your editor do a find/replace for…
[ANGLED_BRACKET_LESS_THAN] replace with left pointing angled bracket [ANGLED_BRACKET_GREATER_THAN] replace with right pointing angled bracket.
#include [ANGLED_BRACKET_LESS_THAN]LiquidCrystal_I2C.h[ANGLED_BRACKET_GREATER_THAN]
#define DISPLAY_W 16
LiquidCrystal_I2C lcd(0x27,DISPLAY_W,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
//SDA is Analog pin 4 on UNO
//SCL is Analog pin 5 on UNO
float revolutions=0;
int rpm=0; // max value 32,767 16 bit
long startTime=0;
long elapsedTime;
void setup()
{
pinMode(2, INPUT_PULLUP); // set pin to input
lcd.init();
lcd.backlight();
lcd.setCursor(0,0);
lcd.print(“RPM :”);
}
void loop() {
revolutions=0; rpm=0;
startTime=millis();
attachInterrupt(digitalPinToInterrupt(2),interruptFunction,RISING);
delay(1000);
detachInterrupt(2);
//now let’s see how many counts we’ve had from the hall effect sensor and calc the RPM
elapsedTime=millis()-startTime; //finds the time, should be very close to 1 sec
if(revolutions[ANGLED_BRACKET_GREATER_THAN]0)
{
rpm=(max(1, revolutions) * 60000) / elapsedTime; //calculates rpm
}
lcd.setCursor(0,0);
String outMsg = String(“RPM :”) + rpm;
fillMessage2DisplayWidth(outMsg);
lcd.print(outMsg);
}
void interruptFunction() //interrupt service routine
{
revolutions++;
}
void fillMessage2DisplayWidth(String & message)
{
if(message.length()[ANGLED_BRACKET_LESS_THAN]DISPLAY_W+1)
{
while(message.length()[ANGLED_BRACKET_LESS_THAN]DISPLAY_W)
{
message+=” “;
}
return;
}
//message is too wide for 1 line of the display, truncate it
message = message.substring(0, DISPLAY_W-1);
}
, https://i.ytimg.com/vi/pIflB4FQpNE/hqdefault.jpg
source
This is a 5v overide
Hi, I've really enjoyed your clear and easy to understand video. I've been searching for some help with a electric motorcycle project I'm working on as a mechancial engineer, but need some help on the electronics and arduino side of things. Would you be interested in some paid work? If so drop me a reply and we can connect. Thank you.
Does it matter which pole is facing the sensor? Will the led light up no matter which pole is facing sensor?
Great video very informative thank you
Great, could that be placed against the spark plug lead of the lawxn mower to get the same effects instead of using the magnet on the flywheel?
Hi, I've just replicate your project and it works, but i need your help. I wanted to measure the rpm of my dirtbike but unluckily the rotor has a pair of magnets instead of one. I've tried to modify the code changing the value 60000 and putting 30000 instead on : ' rpm=(max(1,revolutions) * 60000/elapsedTime;' but it didn't work, it shows me 2000 rpm at idle.
I Think the problem is that the magnets are closer to each one, they need to be at 180 degree instead.
What I can do? How I can fix my problem?
Thank you!
Hi how many max rpm can this read Thank you for your work is very good…
Hey, move your toes from under the mower.
You're about to loose them.
Hi Sir – Wanted to just ask, do I have to use a 3144 Hall-effect Sensor or can I use a different type as I cannot locate a 3144 hall effect sensor in my country. If I use a different type will it still work? Thank you in advance sir
I want to try using this on an RC car nitro engine and sending the data back to me with a 433 hz transmitter/receiver module. Thank you!
It doesn't measure an rpm below 60..
hi, I tried the code by inserting the brackets as you said but it keeps giving error
That was dead on. Mowers run at 3000 to 3500. Great video
I wanted to measure rpm of 6 .motors.How to do it?
Hay Bruno! Thank you for actually explaining the code. You made a light come on as to using interrupts that I've been struggling with.
Thanks,000,000 for helping me understand Arduino code better.
– k –
Bruno Borleri
1 hour ago
My project is an "RPM counter for a 2-speed engine".
I tried your program, your project involves only one magnet so 1 lap 1 pulse, I in mine built a rotor with 6 magnets then 1 turn 6 pulses to have more precision, I do not know if this is wrong, I wanted to modify your program but I have no programming experience, if you can indicate the correct way to change ,then I wanted to remove the fractions of 100 RPM,example if I read 12570 RPM I wanted it to be incremented by 100 RPM,example 12400/12500/12600 etc.with an increase or decrease of 100 RPM, the electrical hardware and connections are the same as your project only changes the magnet that I have built with 6 magnets at 60°, thank you if you can help me in editing the program.
Bruno Borleri
The electrical hardware and connections are the same as yours.
Thank you
great video