Hello friends, I hope you all are doing great. Today, I am going to share the new AS3935 Lightning Sensor Library for Proteus Simulation. The AS3935 is a small chip that listens to the radio crackle of lightning with a 500 kHz antenna, tells real strikes apart from the clicks of motors and switches, and estimates how far away the storm is - from 40 km down to overhead. With this library you can run a full Proteus simulation of the AS3935 board with a storm rolling in, tune its antenna exactly as you would on the bench, and build a lightning alarm with your Arduino.
AS3935 Lightning Sensor Library for Proteus
Latest version: V1.0 (December 2026, this tutorial)
Other weather sensors: Rain Gauge · Rain Sensor · BME280 Sensor
Helping Tools
- Serial Monitor Advance: a serial terminal window for the UART of your board
- Serial Monitor Expert: the serial monitor with extra debugging tools
- LCD Library for Proteus V3.0: 16x2, 20x4 and I2C LCDs to show your readings
The demo is a lightning alarm: an Arduino UNO V4.0 first tunes the sensor's antenna, then reports every strike, shows the distance to the storm on a 16x2 LCD, lights a green, yellow or red LED and sounds a buzzer when the storm is closer than 10 km.
NOTICE: Our team has put a lot of effort into these small parts: the bodies, the animation and the pop-ups are all our own design, and you get them free. Your feedback is the fuel that keeps us going, so please tell us what you think in the comments below or in the weather sensor board of our forum. And if our free libraries help you, you can buy us a coffee. So, let's get started with the AS3935 Lightning Sensor Library for Proteus Simulation:
What Is the AS3935 Lightning Sensor?
Every lightning strike is a huge current pulse, and every current pulse sends out a burst of radio waves. Long before you hear the thunder, these bursts travel tens of kilometres, and a radio tuned to a few hundred kilohertz hears them as crackles. The AS3935 is built around exactly that idea. Its antenna is a small coil with a capacitor, a tuned circuit resonating at 500 kHz. The chip amplifies what the antenna picks up and looks at the shape of every pulse. A lightning signal has a typical pattern; a motor, a relay or a switching supply makes pulses with a different pattern. The chip calls the first kind lightning and the second kind a disturber, and it tells you which one it saw.
From the strength and the history of the strikes, the AS3935 also estimates how far away the storm is. The estimate is not the distance of the last flash - lightning jumps around inside a storm - but the distance to the leading edge, the head of the storm, from the statistics of the recent strikes. The answer comes in 15 steps: out of range, 40, 37, 34, 31, 27, 24, 20, 17, 14, 12, 10, 8, 6 and 5 km, and finally "storm overhead". For every strike the chip also stores an energy value, a pure number that is larger for strong, close strikes and has no physical unit.
The AS3935 Breakout Board
The common breakout is a small board of about 24 x 20 mm. It carries the AS3935 in its 4 x 4 mm package, the antenna coil with its tank capacitors, a few decoupling parts and a five-pin header: VCC, GND, SCL, SDA and IRQ. The chip can talk SPI or I2C; on this board its SI pin is tied high, so it speaks I2C. Two solder pads, ADD0 and ADD1, set the address to 0x01, 0x02 or 0x03 - both closed gives 0x03, the usual setting. The supply can be anything from 2.4 V to 5.5 V.
The Registers
- 0x00: the gain of the front end (indoor 10010, outdoor 01110) and the power-down bit.
- 0x01: the noise floor level (eight steps) and the watchdog threshold.
- 0x02: clear the statistics, the minimum number of strikes before the first alarm (1, 5, 9 or 16) and the spike rejection.
- 0x03: the frequency division for antenna tuning, the disturber mask and, in bits 3:0, the interrupt reason.
- 0x04 - 0x06: the energy of the last strike, 21 bits.
- 0x07: the distance to the head of the storm, in km (63 = out of range, 1 = overhead).
- 0x08: the oscillator display bits and the tuning capacitor TUN_CAP, 0 to 120 pF in 8 pF steps.
- Direct commands: writing 0x96 to 0x3C restores every register (PRESET_DEFAULT); 0x96 to 0x3D calibrates the internal RC oscillators (CALIB_RCO).
The IRQ Pin and the 2 ms Rule
The AS3935 does not need to be polled. When something happens it drives IRQ high. The datasheet asks you to wait 2 ms and then read register 0x03: bits 3:0 hold 8 for lightning, 4 for a disturber, 1 for "noise too high", or 0 when the distance changed only because old strikes were dropped from the statistics. Reading the register sets IRQ low again. If you read too early the reason is not there yet - the simulation shows that mistake in its event log and check page.
Antenna Tuning
The antenna must resonate within 3.5 % of 500 kHz, and no two coils are exactly alike. That is why the chip has the tuning capacitor bank TUN_CAP and a test mode: set DISP_LCO in register 0x08 and the antenna's own oscillator, divided by 16, 32, 64 or 128, appears on the IRQ pin. Your microcontroller measures that frequency for each of the 16 capacitor settings and keeps the one closest to 500 kHz. Adding capacitance lowers the frequency, so an antenna that comes out a little high is pulled down to the target.
Features of the AS3935 Library
- A real-looking board: the breakout at its true size, the chip, the antenna coil, the address pads and the header; the antenna flashes on each strike.
- The registers of the datasheet: gain, noise floor, watchdog, spike rejection, minimum strikes, disturber mask, the direct commands and the calibration flags.
- A true IRQ: active high, with the 2 ms rule and the four interrupt reasons.
- Antenna tuning: the antenna's oscillator on IRQ through the divider, shifted by TUN_CAP in 8 pF steps.
- The distance and the energy: the 15 distance steps to the head of the storm and an energy value per strike.
- A storm: PROFILE DEMO rolls a storm in from 42 km to overhead with two disturbers and a noisy spell; QUIET is a calm sky.
- A pop-up: the sky as a radar, the event list, the registers as tiles; graphs, an event log and a check page.
- A complete package: about 2.7 MB with the library, our I2C LCD, resistors, LEDs, buzzer, our Arduino UNO V4.0 and the demo, without the source code of the model.
The AS3935 in Proteus
The device is AS3935TEP in TEPAS3935.LIB, under Modules > Sensors, with the model TEPAS3935.DLL. Search AS3935 or lightning in Pick Devices. Its five pins are the header of the real board. Three properties set it up: ADDRESS (1, 2 or 3), PROFILE (DEMO or QUIET) and ANTENNA, the antenna's own frequency in kHz before tuning - 520 by default, so there is something to tune.
Download AS3935 Lightning Sensor Library for Proteus Simulation
Click the button below to download AS3935-Lightning-Sensor-Library-for-Proteus-v1.0.zip (about 2.7 MB, without the source code of the models):
AS3935 Lightning Sensor Library for Proteus V1.0- README.txt: installation, the demo, the wiring, troubleshooting and the limits of the simulation.
- Proteus Library Files:
TEPAS3935.LIB,TEPI2CLCD16X2.LIB,TEPRESISTOR.LIB,TEPLED5MM.LIB,TEPBUZZER.LIBandArduinoV4TEP.LIB. - Proteus Model Files:
TEPAS3935.DLL,TEPLCD.DLL,TEPRESISTOR.DLL,TEPLED5MM.DLL,TEPBUZZER.DLLandTEPARDUINO.DLL. - Arduino Code: the demo sketch (Wire only).
- Proteus Simulation: the demo project, its HEX file and copies of the DLLs.
No Proteus yet? Read How to Download and Install Proteus 7 and 8. New to libraries? Follow How to Install a New Library in Proteus.
How to Install AS3935 Lightning Sensor Library for Proteus Simulation
- Close Proteus and extract the whole zip file, for example to your Desktop.
- Copy the files from Proteus Library Files into the LIBRARY folder of Proteus.
- Copy the files from Proteus Model Files into the MODELS folder.
- Delete
TEPAS3935.IDXfrom the LIBRARY folder if it is there. - Start Proteus, press P and search for AS3935.
Proteus Simulation of a Lightning Alarm
The demo uses an A4 sheet with our Arduino UNO Library for Proteus V4.0. The sensor (U1) sits on the I2C bus at 0x03 with A4 and A5, and its IRQ goes to D2, an interrupt pin. A 16x2 LCD from our I2C LCD 16x2 Library for Proteus shares the bus at 0x27. Three LEDs on D5 to D7 show the danger - green all clear, yellow a storm in range, red closer than 10 km - and BZ1 from our Active Buzzer Library for Proteus on D8 beeps while the storm is that close. The Arduino's monitor is built in, the same window as our TEP Serial Monitor Advance for Proteus. Open AS3935-Lightning-Alarm-ArduinoUnoV4.pdsprj.
The Sketch
The tuning comes first. With DISP_LCO set and the divider at 128, the interrupt routine timestamps the edges of the antenna's oscillator on IRQ - the first and the 200th:
if (edges == 0) tFirst = t;
if (edges == EDGES) tLast = t;
200 periods of the divided oscillator take about 50 ms, so the 4 us steps of micros() give the frequency to better than 0.01 %. Multiplying back by 128 gives the antenna's frequency:
return (long)(EDGES * 128.0 * 1000000.0 / (tLast - tFirst) + 0.5);
After all 16 capacitors the best one is written to register 0x08 and CALIB_RCO calibrates the oscillators. From then on the interrupt only sets a flag, and the main loop follows the datasheet - wait 2 ms, then read the reason:
delay(2); // the datasheet: wait 2 ms before reading the interrupt
const byte why = asRead(0x03) & 0x0F;
For lightning it reads the 21-bit energy from three registers and the distance from register 0x07:
const unsigned long energy = asRead(0x04) | ((unsigned long)asRead(0x05) << 8) | ((unsigned long)(asRead(0x06) & 0x1F) << 16);
For "noise too high" it raises the noise floor one step, and a second after the last noise it lowers it again, one step every half second:
if (nfLev < 7) setFloor(nfLev + 1);
AS3935 Simulation Results
Open the project and press Run. The demo runs 6.4 simulated seconds and took about 2 minutes 16 seconds on our PC with the pop-up open and the pictures being taken. Click U1 for its pop-up. Every number below comes from one simulation run, the demo exactly as it ships. The storm runs in fast time - on the real chip the statistics cover 15 minutes, here one second - so a whole thunderstorm passes in a few seconds.
Tuning the Antenna
The sketch starts by restoring the defaults with PRESET_DEFAULT, setting the indoor gain and the noise floor level 2, and then it scans the antenna. This board's antenna starts at 520 kHz with no tuning capacitor - 4 % high, outside the datasheet's 3.5 % window. Each 8 pF step pulls it down by about 2 kHz: TUN_CAP 5 reads about 509 kHz, TUN_CAP 9 about 501.1 kHz and TUN_CAP 10 about 499.1 kHz. The sketch keeps 10, less than 0.2 % below 500 kHz, writes it to register 0x08 with DISP_LCO off and sends CALIB_RCO; the event log shows the RC oscillators calibrated at 1.140 s. The whole scan of 16 capacitors takes a little over a second, and at the end of the run the check page confirms the antenna at 499.1 kHz, in green.
The Storm Approaches
At 1.3 s the storm appears 42 km away and moves in at 12 km per second. Its first strikes are just out of reach; the first one the chip detects comes at 1.70 s, 39 km away, and the distance register reads 40 km. At 1.90 s a strike 38 km away moves it to 37 km. The pop-up at 1.99 s shows the amber banner "STORM - the head 37 km away", the two strikes as dots on the radar and the register as an amber arc, while the true head of the storm is already at 34 km - the estimate is always a step behind, because it needs new strikes to move. The LCD reads "Storm 37 km" and "Hits 2 Dist 1", and the yellow LED is on. From then on a strike every 0.2 s walks the register down the datasheet's table: the monitor shows 24 km at 3.04 s, 20 km at 3.24 s and 17 km at 3.44 s.
Disturbers
Twice in the run a man-made signal reaches the antenna, at 1.75 s and 2.95 s - think of a motor starting or a light being switched. The chip sees that the pulse does not have the shape of lightning, raises IRQ with the reason 4 and leaves the distance and the strike count alone. The sketch prints "disturber - a man-made signal, not lightning", counts it on the LCD's second line and does not sound the alarm. Where disturbers are frequent, MASK_DIST in register 0x03 silences them and a higher spike rejection in register 0x02 rejects them more firmly.
Noise Too High
At 3.6 s an appliance near the sensor raises the noise at the antenna to 100 uVrms. With the noise floor at level 2, 62 uVrms, the chip can no longer tell lightning from noise: it raises IRQ with the reason 1, and keeps raising it while the noise stays above the floor. The sketch answers each one by raising the floor a step - to level 3 (78 uVrms) at 3.54 s, level 4 (95 uVrms) at 3.64 s and level 5 (112 uVrms) at 3.74 s - and above the noise the alarms stop. The pop-up at 3.73 s shows the orange banner "NOISE TOO HIGH - 100 uVrms at the antenna: lightning cannot be detected", the floor being stepped up in the event list, and the price of it in the range tile: 33 km at level 4 instead of 40 km. One strike fell inside the noisy spell and was lost.
The Storm Within 10 km
The strikes come in again as soon as the noise is under the floor: 12 km at 3.84 s, then 10 km at 4.04 s - the LED turns red and the buzzer starts beeping four times a second - and 8 km at 4.24 s. The pop-up at 4.45 s shows the red banner "STORM - the head 8 km away" with 13 strikes detected, the strikes packed close to the centre of the radar, and the antenna on the board flashing at every strike. Its range tile still shows 30 km, because the floor is at level 5 - the sketch only lowers it a second after the last noise, at 4.74 s.
Overhead, and All Clear
At 4.64 s the register reads 1 - storm overhead - and it stays there for the strikes at 4.84 s and 5.04 s; the LCD shows "STORM OVERHEAD!". The energies of these close strikes are the largest of the run, 1.1 to 1.6 million, against about 0.33 million for the first strikes at 38 and 39 km - a pure number, but a useful hint of how strong and how close a strike was. Meanwhile the noise floor comes back down: level 4 at 4.74 s, 3 at 5.24 s and 2 at 5.74 s.
The storm stops at 5.2 s. For a second the old strikes keep the register at overhead, because the statistics still hold them; then they are purged. At 6.04 s IRQ rises once more, with the reason 0, and register 0x07 reads 63 - out of range. The sketch prints "distance update (old strikes purged): out of range - all clear", the LCD shows "All clear" and "Hits 17 Dist 2", the buzzer stops and the green LED comes back. The pop-up at 6.40 s shows the green banner and an empty radar. On the real chip this happens 15 minutes after the last strike, which matches the usual advice to wait half an hour after the last thunder before going back outside.
The Graphs, the Event Log and the Check Page
The Graphs page plots the true head of the storm next to the distance register - the steps of the estimate follow the straight line of the storm - the interrupts as they add up, and the noise at the antenna. The Event log lists the set-up writes, the tuning and every strike. The Check page sums up the run: the supply at 5.00 V and the address 0x03; the antenna at 499.1 kHz with TUN_CAP 10, 0.2 % from 500 kHz and inside the datasheet's 3.5 %; the RC oscillators calibrated; 17 of 20 strikes detected - two were beyond 40 km when the storm appeared and one fell in the noise - and the register out of range at the end; and 23 interrupts: 17 lightning, 2 disturbers, 3 noise and 1 distance purge, none of them read before the 2 ms.
The Arduino's built-in serial monitor tells the whole story in text: the tuning table with a line for each capacitor, the chosen capacitor and the calibration, then a line for every interrupt - each strike with the head of the storm and its energy, the disturbers, the noise floor going up and coming down, and the final all clear.
Why the Head of the Storm?
A thunderstorm is not a point. It is a cell, often 10 km or more across, moving with the wind, and its strikes land anywhere inside it. The distance of one flash says little; what matters for safety is how close the nearest part of the storm is. The AS3935 keeps the recent strikes and estimates the distance to that leading edge, so its answer moves smoothly as the storm approaches, while the energy of each strike jumps up and down. The radar in the pop-up shows both: the dots are single strikes, the amber arc is the register.
Indoor or Outdoor Gain?
The front end has two gain settings. Indoors the walls weaken the signal, so the indoor gain is higher; outdoors the antenna hears more, also more noise, so the outdoor gain is lower. In this simulation the outdoor gain used indoors costs about half the range. The noise floor works in the same direction: raising it stops the "noise too high" alarms near a noisy appliance, but weak, far strikes are lost - the pop-up's range tile shows 30 km at floor 5 instead of 40 km.
AS3935 and Other Weather Sensors
Lightning is one part of a weather station. Our Rain Gauge Library for Proteus measures how much rain fell, our Rain Sensor Library for Proteus tells you when it starts, and our BME280 Sensor Library for Proteus gives the temperature, humidity and air pressure - a falling pressure is the classic sign of a coming storm. Put them on one Arduino and the AS3935 becomes the early warning of a complete station.
Try It Yourself
- Click U1 while the simulation runs and use the chips: Strike 10 km, Disturber and Noise burst add events at any time.
- Set ANTENNA to 560: the tuning scan cannot reach 500 kHz any more, and the check page turns red.
- In setup(), write 0x1C instead of 0x24 to register 0x00 (the outdoor gain): the far strikes disappear.
- In setup(), write 0xD2 to register 0x02 (MIN_NUM_LIGH = 5): the first alarm waits for the fifth strike.
- In tuneAntenna(), write 0xE0 instead of 0xC0 to register 0x03 (MASK_DIST): the disturbers no longer raise IRQ.
Ideas to Extend the Demo
- Send an alert to your phone with an ESP32 when the storm comes within 20 km.
- Log every strike with its time and energy to an SD card.
- Disconnect an outdoor antenna or a garden pump automatically while the storm is overhead.
Your Own Sketches
The demo sketch is in the zip file, and you can change it in the Arduino IDE. New to Arduino? Start with our Arduino Tutorial for Beginners. Export the compiled binary, and set the UNO's PROGRAM property to the new file. Our guide on How to get the HEX file from Arduino shows you where the file ends up.
Things to Know Before Using a Real AS3935
- Placement: keep the antenna away from monitors, motors, LED drivers and switching supplies - they are the disturbers and the noise.
- Tuning: tune the antenna once on every board; the result can be stored in EEPROM.
- Gain: indoor gain inside the house, outdoor gain outside.
- Statistics: the real chip estimates over 15 minutes, so the first distance after a quiet spell needs a few strikes.
- Safety: a lightning sensor gives a warning, not protection - follow the usual advice when you hear thunder.
Troubleshooting
- No event at all: IRQ is not on an interrupt pin, or the sketch waits for LOW - IRQ is active high.
- The interrupt reads 0: it was read less than 2 ms after IRQ rose.
- Only "noise too high": raise the noise floor or move the antenna away from the noise.
- The antenna is far from 500 kHz: run the tuning scan; the check page shows the error.
- The part is not simulated:
TEPAS3935.DLLis missing from MODELS and from the project folder.
Limitations of the Simulation
- The registers, the direct commands, IRQ with the 2 ms rule, the distance table, the noise floor levels and the tuning range follow the AS3935 datasheet; the board is our own drawing.
- Our own figures: a 937 pF antenna tank, the range of 40 km at the indoor gain (less with the outdoor gain, a higher watchdog or a raised noise floor), the statistics over one second and the storm at 12 km per second.
- Not modelled: SPI mode, the TRCO and SRCO outputs on IRQ, and the real detection algorithm - the strikes come from the DEMO storm or the pop-up.
- Arduino is a name of Arduino; this library is not made or endorsed by Arduino, Labcenter or the maker of the AS3935.
- Tested in Proteus 8.5 in November 2026 (the demo as shipped). Proteus 7 is not supported.
So, that was all about the AS3935 Lightning Sensor Library for Proteus Simulation. I hope it helps you build a lightning alarm that tells you a storm is coming long before the first thunder. If you have any questions, ask in the comments and I will help you out. Till the next tutorial, take care and have fun!