Based on scientific research, the distance of a thunderstorm can be statistically calculated from the observation of lightning flashes and thunder sounds. The US National Weather Bureau suggests the 30-30 rule when lightning is imminent: when a flash is seen and the thunder is heard less than 30 seconds later, the storm is within 10 km.
The AS3935 from austriamicrosystems is a programmable Lightning Sensor IC that detects the presence and approach of potentially hazardous lightning activity in the vicinity. It detects intra-cloud activity as well as cloud to ground flashes, often enabling risk to be evaluated for approaching storms. The new chip detects lightning activity as it approaches from up to 40 km away which provides a much longer distance for lightning warning. In addition, the device identifies and rejects interference signals from common man-made sources such as: fluorescent lighting, motors, microwave oven, switches, etc.
The flexible IC allows for configurability that allows the part to work both indoors as well as outdoors, just changing the gain setting in a register.