RG-15 Rain Sensor¶
The Hydreon RG-15 is an optical rain sensor used in SQMeter to flag sky quality readings taken during active rainfall. Rain causes light scattering that makes SQM values unreliable, so the RG-15 lets the firmware mark affected readings accordingly. It is an optional peripheral.
Initialised means the ESP32 opened the UART. Online means the firmware received and parsed a valid RG-15 response.
Specifications¶
| Spec | Value |
|---|---|
| Supply voltage | 5 V or 12 V |
| Interface | UART (serial) |
| Default baud rate | 9600 |
| Output | ASCII polled or event-driven |
| Rain rate range | 0–999 mm/hr |
| Operating temp | −40 °C to +60 °C |
Wiring¶
The connector on the RG-15 PCB is labelled J2. Pin 1 is closest to the housing edge marked with a triangle.
| J2 Pin | Label | Connect to |
|---|---|---|
| 1 | GND | ESP32 GND |
| 2 | V+ | 5 V supply |
| 3 | OUT (open-collector) | Not required — leave unconnected |
| 4 | Serial OUT (TX from sensor) | ESP32 RX GPIO (default: GPIO 18) |
| 5 | Serial IN (RX into sensor) | ESP32 TX GPIO (default: GPIO 19) |
Pin direction
J2 pin 4 is the sensor's TX line — connect it to the ESP32 RX pin. J2 pin 5 is the sensor's RX line — connect it to the ESP32 TX pin.
Voltage levels
The RG-15 serial lines operate at 5 V. Most ESP32 GPIO inputs are 5 V-tolerant, but verify your specific board before connecting without a level shifter.
Serial protocol¶
The firmware communicates with the RG-15 over UART at 9600 baud, 8N1 by default.
If you enable rain.debugUart, the firmware logs the UART command/response flow to the serial console. This is safe to use in the field and does not expose WiFi, MQTT, or OTA secrets.
Poll command¶
In polling mode the firmware sends R\n to request a reading. The sensor responds with one ASCII line:
| Field | Description |
|---|---|
Acc |
Accumulation since the last poll (mm or in) |
EventAcc |
Accumulation since the start of the current rain event |
TotalAcc |
Cumulative total since the sensor last powered on |
RInt |
Current rain intensity (mm/h or in/h) |
Optional flag characters may appear after the unit suffix:
| Character | Meaning |
|---|---|
i |
Hardware / lens fault |
o |
Emitter saturation |
Configuration commands¶
The firmware sends these commands on startup to apply the configured mode:
| Command | Effect |
|---|---|
M |
Set metric output (mm) |
I |
Set imperial output (inches) |
H |
Set high resolution (0.01 mm / 0.001 in) |
L |
Set low resolution (0.2 mm / 0.01 in) |
DIP switches vs serial configuration¶
The RG-15 has DIP switches on the PCB that set defaults for units and resolution. On every power cycle the sensor reads the DIP switches and resets to those defaults.
SQMeter re-applies the configured units and resolution over serial each time the firmware starts or the sensor is reconfigured. This ensures the sensor operates in the mode you specified regardless of the DIP switch positions.
If you set units or resolution to "switch", the firmware does not send the corresponding command and the DIP switch setting is used instead.
Configuration¶
Add or update the rain block in the device settings page, or via POST /api/config:
"rain": {
"enabled": true,
"rxPin": 18,
"txPin": 19,
"baudRate": 9600,
"debugUart": false,
"mode": "polling",
"resolution": "high",
"units": "metric",
"pollIntervalMs": 5000,
"rainClearDelayMs": 900000,
"dailyResetEnabled": true,
"dailyResetHour": 0,
"dailyResetMinute": 0
}
| Field | Type | Default | Description |
|---|---|---|---|
enabled |
boolean | false |
Enable the RG-15 sensor |
rxPin |
integer | 18 |
ESP32 GPIO connected to sensor Serial OUT |
txPin |
integer | 19 |
ESP32 GPIO connected to sensor Serial IN |
baudRate |
integer | 9600 |
Serial baud rate (2400, 4800, 9600, 19200) |
debugUart |
boolean | false |
Log RG-15 UART command/response traffic |
mode |
string | "polling" |
Compatibility field; RG-15 communication is polling-only |
resolution |
string | "high" |
"high", "low", or "switch" |
units |
string | "metric" |
"metric", "imperial", or "switch" |
pollIntervalMs |
integer | 5000 |
Polling-mode interval between R read commands |
rainClearDelayMs |
integer | 900000 |
Local delay before SQMeter clears its raining latch after intensity returns to zero |
dailyResetEnabled |
boolean | false |
Send the RG-15 O command once per day to reset TotalAcc |
dailyResetHour |
integer | 0 |
Local-hour reset schedule for TotalAcc |
dailyResetMinute |
integer | 0 |
Local-minute reset schedule for TotalAcc |
Communication¶
SQMeter uses polling-only RG-15 communication. The firmware sends R on the configured pollIntervalMs cadence and reads the response. This proves the UART command/response path on every poll.
EventAcc is maintained by the RG-15 for the current rain event and resets about 60 minutes after the last detected drop. SQMeter also exposes a local raining boolean that stays true for rainClearDelayMs after the last non-zero intensity reading, so you can treat an event as over after 10, 15, 45, or another configured number of minutes.
TotalAcc persists until the RG-15 O reset command is sent or the counter rolls over. SQMeter can send O manually from the System page or on a daily schedule, commonly at 00:00, so the value can be treated as a resettable daily total instead of a lifetime total.
REST API¶
GET /api/sensors includes a rainSensor object with RG-15 readings and UART diagnostics:
{
"rainSensor": {
"enabled": true,
"sensor": "hydreon_rg15",
"initialized": true,
"online": true,
"stale": false,
"state": "online",
"timestamp": 123456789,
"ageMs": 40,
"status": 0,
"isRaining": false,
"raining": false,
"acc": 0.000,
"eventAcc": 2.400,
"event_accumulation": 0.000,
"hydreon_event_accumulation": 2.400,
"totalAcc": 12.340,
"rInt": 0.000,
"lensBad": false,
"emSat": false,
"uart": {
"configured": true,
"opened": true,
"rx_pin": 18,
"tx_pin": 19,
"baud_rate": 9600,
"uart_port": 1,
"mode": "polling",
"resolution": "high",
"units": "metric",
"debug_uart": false,
"last_command": "R",
"last_raw_response": "Acc 0.00 mm, EventAcc 0.00 mm, TotalAcc 1.24 mm, RInt 0.00 mm/h",
"last_error": null,
"timeouts": 0,
"parse_errors": 0,
"successful_reads": 42
}
}
}
| Field | Description |
|---|---|
enabled |
true when RG-15 is enabled in config |
sensor |
Fixed sensor identifier (hydreon_rg15) |
initialized |
true when the UART is open |
online |
true after a valid RG-15 response has been received |
stale |
true when the last valid reading is too old |
state |
Current communication state (configured, awaiting_response, online, etc.) |
timestamp |
Timestamp of the last valid reading |
ageMs |
Age of the last valid reading in milliseconds |
status |
0 = OK, 1 = not initialised, 2 = read error / invalid data, 3 = timeout |
isRaining |
true if current rain intensity is above zero |
raining |
Locally latched rain state using rainClearDelayMs |
acc |
Accumulation since last poll |
eventAcc |
Raw Hydreon event accumulation, cleared by the sensor's own event timer |
event_accumulation |
SQMeter local event accumulation, cleared by rainClearDelayMs |
hydreon_event_accumulation |
Alias for raw Hydreon EventAcc |
totalAcc |
Daily/resettable total accumulation |
rInt |
Rain intensity in configured units per hour |
lensBad |
true if the sensor reported a hardware / lens fault |
emSat |
true if the sensor reported emitter saturation |
uart |
UART diagnostic block with command, response, timeout, and parse counters |
GET /api/status includes an rg15 entry under sensors with the same diagnostic block:
{
"sensors": {
"rg15": {
"enabled": true,
"initialized": true,
"online": true,
"stale": false,
"state": "online",
"status": 0,
"lastUpdate": 1234567890,
"uart": {
"last_command": "R",
"last_raw_response": "Acc 0.00 mm, EventAcc 0.00 mm, TotalAcc 1.24 mm, RInt 0.00 mm/h",
"last_error": null,
"timeouts": 0,
"parse_errors": 0,
"successful_reads": 42
}
}
}
}
Communication test¶
Use POST /api/sensors/rg15/test to trigger a manual RG-15 read and inspect the raw response details:
The response includes the command sent, bytes written, raw response, acknowledgement status, parse status, elapsed time, and a troubleshooting hint if the read times out.
Use these endpoints from the System page or directly when bringing up hardware:
curl -X POST http://sqm-esp32.local/api/sensors/rg15/reset-total
curl -X POST http://sqm-esp32.local/api/sensors/rg15/reboot
reset-total sends O and expects the o acknowledgement. reboot sends the RG-15 restart command K; after reboot, the sensor is marked offline until fresh UART traffic is received and parsed.
MQTT¶
When MQTT is enabled, the rain sensor reading is included in the published payload under the rain key:
{
"rain": {
"enabled": true,
"initialized": true,
"online": true,
"stale": false,
"status": 0,
"isRaining": false,
"raining": false,
"acc": 0.000,
"eventAcc": 2.400,
"event_accumulation": 0.000,
"hydreon_event_accumulation": 2.400,
"totalAcc": 12.340,
"rInt": 0.000,
"uart": {
"last_command": "R",
"last_raw_response": "Acc 0.00 mm, EventAcc 0.00 mm, TotalAcc 1.24 mm, RInt 0.00 mm/h",
"timeouts": 0,
"parse_errors": 0,
"successful_reads": 42
}
}
}
The MQTT topic is configured by mqtt.topic (default: sqm/data).
Sensor placement¶
- Mount outdoors with an unobstructed view of the sky.
- Keep away from roof overhang drip zones — drips from overhangs trigger false positives.
- Mount on a level surface so water drains correctly.
- Avoid locations where debris or bird activity is likely.
Freezing climates
Hydreon offers the RG-15H heated variant for installations where icing is a concern. It is a drop-in replacement — the interface and wiring are identical.
Troubleshooting¶
| Symptom | Likely cause | Fix |
|---|---|---|
initialized: true but online: false |
UART opened but no valid RG-15 response yet | Check wiring, baud rate, and sensor power |
status: 2 (read error / invalid data) |
Wiring fault or malformed response | Verify J2 pin 4 → ESP32 RX, J2 pin 5 → ESP32 TX |
status: 3 (timeout) |
Sensor not sending data | Check power, baud rate, mode setting, and the debug UART logs |
| Values always zero | Sensor in DIP switch units that differ from config | Set resolution/units to match, or use "switch" mode |
lensBad: true |
Lens fouled or hardware fault | Clean the lens; replace sensor if fault persists |
emSat: true |
Very intense light source near sensor | Check for direct sunlight hitting the emitter |
What successful debug logs look like:
[RG15] UART begin rx=16 tx=17 baud=9600
[RG15] forcing metric units: TX "M"
[RG15] RX ack "m" after 42ms
[RG15] forcing high resolution: TX "H"
[RG15] RX ack "h" after 39ms
[RG15] poll TX "R"
[RG15] RX raw: "Acc 0.00 mm, EventAcc 0.00 mm, TotalAcc 1.24 mm, RInt 0.00 mm/h"
[RG15] parsed acc=0.00 event=0.00 total=1.24 intensity=0.00 unit=mm
[RG15] online=true age=0ms
What timeout logs look like:
[RG15] UART begin rx=16 tx=17 baud=9600
[RG15] forcing metric units: TX "M"
[RG15] timeout waiting for ack "m" after 500ms
[RG15] sensor remains offline: no UART response received
If you still get no response:
- Swap RX/TX if the wiring is reversed
- Check that the RG-15 and ESP32 share a common ground
- Verify the configured GPIO pins are correct and not shared with another peripheral
- Confirm the baud rate matches the sensor
- Confirm the sensor has power and the serial level is compatible
- Use a USB-UART adapter or logic analyser if you need to confirm the line activity directly