I’m testing out a flow meter and have made Arduino code where I can push a button to run a 12V pump until a set amount is measured by the flow meter.
Below are pictures of the breadboard test setup for the flow meter test.
Below are the Fritzing sketch of the setup. The little black thing are the flow measurement. The motor/pump is controlled using a TIP120 transistor.
When testing the code using USB and the serial monitor I could see that the sketch was fine. In the serial monitor when pushing the button, the button state changed, pump state changed and the LED state changed. However when connecting 12V and testing the the setup with the pump running something seamed very odd.
The graph show the problem. Either the flow sensor detected an invalid value or the Arduino went mad. At this point the flow sensor isn’t calibrated to reach exactly 3,3dl, so that’s not so important, but the variations are the big failure.
Running the pump continuously on a separate power supply, powering the Arduino circuit with USB and using serial monitor on the computer show that the sensor is all right as it measures the flow and sets the pump state off as expected. So teh circuit and motor is the problem.
I first soldered 0.1uF ceramic noise suppression capacitors to the motor. That didn’t make a difference after a couple of new tests filling a bottle.Then I added a 470uF electrolytic capacitor on the breadboard and suddenly the breadboard exploded! I quickly learned about electrolytic capacitors and the importance of correct polarity. Then after lots of googling and help from the arduino forum I tried again with a 470uF electrolytic capacitor close to the +12v and ground on the breadboard and test filled some bottles.
That really made a difference.The circuit now works as expected, with only a tiny difference with each filling. In a beer bottle, the measured variation shown in the graph is ±1 cm up in the bottle neck. That’s about a teaspoon of liquid and is acceptable for me. To reach the 3,3 dl target the calibrationFactor variable in the code needs to be calibrated.