Thanks for the link to the stainless NPT sensor, my Web searches were coming up dry!
Greetings all,
Itās gratifying after all this time to see so many of you still helping each other this thread.
Iām here to provide some general updates, and to ask your advice again.
Since my original post, there have been some shakeups here. Iām not in control of as much land as I used to be, and Iām not trying to irrigate avocados.
However, Iām still trying to control pumps and read flowmeters.
I grew up as a subsistance farmer, and Iām going back to those principles because I think itās fair to say that itās hard out there for most of us right now, and frankly, I think itās dumb for farmers to have to buy groceries.
So Iām developing a pretty epic veg patch, which if I get it right will be enough to feed my family, and those of my employees. To this end, control of irrigation remains a priority.
Now, I started off running this project on a D1 Mini with an ESP8266, in an outdoor box, right where the flow meter was install. Under those conditions, I found that the ESP8266 module tended to last about two years before having to be replaced.
The circuit board itself lasted just fine and still works. I had to replace the power supply to the board twice, though.
In terms of the flow sensors themselves, I see that they are susceptible to building up grit that will stop the propeller after some time. However, you can clean and lubricate the mechanism, and it will work again good as new.
As far as that goes, the most useful tip I want to share is that if you are installing a large flow meter somewhere you know will get dirty, it is possible to purchase snap connectors that you can put inline with the flow meter, on either side.
They are pipe connectors that seal with compression clips instead of the traditional threads. They let me pop the sensor out of the pipe if I need to clean it, instead of having to go at it with a wrench.
I bought mine from a local agriculture supply store that sells irrigation pipes and connectors, I have not seen them in a general hardware store. They were, however, not very much more expensive than a non-return valve. You should use one of those, too.
Currently Iām having to rebuild the device because needs have changed. This time I will use ESP32, but I donāt want to put the controller in a box in direct sun. Iād rather have it in a nearby structure, and run cables to the sensors. It may also be possible to use ethernet rather than wifi, but we will see.
I intend to use UV-shielded and grounded CAT-5 cable, because I have a roll of it in the shed. Iāll run underground inside an electrical conduit. Google Earth says Iām planning to run 35m of cable.
That gives me 4 pairs of wire, and Iām saying 4 because of the distance: I am considering a twisted pair to be one wire.
At the end of that cable, I have to read a flow sensor, and a waterproof ultrasonic to detect tank level. Thereās also a relay for switching a big-ass contactor that runs a pump, but it doesnāt need to be where the sensors are.
So this is where I need the input.
First, is 35m too far?
If not, I think I can use two of those pairs to send power and ground. The flow meter only needs one wire for the sensor data. The ultrasonic, however, needs two.
So second, can I risk using one twisted pair for the ultrasonic? I must otherwise run two ethernet cables, which means Iām now using 70m of cable, and will definitely have to purchase more.
Any feedback would be welcome.
Says it is 24AWG cable.
http://hyperphysics.phy-astr.gsu.edu/hbase/Tables/wirega.html
says 24AWG is 25.6 Ohms/1000ft
35 meters is about 115 feet, but you need both distances so 130 feet .
That means the loop resistance is 3.3 Ohm for the single wires, so using the pair for power makes sense.
For power at that distance I would use the pair method and/or POE (just the simple fixed 12V version) and a DC:DC convertor at the sensors end.
For a simple switch you donāt need to worry about the distance. Not sure about the ultrasonic thing.
you will need a strong pull-up and should consider other protection
Iām no electronics guru, but my understanding is that each of those āpairsā comprises a data wire (with solid colour) and a ground wire (white + colour) ⦠so you actually have 4 ground wires and 4 data wires; and sooner or later all the GND gets connected together anyway.
If you use one data wire for power (which may depend on how much power you need to send) that will leave one for sensor data and two for ultrasonic.
⦠at least that is my thinking to connect some sensors about 3m away from my greenhouse ESP32 controller. But first to track down my wi-fi issue ![]()
That is almost correct (the signal is differential, so not really ground and signal, just both sides of the same signal) for the intended use as a data cable. There is nothing that says you can NOT use the two wires in a pair as one. If you look at the post above, I did the math:
That math says using both wires in the pair is a good idea.
Here is a picture showing how some versions of PoE work.
My chinese eyes are learning to reverse engineer like a true chinese
im new to esp32 so i just learn everything i need to checkout on my amazon cart thanks
Hi all,
Some time ago I posted here asking for some help. My project had to be stopped for a while due to other things, but Iām trying to work on it evertime I can. But I have some issues, I donāt know if itās on software or hardware.
So, I have 2 Aquariums.
The first I run a canister that has a nominal 1000L/h flux and a 16mm pipe.
The other has a nominal 500 L/h flux in a 12mm pipe.
I installed the YF-B5 (F=6.68Q) on the fisrt one and another smaller (F=5Q) on the other.
For the 1st one, initially I had a ESP8266 on a protoboard getting readings, and it was working, reporting about 318L/h of real flux. Donāt know if that was right.
When I decided to make a little board, I ended using a ESP32-C3, but It never worked, did not get any readings.
Now, I got another ESP32-C3 and mounted it on the protoboard, just to test. I got strange readings from it. The pulses it gets from the sensor is about 30.000Hz - 34.000Hz.
Then, from the formula and from what I read here, this readings are equivalent to about 75L/min, and 4500L/h, too high.
About the wiring, I donāt know where I read, but I put a 200ohm resistor on the sensor return (inline). I donāt really know if this is necessary, but may this be the problem, but ince ESP32 can handle the 5V input, it should not be a problem if I remove.
So, I tested removing this resistor, and the readings got a lot higher, over 48.000hz. So I put a 10k resistor back there and the readings dropped to about 4000hz.
Below is the YAML, gotten from this topic. I also tried to change some of the lambdas, but no success.
- platform: pulse_counter
name: "Litros por Min"
id: freq_fluxo_teste
use_pcnt: true
pin:
number: ${flux_pin}
mode:
input: true
pullup: true
update_interval: "${flux_time}s" # 60s
icon: "mdi:wave-undercurrent"
unit_of_measurement: "L/min"
accuracy_decimals: 0
filters:
- filter_out: nan
- lambda: return (x / 400); # 400 = 6.68 * 60
- platform: integration
name: "M3"
unit_of_measurement: 'm³'
accuracy_decimals: 2
sensor: freq_fluxo_teste
time_unit: min
filters:
- lambda: return (x / 1000);
- platform: integration
name: "Litros por Hora"
device_class: volume_flow_rate
id: fluxo_hora
unit_of_measurement: 'L/h'
accuracy_decimals: 1
icon: "mdi:waves-arrow-right"
sensor: freq_fluxo_teste
time_unit: h
filters:
- filter_out: nan
- platform: integration
device_class: water
state_class: total_increasing
name: "Litros Filtrados"
unit_of_measurement: 'L'
accuracy_decimals: 1
sensor: freq_fluxo_teste
time_unit: min
icon: "mdi:cup-water"
#------------------------------------------------------------#
I am now getting another ESP8266 to use also as a test and see if the readings it gets are the same.
Any tip any one can give me ?
THanks
Hi Vincent, trying to understand why you put 396 = 6,660 sec in your code. My sensor has same flow rate as yours seems (unless Iām wrong), which is 6,6 * Q (Q = L / Min ± 3%). Considering that my time interval is 5 sec as well, following your explanation the value in my case should be 6,65 = 33, which is far different from 396 = 6,6*60. Where am I not understanding the logic?
Thank you for your help
Impulso di flusso: 6,6 * Q (Q = L / Min ± 3%)
Youāre not wrong about the formula, the spec sheet says F = 6.6 Ć Q (with Q in L/min). That means if your sensor is passing 1 L/min, you should see about 6.6 pulses per second, or ~396 pulses per minute.
Thatās where my 396 comes from:
- 6.6 pulses/sec Ć 60 seconds = 396 pulses/min.
- Since ESPHomeās
pulse_counterby default counts pulses per minute, the math is:
L/min = pulses_per_minute / 396
So the lambda: return (x / 396); is just a direct conversion from āpulses per minuteā into āliters per minute,ā based on the sensorās spec.
If you wanted to do it with a different sample interval (like every 5 seconds instead of 60), the raw x value you get out of ESPHome will change, thatās why you saw me scale it by 60 in my explanation. But the underlying idea stays the same: divide pulses by (6.6 Ć 60) to get flow in L/min.
Hope it helps!
Many thanks it helps! In the meantime I understood the logic before your answer, and the point was exactly the one you outlined. if you measyre every 5 sec there are 12 slices of 5 sec in a minute⦠as well as, if you measure every 15 sec there are 4 slices of 15 sec in a minute⦠which means that, whatever measure frequency you use, you always multiply per 60 seconds. So, in the famous example abofe of F=38, IMHO the famous conversion rate should be 38 x 5 x 12=2280, or 38 x 60 in any case. Many thanks for the support!
Iāve made a adjustable esp32 for diferent water flow sensors so you can adjust the flow acuracy without a nes esp32 install, and there is a reset button for testing
globals:
- id: water_offset
type: float
restore_value: yes
initial_value: '0'
- id: k_factor
type: float
restore_value: yes
initial_value: '396.0'
number:
- platform: template
name: "Water Sensor K-Factor"
id: k_factor_input
icon: "mdi:calculator"
unit_of_measurement: "imp/L"
min_value: 30.0
max_value: 500.0
step: 0.1
initial_value: 396.0
optimistic: true
restore_value: true
on_value:
then:
- lambda: 'id(k_factor) = x;'
button:
- platform: template
name: "Reset Water Meter"
icon: "mdi:water-reset"
on_press:
- lambda: |-
id(water_offset) = id(total_water_raw).state;
id(total_water_l).publish_state(0);
id(total_water_m3).publish_state(0);
sensor:
- platform: pulse_counter
pin: GPIO34
unit_of_measurement: 'L/min'
id: water_usage
name: 'Current water usage'
update_interval: 5s
filters:
- lambda: |-
if (id(k_factor) > 0) return (x / id(k_factor));
else return 0;
- platform: integration
id: total_water_raw
sensor: water_usage
time_unit: min
internal: true
- platform: template
name: "Total Water Usage"
id: total_water_l
unit_of_measurement: 'L'
device_class: water
state_class: total_increasing
accuracy_decimals: 1
lambda: return id(total_water_raw).state - id(water_offset);
- platform: template
name: "Total Water MC"
id: total_water_m3
unit_of_measurement: 'm³'
device_class: water
state_class: total_increasing
accuracy_decimals: 3
lambda: return (id(total_water_raw).state - id(water_offset)) / 1000.0;
@DrQueenKitas can you share some details about your HW config?
Hi @DrQueenKitas ,
I just canāt thank you enough. Iāve been going crazy over installing my water flow sensor, and fortunately found this. So far it looks alright. Letās see if this matches my water company meter.
Regards
Teymur

