lightning-distance¶
How far away was that lightning? Count the seconds between the flash and the thunder, and divide — sound takes roughly 5 seconds per mile (3 seconds per kilometer). If the gap is 30 seconds or less, the storm is close enough to be dangerous: go inside and wait 30 minutes after the last thunder.
lightning-distance is a pure-Rust, zero-dependency crate that does both
the distance estimate and the 30-second safety check. It is the math behind the
EarlyThunder storm tracker, a free tool for
judging lightning safety outdoors.
Why the rule works¶
Light travels near-instantly; sound is slow (~343 m/s). So the delay between seeing the flash and hearing the thunder is essentially the sound's travel time:
| Delay (seconds) | Miles | Kilometers | Verdict |
|---|---|---|---|
| 5 | 1.0 | 1.7 | dangerous |
| 10 | 2.0 | 3.3 | dangerous |
| 15 | 3.0 | 5.0 | dangerous |
| 30 | 6.0 | 10.0 | dangerous (cutoff) |
| 45 | 9.0 | 15.0 | safer, still watch |
| 60 | 12.0 | 20.0 | likely safe |
The 30-second rule: if thunder follows the flash within 30 seconds, the strike was within ~6 miles — close enough that the next strike could reach you. The standard advice is to shelter for 30 minutes after the last thunder you hear.
Install¶
Quick start¶
use lightning_distance::{miles, kilometers, is_dangerous};
let delay = 10.0; // seconds between flash and thunder
let mi = miles(delay); // ≈ 2.0
let km = kilometers(delay); // ≈ 3.33
let danger = is_dangerous(delay); // true (≤ 30 s)
println!("{mi:.1} mi / {km:.1} km — danger: {danger}");
Track a whole storm
The crate gives you the per-flash math. For a live storm timeline with approach/retreat detection, use the EarlyThunder storm tracker.
Features¶
- Pure Rust, no deps —
f64arithmetic, single file, no features. - Miles & kilometers — from the flash-to-thunder delay.
- 30-second rule —
is_dangerousboolean safety check. - Tunable constants —
SECS_PER_MILE,SECS_PER_KM,DANGER_THRESHOLD_SECS. - MIT licensed — embed anywhere (wearables, weather apps, IoT).
Links¶
- Source crate:
theluckystrike/earlythunder - Interactive tool: EarlyThunder