1
\$\begingroup\$

I am using a Water flow sensor connected to v2 nodemcu. However, this sensor needs to be placed at a distance of 40 feets from nodemcu, on the 3rd floor of my apartment roof (I stay on 1st floor).

The sensor consists of 3 wires:

  • Red- for voltage input
  • Black- Ground
  • Yellow- sensor data

enter image description here

Relevant Specifications of 1/2 inch Water Flow Sensor - YF-S201:-

  • Model: YF-S201
  • Sensor Type: Hall effect
  • Working Voltage: 5 to 18V DC (min tested working voltage 4.5V)
  • Max current draw: 15mA @ 5V
  • Output Type: 5V TTL
  • Maximum water pressure: 2.0 MPa

What is the right way to extend the wiring for this sensor and does it require amplification? If yes, how?

PS: Do not want to use wifi as it is highly unreliable in outdoor conditions and susceptible to elements.

\$\endgroup\$
10
  • 1
    \$\begingroup\$ Use another nodemcu board and use the wifi to transfer the data. \$\endgroup\$
    – Kartman
    Nov 9, 2021 at 20:53
  • \$\begingroup\$ Using wifi is not a good idea since the sensor is to be used on roof, exposed to elements. Wifi signal will not travel 3 floors down with thick concrete walls in between. \$\endgroup\$
    – jerrymouse
    Nov 9, 2021 at 21:03
  • \$\begingroup\$ With wires you’ll need to manage RF interference and lightning. Choose your poison. \$\endgroup\$
    – Kartman
    Nov 9, 2021 at 21:07
  • \$\begingroup\$ How do they use long wires in other industries? I am sure my use case is not too obscure. \$\endgroup\$
    – jerrymouse
    Nov 9, 2021 at 21:11
  • \$\begingroup\$ I would consider using a RS422/485 differential driver up at the sensor and the matching receiver downstairs. Your cable would then require 2 pairs, one for power and the other for the differential signal. \$\endgroup\$
    – brhans
    Nov 9, 2021 at 21:16

2 Answers 2

3
\$\begingroup\$

The sensor outputs a digital pulse with a frequency that is linear with the flow rate, 7.5 Hz/(L/Min). It has a maximum flow of 30 L/Min so the maxium frequency is 225 Hz which is not challenging.

Solution one: use a MAX485 or equivalent at both ends with a twisted pair cable (ethernet CAT 5e should do) to transmit and receive the signal with minimal noise and number of components. Be sure to provide power to the sensor on another twisted pair and use decoupling capacitors. Cat5e has 4 pairs. This is not perfect but should do at 40 feet.

Solution two: use op amps to make a line driver for the impedance of the cable you will use, Cat5e is 100 ohms.

Solution three: use a dedicated line driver with a proper transmission line and termination.

Solution four: ad another microcontroller at the sensor side and use ethernet maybe even with PoE.

\$\endgroup\$
0
2
\$\begingroup\$

When lightning hits in the vicinity, the magnetic field will induce current into conductor loops. That's why long loops usually include isolation transformers, like Ethernet does. In your case, the sensor does not have a metallic case and is not grounded, and it is powered from the NodeMCU end, so there won't be a ground loop through the cable, so you'll be fine without isolation.

I don't see why differential signaling would be useful here either, for similar reasons. Without loops, there will be no large current through the GND wire, so if you use Cat5 shielded cable, the difference between GND and signal should be the same at both ends of the cable. There is a caveat though: due to different impedances, the ground wire and the signal wire could convert common mode EMI to differential. If there was a ground loop, this would be a big problem at low frequency (but there isn't). Without a ground loop, the cable will still pick up HF though. The cheat against this is to decide the signal is slow, aftre all it's pulses from a flow meter, definitely not gigabits, and use a small filtering capacitor that will dump any high frequency spikes picked up by the signal wire.

Note that differential signaling protects signal integrity, but it is NOT a magic bullet, differential receiver chips still need protection against overvoltage, spikes, nearby lightning strikes, ESD, etc.

Here's what I'd do:

At the sensor side, add a small pcb with a decoupling cap for power, like a few hundred µF electrolytic, and a 5.6V Zener on the signal line. This is to avoid any fields picked up by the cable creating an unsafe voltage for the sensor, especially in case of nearby lightning strike. The zener protects both ways, for negative voltages it will act as a diode.

Perhaps add 100R source termination resistor on the signal line, in series with the cable.

Connect sensor to NodeMCU with Cat5 cable, one twisted pair for power/ground, another twisted pair for signal/ground. Clamping a ferrite core on the cable is an option if you have trouble (probably not necessary).

On the NodeMCU side, connect 5V/GND from the cable to the power supply. You can add a fuse or current limiting resistor in case someone drills into the cable and shorts it.

If your 5V power supply is powerful enough to set the Cat5 cable on fire, definitely add a fuse, polyswitch, fusible resistor...

If it has open collector output, the pullup should be on the NodeMCU side. If it has a push pull output, then no pullup.

Now on the NodeMCU side the sensor output can be 0/5V which needs voltage translation, and the micro also needs to be protected from harmful voltage spikes.

You can use a simple BJT to do this:

enter image description here

Feed sensor output to the base with a resistor like 10kOhms, top side of collector to 3V3, so it outputs 3V3 logic level for the NodeMCU while tolerating large voltage spikes on the input. The 10k resistor will protect it against pretty much anything except direct short to mains. If you want a "belt and suspenders" approach, you can add a reverse diode to ground to protect it against negative voltage.

You can add a RC filter before that, which would be good practice.

Total cost should be way below 1€, with parts you most likely already have.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.