Cannot read signal from flow meter

Hello everyone! This is my first post although I've been reading the forums for a while now, and I'm very excited about Arduino :slight_smile:

I'm working on a project that involves a flow meter controlled by Arduino (model Mega 1280). The problem is that I cannot make Arduino to read data coming from the flow meter. I've followed this guide (by TheMakersWorkbench) and plugged every cable as shown in the diagram but nothing happens... Using the code provided by TheMakers as a test, the Serial Monitor shows 0 L/Hours even when the liquid is flowing through.

I think it has something to do with the flow meter, here are the specs of the one I'm using:

Working voltage: 5 - 18 Vcc
Factor: 1120 pulses per liter
Max. frequency: 280 Hz
Output type: open collector

Here's a picture of it

And here's a picture of the wiring.

Hope some one can help :slight_smile: thanks!

1_ test the arduino side: Check connecting the pin2 to something else like switch and see if you can read it
connect if to 5 v and then to 0.

2- Check the flow sensor: put to water circuit and check volts between yellow and black cable.

Thanks for your reply!

  1. I always get 0 L/hour when using a switch or a jumper, maybe the code is wrong..

  2. I've tried the sensor side and it shows variations of voltages when using a 9V battery independently from the Arduino board.

An Arduino sketch to read a KWH meter I made once can also be used here, you need to adapt some constants.

robtillaart:
An Arduino sketch to read a KWH meter I made once can also be used here, you need to adapt some constants.

thanks for the input robtillaart! I'm confused about the pin 2 of the Arduino board, because I'm using Mega 1280 model and Pin 2 is located on the "Analog In" sector. The "digital" inputs are from pin 22 to pin 53.

AH you must find out which pin is the first IRQ pin - IRQ0 - don't have that info nearby

That's okay, I think the IRQ0 port of the Arduino Mega 1280 is digital Pin 22. I ran your sketch and got something: when no liquid is flowing through, all stats are on 0, and when liquid flows through it rises to 0.0010.. What does this means? Thanks!

KWH: 0.0000 0.0000
KWH: 0.0000 0.0000
KWH: 0.0000 0.0000
KWH: 0.0000 0.0000
KWH: 0.0000 0.0000
KWH: 0.0000 0.0010
KWH: 0.0000 0.0010
KWH: 0.0000 0.0010
KWH: 0.0000 0.0010

Thank you guys for your comments!

I managed to solve the problem, it was a stupid thing of my part: instead of plugging the sensor on Pin 2 of the PWM section I was plugging it on the Pin 2 Digital In section. I got confused because Arduino Mega is different from other models... Anyway, thank you very much!