AaronKow / Water-Flow-Sensor-in-C

use C Programming to read water flow sensor data
MIT License
2 stars 1 forks source link

Bug on Raspberry Pi3 with YF-S201C #firstbugreport #1

Open Scanbot90 opened 7 years ago

Scanbot90 commented 7 years ago

Hello AaronKow,

I've tested your code on my Raspberry Pi3 and the program starts without any problems (init with 0). When water starts flowing, the sensor starts reading the pulses, but there is the bug. It reads not correct (current liquid flowing ca 718000 ml/sec; flow rate ca 43100 L/min) if water stops, it still reads the 718000 ml/sec. If I unplug the signal wire, it still "reads" current liquid flowing (around 718000 ml/sec).

Can you help me fixing it?

Greetings and thank you :)

AaronKow commented 7 years ago

Hi @Scanbot90,

Thanks for trying out the code. I refer to my previous project. It seems I missed out the usleep(100). Can you try see it works out. Make sure the pins connected are correct as well.

Scanbot90 commented 7 years ago

Hi AaronKow,

still the same problem. It doesn't return back to 0 (current liquid flowing)

pins connected: -pin 17 (raspberry pi3) -5V+ -Gnd

-> sudo gcc -o waterflow water_flow.c main.c interrupt.c -pthread -> sudo ./waterflow 17

I just know basics in c and UNIX, so I can't debug your project. Does it work with your hardware?

AaronKow commented 7 years ago

Yep, I do tried with the experiment project before. You can have a look in the video.

Can, you try debug through the hardware? You after you compile the code with pin 17. Instead of connect to pin 17, try to connect your signal to GND. If you did it right, you should get 0, (because you grounded your signal).

AaronKow commented 7 years ago

Make sure you connect the wires correctly with respect to the colors:

Water Flow Sensor - Artik 10

Btw, you mentioned you connect to pin 17, is it a 3.3v power?

Raspberry Pinout

Scanbot90 commented 7 years ago

Hello again, I mean GPIO 17 (pin 11).

Hardwaresetup: VDD (red Line) = pin 4 (5V PWR) GND (black Line) = pin 6 (GND) Signal(Yellow Line) = pin 11 (GPIO 17)

I think there is a problem with the interrupt handler.

When I start your programm on GPIO 17, all values are init with 0 (like in your video). When the sensor get the first pulse (water flows), the program give me wrong values (allways around 718000 ml/sec). When I stop water flowing, the program still reads values. Then I unpluged the signal wire to see if there is a problem with the sensor, but the program still read values (allways around 718000 ml/sec). And then i stop your program by pressing "Enter"

Greetings

AaronKow commented 7 years ago

Hi, If that case, it's a bit hard for me to test things out because I don't have any Raspberry with me right now ... Btw, I can't confirm if this code does work for other devices. For the time being. if you have an Arduino, you can use the source code, here.