Dear All,
I have I rather lengthy code to monitor some variables in a water reservoir and transmit the info to my house using nRF24L01+.
It took a lot of time to get all the "pieces" of the code working properly.
Although I managed to read and transmit all the variables I need properly, I realized, to my surprise, that the flow measurement is totally off.
The actual flow value is 4.5 l/min and the reading is 47.0-48.5 l/min
I am using the Sekdiy FlowMeter and a YF-S201 to measure the flow, and I have checked the value of the calibration constant, kf, which is 8.0.
I suspect that the problem lies in the use of INT6, which is associated with board pin 7.
I have tried the following:
#1 attachInterrupt(digitalPinToInterrupt(interruptPin), Meter1ISR, RISING); (interruptPin=7)
#2 attachInterrupt(4, Meter1ISR, RISING);
But the readings are about 10 times higher than the actual value.
The complete code is attached.
Any ideas?
Cisterna_rev1.ino (10.3 KB)
I forgot to mention that I have measured the frequency of the signal arriving at pin 7 just to make sure that the front end (the sensor) output is ok.
I measured a frequency of 30Hz, which is the expected value for a flow around 4.5 l/min
Dear all,
I decided to check if I could apply a correction factor to the displayed value (without knowing what is happening)
and I applied a rectangular signal to pin 7 and varied the frequency.
These are the results I had:
frequency flow
10 15,5
20 31
30 46,5
40 62
50 77,5
This is a perfectly linear relationship where Flow(l/m) = 1.55 Freq(Hz)
So I decided to apply a correction factor and move on without knowing the explanation.
I have one more fact to add, although it seems nobody is interested in this topic.
There is another prototype using a different code the I will use to measure the flow rate of another stream.
The relationship between frequency at pin 7 and the measured flow rate is also linear, but the correction factor is about 80% larger than the one I have determined for the other setup.
For some reason it seems related to the code, since the flow sensor and the boards are the same.
Does it help to explain what is happening?
Regards,
Roger