Rain Sensor Circuit Margins

Ada re-derives this chapter’s own numbers step by step, at full precision

foundations
math-foundations
calculation-audit
sensors
Ada ADA · CALCULATION AUDIT

Rain Sensor Circuit Margins

Check the circuit as a chain: divider range first, then filter attenuation, then transistor drive. Each number below comes from the rain-sensor design values already stated in the chapter.

A rain-sensor circuit uses a 47 kOhm pull-up against a sensor resistance that swings from 1 MOhm dry to 10 kOhm in heavy rain, an RC filter built from 10 kOhm and 1 uF to knock down 20 kHz motor noise, and a 1 kOhm base resistor driving a 500 mA relay coil from a GPIO limited to 12 mA — the whole design costing EUR 0.48 in parts. This audit asks the question those three margins invite: do the divider range, the filter attenuation, and the transistor drive current all actually clear their limits at once, or does one of them run out of headroom?

Companion to the chapter Sensor Circuit Fundamentals — every number here comes from that chapter.

Divider arithmetic

With a 47 kOhm pull-up and a 3.3 V rail, the sensor-bottom divider gives Vout = 3.3 * Rsensor / (47000 + Rsensor). Dry at 1 MOhm gives 3.3 * 1000000 / 1047000 = 3.1519 V. Light rain at 100 kOhm gives 3.3 * 100000 / 147000 = 2.2449 V. Heavy rain at 10 kOhm gives 3.3 * 10000 / 57000 = 0.5789 V. The heavy-rain current is 3.3 / 57000 = 0.00005789 A = 0.0579 mA, below the 0.5 mA budget.

Filter arithmetic

For the selected 10 kOhm and 1 uF filter, RC = 10000 * 0.000001 = 0.010 s and fc = 1 / (2 * pi * 0.010) = 15.915 Hz. A 20 kHz motor spike is 20000 / 15.915 = 1256.6 times above cutoff. The first-order magnitude is 1 / sqrt(1 + 1256.6^2) = 0.0007957, which is 20 * log10(0.0007957) = -61.98 dB. A 50 mV spike becomes 50 * 0.0007957 = 0.0398 mV, safely below the 12-bit ADC step 3.3 / 4095 = 0.0008059 V = 0.8059 mV.

Relay-drive arithmetic

The 500 mA relay coil with beta 200 needs 500 / 200 = 2.5 mA of base current. The base resistor drops 3.3 - 0.7 = 2.6 V, so the computed value is 2.6 / 0.0025 = 1040 Ohm. The selected 1 kOhm resistor drives 2.6 / 1000 = 0.0026 A = 2.6 mA, still under the 12 mA GPIO limit while giving enough transistor drive for the 500 mA coil.

Ada’s conclusion: the chosen values pass the three margins at once. The divider stays inside the ADC range, the filter reduces the 20 kHz spike below one ADC count, and the GPIO current remains well below its limit while controlling the relay.

Every number above is taken from the chapter’s own rain-sensor design values and re-derived step by step.