Home | pfodApps/pfodDevices | WebStringTemplates | Java/J2EE | Unix | Torches | Superannuation | CRPS Treatment | | About Us
 

Forward Logo (image)      

Using the RG-9 Rain Detector

by Matthew Ford 16th September 2024 (original 17th May 2024)
© Forward Computing and Control Pty. Ltd. NSW Australia
All rights reserved.

Update 16th September 2024 – This project is superceded by the more accurate and sensitive Audio Rain Sensor and Window Open Detector

Introduction

This is the next version of the Window Open and Rain Detected project. In that first version the rain detector was PCB strips whose inter track resistance changed when the water was present on the PCB surface. That rain detector has a few problems:-
i) the PCB tracks corrode within a few days, changing the resistance when wet
ii) Once the PCB gets wet it takes some time after the rain stops to return the dry state even when mounted on an angle to drain away the water

Problem i) change in resistance, means the transition point between dry and wet changes value while problem ii) slow recovery to the dry state, means if a window is opened after the rain stops the alarm still sounds.

In an attempt to overcome the problems with the PCB rain detector, it was replaced with an Hydreon RG-9 rain detector.

The Components

The Parts List. (Prices as at 1st May 2024 excluding shipping)

Window/Door Open Detector

As per BLE Window/Door Open Detector and Rain Detector

Receiver and Rain detector

As per BLE Window/Door Open Detector and Rain Detector
remove 1 x Rain Detector PCB ~ US$0.44 (ElectronicFans, Aliexpress) (only the PCB used not the switching module see below)
add
1 x Hydreon RG-9 rain detector – Seeed Studio (SKU 101990760
)US$49.00
1 x 2.1mm Bulkhead Male DC Power Connector Jaycar PS0522 – ~US$2.20
1 x 2.1mm DC Power Line Connector 9.5mm Shaft Jaycar PP0510 – ~US$1.80

Code RD_ESP32C3_BLE_Scanner_RG_9.zip and ESP32
V2.0.11 Arduino board support and these libraries

Hydreon RG-9

The Hydreon RG-9 rain detector infers the presents of rain from the change if refractive index of the domed plastic cover, which varies light level received by the unit's sensors from the unit's leds.

( how it works diagram from Hydreon)

Hydreon makes it clear in their documentation that this 'rain detector' is not completely reliable. The warranty document states “It is the responsibility of the system designer and purchasers of the Rain Gauge to be aware of performance limitations of the device. … Apply engineering judgment: Hydreon does not claim the RG-9 is a perfect rain sensor. It is what it is, and senses what it senses.

Limitations include the following :-
The RG-9 can indicate rain when there is none.
The can take some time after it starts raining before the RG-9 detects rain when on the most sensitive setting.
It takes some time after the rain stops for the RG-9 to detect the rain has stopped
Wind moving rain drops on the plastic covering can be detected as rain.

This project attempts to work within those limitations.

The RG-9 receiver

The BLE Window/Door Open Detector and Rain Detector covers the construction and programming of the long life BLE Window/Door Open Detectors which run for 5 years on a coin cell. It also covers the design of your custom window layout and the generation of the Arduino code to display it on pfodApp. This project only covers the changes to the BLE receiver and rain detector module to accommodate the RG-9.

Configuring the RG-9

The RG-9 has a number of DIP switches, detailed in the RG-9 Instructions for SW 1.200 (local copy here). In this project they are all set to 0. That is Sensitivity 1 (Rain Drops) and no time extension of the Monostable output. J1 is used for connections, Out, V+, GND. There is also a serial connection available which gives access to actual emitter values and other controls, but that was not used here.

Construction

Again the circuit is trivial. A led to indicate when a window is open or bad or it is raining and a window is open. A buzzer to sound when it starts raining with an open window and the 5V supply to the RG-9 (black power plug) and it output signal (Red RCA plug)

Programming

Setting up to program the receiver is covered in BLE Window/Door Open Detector and Rain Detector. The Arduino code for the RG-9 version is in this zip file, RD_ESP32C3_BLE_Scanner_RG_9.zip. Unzip it to your Arduino sketch directory.

The required libraries are the same as for the BLE Window/Door Open Detector and Rain Detector, WinOpenDetect_libraries.zip Unzip the required libraries, WinOpenDetect_libraries.zip, to your Arduino sketch dir (Note: the Arduino .add .ZIP file does not work as the zip contains multiple libraries)

As for BLE Window/Door Open Detector and Rain Detector, the receiver/detector runs a BLE scanner, a web server, a tcp server. It also runs ESPAutoWiFiConfig to let you connect to your network and set the device's static IP. See ESPAutoWiFiConfig for the details. Here the config/connected indicator led has been omitted (pinNo is 0) but you can add another connection led to a spare XIAO output if you wish.

Code Options

The RD_ESP32C3_BLE_Scanner_RG_9.ino sketch and .cpp files have a number of options to monitor RG-9 output and control the transition from Dry to Wet and back.

At the top of the RG_9_RainDetector.cpp file there are two time delay settings

unsigned long startRainingDelay_ms = 30000; // 30sec
unsigned long stopRainingDelay_ms = 5ul * 60 * 1000; // 5min


This delays 'debounce' the RG-9 output. The RG-9 output must be low (raining) continuously for 30sec before the RD_ESP32C3_BLE_Scanner_RG_9.ino will switch to isRaining. On the other hand once it isRaining, the RG-9 output must be high for 5mins continuously before the RD_ESP32C3_BLE_Scanner_RG_9.in switches back to not-Raining.

The choice if these values is a compromise between false isRaining triggers and the delay in detecting the start of raining and preventing repeated triggers after the rain stops and the water on the plastic dome clears.

To help you determine suitable values for your installation, at the top of RD_ESP32C3_BLE_Scanner_RG_9.ino there is a

#define TELNET


statement, that switches the tcp server from a pfodDevice running on port 4989, to a telnet server running on port 23. When running as a telnet server the sketch sends to a connected telnet client, every 5secs, the current system state, Rain Detector is Dry / Wet together with the time current and previous output of the RG-9. For example

9:50:40 PM  Rain Detector is WET   Sensor is WET 256 secs  was DRY 66 secs
9:50:45 PM  Rain Detector is WET   Sensor is DRY 2 secs  was WET 259 secs
9:50:50 PM  Rain Detector is WET   Sensor is WET 2 secs  was DRY 4 secs
9:50:55 PM  Rain Detector is WET   Sensor is WET 7 secs  was DRY 4 secs
9:51:00 PM  Rain Detector is WET   Sensor is WET 12 secs  was DRY 4 secs
9:51:05 PM  Rain Detector is WET   Sensor is DRY 3 secs  was WET 14 secs
9:51:10 PM  Rain Detector is WET   Sensor is DRY 8 secs  was WET 14 secs
9:51:15 PM  Rain Detector is WET   Sensor is DRY 13 secs  was WET 14 secs
9:51:20 PM  Rain Detector is WET   Sensor is DRY 18 secs  was WET 14 secs
9:51:25 PM  Rain Detector is WET   Sensor is DRY 23 secs  was WET 14 secs
9:51:30 PM  Rain Detector is WET   Sensor is DRY 28 secs  was WET 14 secs
9:51:35 PM  Rain Detector is WET   Sensor is DRY 33 secs  was WET 14 secs
9:51:40 PM  Rain Detector is WET   Sensor is DRY 38 secs  was WET 14 secs
9:51:45 PM  Rain Detector is WET   Sensor is DRY 43 secs  was WET 14 secs
9:51:50 PM  Rain Detector is WET   Sensor is WET 3 secs  was DRY 44 secs
9:51:55 PM  Rain Detector is WET   Sensor is WET 8 secs  was DRY 44 secs


The first line of the above output shows current system state is WET (raining) and the RG-9 has been outputing a low level continuously for the last 256 seconds and before that it was showing no rain for 66 seconds.
The next line shows the RG-9 as switch its output to high (DRY), but in the following line it switches back to low output WET. The high output (DRY) only lasted for 4 seconds.
Since the output was not continuously high for 5mins the system maintains its raining (WET) status.

Collecting this data, via a telnet connection, over a number of hours/days through rainy weather will help you decide what start and stop raining delays to use to get the best result.

The result will not be perfect. So in this version of the code, the buzzer only sounds for 5sec when the system switches to the isRaining state and a window is open.

Conclusion

This project replaces the PCB rain detector in BLE Window/Door Open Detector and Rain Detector with an an Hydreon RG-9 rain detector. The RG-9 can detect when it is raining but also gives false readings and can be slow to detect when the rain starts and stops. As the RG-9 instruction sheet says “Apply engineering judgment: Hydreon does not claim the RG-9 is a perfect rain sensor. It is what it is, and senses what it senses.”

In this project added extended 'debounce' times were added to the start and stop raining indications to reduce the false triggers at the expense of the speed of detection.

Android TM is a trademark of Google Inc. For use of the Arduino name see http://arduino.cc/en/Main/FAQ


The General Purpose Android/Arduino Control App.
pfodDevice™ and pfodApp™ are trade marks of Forward Computing and Control Pty. Ltd.


Forward home page link (image)

Contact Forward Computing and Control by
©Copyright 1996-2024 Forward Computing and Control Pty. Ltd. ACN 003 669 994