Combine hall effect sensor and LCD display

Hello to the Arduino community ! :wink:

I’m a novice with arduino, and I want to do a project with a hall effect sensor (a water flow sensor ref:YFS 201) and a LCD display 16x2.

I have an Arduino Uno and I figured out that the hall effect sensor use external interrupts and need to be plugged on pin 2.
According to what I found, the LCD display need to be wired with the pin 2: LiquidCrystal lcd(12, 11, 5, 4, 3, 2).

Do you have any idea about what should I do because I have 2 wires for only 1 pin ? :confused:

Thank you !!!

You can wire the LCD to any pins that you want. The analog inputs as well. You must change the numbers in the constructor to match how you have the LCD wired.

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

is the constructor and the pins are, in order, RW, EN, D4, D5 D6 D7 on the LCD. Move the wire from Uno pin 2 and put it in pin 6 of the UNO and the constructor changes to:

LiquidCrystal lcd(12, 11, 5, 4, 3, 6).

Use one of the timer counter inputs. It is not quite straight forward but Jurs gave a great explanation on how to do this: By using the timer counter you remove the bulk of the countin load from the Arduino keeping your code much simpler once you get past the TC. I read this about your sensor, and came to the conclusion that you probably will have to add a pull up to the input as it states TTL output, it can be CMOS where no resistor would be needed but that is not specified. The sensor comes with three wires: red (5-24VDC power), black (ground) and yellow (Hall effect pulse output). By counting the pulses from the output of the sensor, you can easily calculate water flow. Each pulse is approximately 2.25 milliliters. Note this isn’t a precision sensor, and the pulse rate does vary a bit depending on the flow rate, fluid pressure and sensor orientation. It will need careful calibration if better than 10% precision is required.

Good Luck & Have Fun!


Thanks both of you for your quick answers, that helped me a lot !
@groundFungus, I tried what you suggest me and it works perfectly, the screen is showing the flow properly!!

@Gil I'm using this code to count the water flow and it works fine:

void rpm (){NbTopsFan++;}

in setup -> attachInterrupt(0, rpm, RISING);
in the loop ->
sei(); //Enables interrupts
delay (1000); //Wait 1 second

You are right I should be considering about precision, and I'll try an experiment with a known volume of water and I'll compare the results with the expectation. Anyway it's doesn't need high level precision so I think it will be just fine !

Thanks guys I have no more questions the topic can be locked :slight_smile: