Category Archives: Weather Station

Lightning Sensor Arduino Shield

How cool would it be to have a sensor that warns you of lightning strikes within a 40km radius?  Maybe you need to be alerted to unplug an antenna or sensitive electrical equipment.  Maybe you want to know when to bring the kids/pets inside.  The possibilities are really endless.  My goal was to connect it to my arduino powered weather station, and that is what I did.

Parts Needed:


The pinout mappings depend on what arduino board you are using and if you are using I2C or SPI.  You should match the pins accordingly to your board’s specs.

MOD-1016Uno R3Leonardo
IRQ2 or 33, 2, 0, 1, or 7

Wire-up the sensor module to the proto shield and solder it all together.  You can do the wiring however you want but I ran the wires on the bottom.  Then solder the headers onto the proto shield.  It should look something like this:



I’m utilizing the AS3935 arduino library HERE written by raivisr.  Keep in mind that technically this library was written for a different AS3935 breakout board, but since it’s the same chip it should be fine.  Also, they are using a Mega so their documentation has different pinouts.  Use the example included with the library to get started.  You will need to change the following bits of code to get it to work:


AS3935 AS3935(SPItransfer,SS,2);


int PIN_IRQ = 2;  // Your IRQ pin, mine is 2
int PIN_CS  = 10; // Your sensor's CS pin, mine is 10
AS3935 AS3935(SPItransfer,PIN_CS,PIN_IRQ);

The attachInterrupt() function requires the interrupt ID for the pin you are using.  This table identifies the interrupt value and the associated Arduino pins:

Uno R3, Ethernet23----





int myIRQ = 0 // You need to change this to your IRQ

Comment out the calibration function and add our custom tune function instead:

// Serial.println("Tuning out of range, check your wiring, ...");

AS3935.tune(4);  // The number I used here (4) came on the packaging

Add the following function to the AS3935.cpp library file:

void AS3935::tune(int tuneValue)

And add the following to the “public” class in the AS3935.h library file:

void tune(int tuneValue);


It’s time to begin testing the serial output from the sensor.  Open your serial console window in the arduino IDE and see what’s going on.  You should see this:


Extending Use:

Some other ideas for how to extend the use of this shield…

  • Hook it in to your personal weather station
  • Connect an LCD screen or LED matrix
  • Send a tweet



My Tips for Sparkfun’s Wireless Weather Station

If you haven’t seen it already, check out Sparkfun’s guide on how to build your own weather station that reports statistics to Weather Underground ( here:

In this and my next few posts I will show how I built my station along with some extra tips and tricks that are not included in Sparkfun’s tutorial.  I will also be adding posts in the near future to expand the capability of the weather station with additional sensors.

Tip #1: It’s either the red enclosure OR the radiation shield, not both!

The full red enclosure will NOT fit inside the Ambient Weather solar radiation shield.  I would not recommend building a weather station without the solar shield because you WILL have incorrect temperature readings.  I was, however, able to utilize the cover of the red enclosure to house the components safely inside of the solar shield using some of the upcoming tips!

Tip #2: Install the male headers onto the weather sensor shield backwards

This will allow you to put the sensors outside of your enclosure to get the most accurate readings.  The photo below shows the top of the Sparkfun weather shield prior to soldering in the male headers.  I’ve used a spare proto shield on the bottom to temporarily hold everything in place while I solder.



Tip #3: Cut a hole into the red enclosure lid so the male headers of the weather sheild can attach to the rest of the components inside

Use the Sparkfun weather shield as a stencil to mark out the areas on the enclosure to remove.



Then take your time and remove the plastic so the headers and the nubs of the RJ-11 jacks fit through.  This will allow your weather shield to sit flush up against the enclosure.  Notice that I did not take my time so it looks a bit sloppy.  Use hot glue to hold it in place and create a nice seal to prevent moisture from entering the enclosure.


Tip #4: Mount a right-angle female JST to the Wireless IMP shield

This step is not specifically mentioned in the Sparkfun tutorial, however it is shown in their photos.  I made the mistake of connecting the load output of the Solar Buddy MPPT shield to the barrel jack of the Arduino because it wasn’t specifically mentioned not to.  The barrel jack expects at least 4.something volts, which the 3.7 volt LiPo battery will only produce when there is over 85% battery capacity.  Once it gets below this threshold, your wireless IMP and weather sensors will not receive enough power.  So, instead solder the right-angle female JST connector to the wireless IMP shield as shown.


Tip #5: Make blink programming easier with components mounted in the enclosure lid

As you can see, the wireless IMP sits almost flush with the edge of the enclosure, so to reprogram wireless settings you would need to remove it.  This causes unnecessary wear and tear on the components and is kind of a pain in the butt.  Instead, drill a hole directly above the center of the wireless IMP’s photo sensor, and then insert a small piece of the plastic light tube.  This allows you to re-blink the IMP from outside the case.  Note that in my photo, the hole is not directly centered.  You can ignore that.



Tip #6:  Use a 2.5mm screw terminal instead of soldering wires directly to the Sunny Buddy’s load

This step makes it easy if you need to temporarily disconnect or rewire something for testing.


Tip #7:  Use a voltage step-up module

This tip builds on Tip #4.  The 3.7 volt LiPo battery supplied will output about 4.2 volts when fully charged but as time goes on, if it’s not being recharged by the solar panel, the voltage will drop.  Once it gets below about 3.26 volts, there is not enough power to run the weather station.  I found a 5v step-up module (MOD-1017-5V) from Embedded Adventures that can take anything from 0.9v and bump it up to 5v at 1 Amp.  Simply wire the module between the Sunny Buddy load output (module’s input) and the JST connector (module’s output) on the IMP shield and you are good to go.  Or, if you are feeling ambitious, you can solder the step-up module right to the IMP shield.  If you do that you’ll also have to cut some of the traces on the back of the shield.


Tip #8:  Add a lightning sensor!

See my post on creating a Lightning Sensor Arduino Shield for instructions on how to build the shield.  Adding this shield does introduce some complexities to your weather station, so I would only recommend doing it if you are experienced with re-coding the base application.  I will be putting together full instructions on how to incorporate this shield into the weather station soon.


Thanks for viewing!  Check back later for more tips and build progress!