logo elektroda
logo elektroda
X
logo elektroda

[Solved] How to prevent false impulses from a rain gauge from AliExpress?

szmiit 627 7
ADVERTISEMENT
Treść zostaÅ‚a przetÅ‚umaczona polish » english Zobacz oryginalnÄ… wersjÄ™ tematu
  • #1 20952201
    szmiit
    Level 9  

    I need to count the pulses of a rain gauge I recently bought on AliExpress. It has a cable with two wires on it, and it short-circuits them for a few tens of ms when the pan inside it fills with water and tilts to the other side. Each such pulse represents some constant level of rain in mm, so I want to count them.

    I placed the rain gauge on the roof and extended its cable to about 6 metres, connecting it in the middle of its length and sealing it with heat shrink tubing with glue inside. I connected the wires to the NodeMCU board with the ESP8266 inside - one to GND and the other to GPIO14. I set this input to pullup mode so that the pulse is counted every time it is shorted to GND.

    Everything works when the rain starts. However, after it rains for a while (tens of minutes, maybe over an hour), the circuit starts generating these pulses like crazy. I noticed that when I cut the cable and leave it like that in the rain (because I already suspected water getting under the heat shrink and wanted to improve the bonding), after a while this effect starts again very clearly. So I rather rule out false pulse generation by the rain gauge (unless it itself has poor insulation somewhere). In any case, it is encapsulated in such a way that no water can get into the PCB it has inside.

    I would like advice on how to approach the subject. Am I guessing correctly that by some miracle (I don't know enough), some micro current is able to get through the insulation somewhere and cause a false grounding (or whatever you want to call it) that generates these pulses for me?

    Alternatively, what I am testing now is to switch the input to pulldown mode and generate a positive pulse. For now I am verifying that this will work, but I would like to ask you if my suspicion, for this initial configuration, is correct. The same happens on other GPIOs I have tested, including on a board with ESP32.

    Thanks!
  • ADVERTISEMENT
  • Helpful post
    #2 20952348
    jarekgol
    Level 39  
    Add a pull-up resistor, what the processor gives is weak. Think about contact vibration (debouncing), add an RC type filter and software filtering.
    How much current can your rain gauge handle?
  • ADVERTISEMENT
  • #3 20953527
    szmiit
    Level 9  

    Thanks for the reply. I don't have the specs, unfortunately, as it's Chinese hardware 😛. There's some sort of reed switch in there and that's all I know about it. Debouncing I tried at first, but there is no way to temporarily distinguish the actual pulse from the false one, probably caused by water.

    Overnight now it worked with this pulldown + positive pulse approach. It didn't freak out and it rained all night. I haven't tried my own pull-up resistor yet, likewise the RC filter.

    I'm curious what this could be about. I.e. I'd like to understand this phenomenon assuming the whole cable is tight, because that's what it seems to me.
  • Helpful post
    #4 20954393
    jarekgol
    Level 39  
    I'm betting on contact vibration in the first instance, in the second that the cable acts as an antenna and perhaps something is switching on in the area and interfering. And the less 'your' current flows in the cable the easier it is for interference to break through, hence the suggestion of an additional resistor. Do you have an oscilloscope?
    szmiit wrote:
    and short-circuit it for a few tens of ms when the pan inside it fills with water
    as you estimated that a good signal is a few tens of ms, make a filter so that it doesn't count anything below a few ms :) even an AVR with a slow for today's times 16MHz clock, has a cycle of 62ns of course it doesn't sample the input every cycle, but it's still very much within a few ms.
    Another option you can check is to send a 4 wire cable (twisted pair) with power to the roof and mount a buffer or "line transmitter" right next to the device and a receiver next to the proc, something like you use for rs485/422, cheap easily available chips.
  • ADVERTISEMENT
  • #5 20957077
    szmiit
    Level 9  

    Thank you for your answers. I was keen to understand this phenomenon. I'm not very much into electronics and various things surprise me later. Even when something seemingly cannot fail to work and I would almost give my hand up for it, it is then that such things come out :P

    For now, I have stayed with the ESP8266 and introduced a 47 kΩ pulldown resistor externally. It's been working fine for the last two days despite the rain - if it stays that way I'll leave it that way so I don't waste any more time with other combinations, but thanks for all the suggestions. As I wrote - various things are new to me, so even if I don't put these suggestions into practice now, maybe they will come in handy another time ;)


    What about debouncing, it wasn't IMO possible, because these fake pulses were temporally indistinguishable from real ones unfortunately.

    Greetings!
  • ADVERTISEMENT
  • Helpful post
    #6 20957873
    dktr
    Level 25  
    Add opto-isolation because this GPIO is about to collapse anyway, either from a thunderstorm or from other electrostatics.
  • #7 20958909
    szmiit
    Level 9  
    Thanks, I didn't know that, cool
  • #8 20958915
    szmiit
    Level 9  
    Closing the thread, I finally solved the problem by inserting an external 47 kΩ pulldown resistor (into the ESP8266, as it would be redundant in the ESP32 to my knowledge), and the GPIO now responds to positive pulses, not ground. It has been working flawlessly for several days now.

Topic summary

The discussion revolves around troubleshooting false pulse generation from a rain gauge purchased on AliExpress, which is connected to a NodeMCU board with an ESP8266. The user initially faced issues with excessive pulse counts after prolonged rain, suspected to be caused by contact vibration and potential interference along the extended cable. Suggestions included adding a pull-up resistor, implementing debouncing techniques, and using an RC filter to distinguish between real and false pulses. The user successfully resolved the issue by introducing a 47 kΩ pulldown resistor, allowing the GPIO to respond to positive pulses instead of ground, resulting in stable operation during rain.
Summary generated by the language model.
ADVERTISEMENT