SparkFun Forums 

Where electronics enthusiasts find answers.

Questions &/or issues related to products in the Qwiic category should be posted in this forum. To learn more about Qwiic, consider checking out our pillar page on the Qwiic system.

Microcontroller: Feather HUZZAH 32 (ESP32)
Board: Sparkfun AS3935 (SparkX Version)
Programming Env: Arduino 1.8.9 (Windows)

I'm following the hookup guide for the AS3935 provided on the SparkFun website. Upon compiling I'm getting some errors that I am thinking may be more about the ESP32 than the library, but I thought that I would check.

First error:
Code: Select all
SparkFun_AS3935 lightning(AS3935_ADDR);
"WeatherStation_FeatherHUZZAH:40:38: error: invalid conversion from 'int' to 'i2cAddress {aka SF_AS3935_I2C_ADDRESS}' [-fpermissive]"

I've tried replacing it with the explicit 0x03 with no luck.

Any thoughts? Thank you in advance.
Possibly, but I'm not aware of any plans to do that at this time. You might try filing an issue in the Github repository. The team that wrote the firmware will see that.
User avatar
By blazer5154
Every time I try to use the lightning detector, all I get is the message, "Lightning Detector did not start up, freezing!" I have tried several different microcontrollers, jumper wires, breadboards, and tried cutting the I2C pull-up jumpers. Perhaps I received a defective unit?
I have an AS3935 Lightning Detector board (SPX-15057) connected to the BlackBoard C (SPX-15098) but it doesn't go past the "Lightning Detector did not start up, freezing!" prompt. I have the same Blackboard talking to a QWIIC OpenLog and that communication seems to be fine so I don't think the issue is either the Blackboard C or the QWIIC cable.

I even modified the specific section from:
Code: Select all
 if( !lightning.begin() ) { // Initialize the sensor. 
  //if( !lightning.beginSPI(9, 2000000){ // Uncomment for SPI.
    Serial.println ("Lightning Detector did not start up, freezing!"); 
    Serial.println("Schmow-ZoW, Lightning Detector Ready!");
Code: Select all
 while( !lightning.begin() ) { // Initialize the sensor. 
    Serial.println ("Lightning Detector did not start up, freezing!"); 
Serial.println("Schmow-ZoW, Lightning Detector Ready!");
The address seems ok (jumpers are open = 0x03).

Any ideas?
User avatar
By 77boiler
I'm having the same issue. I just received the Qwiic AS3935 Franklin Lightning Detector direc from Sparkfun, and am using a DEV-12757 (Batch #58508) RedBoard with a Sparkfun i2c shield connected to the Qwiic AS3935 along with a separate jumper between pin 4 of the RedBoard and the INT signal of the AS3935 board. I'm running Arduino IDE 1.8.9, building example "BasicLightning" without build errors Any suggestions?
User avatar
By TS-Mark
Hey everyone,

That error is showing up usually because of a connection issue that is preventing the Arduino from initializing the sensor. You can check to see if your microcontroller is seeing the device on the I2C bus by running the I2C Scanner example from Arduino. If the Lightning Detector is present on the bus, you should see its address (0x03) printed in your serial monitor.

Please try that code to confirm the board is showing up on the bus. Blazer5154, if you disabled the pull-up jumpers, you will want to re-solder those jumper pads back together. If you do not see the Lightning Detector show up on the bus, please take a few photos of your boards and circuit and attach them to your replies.
I had the exact same issue the first time I tried the board but once I ran the I2C Scanner sketch (attached) and the sketch discovered a device at address 0x03, everything worked after that.

Try running the I2C_Scanner.ino sketch and see if it finds a device at 0x03. If it doesn't reply with photos of the top and bottom of your board and a photo showing how you have the board connected to your Arduino. If the I2C scanner does find a device at 0x03, then try the first example in our library and see if it works then.

I have no idea why it took running the I2C scanner first, but it seems to work.
User avatar
By blazer5154
I tried the I2C scanner and the device shows up at 0x03; I was unable to re-solder the I2C jumpers though, the pads lifted off the board as soon as I applied solder. Device still shows up in I2C scan though. If you still need photos, let me know and I'll send as soon as I can.
I tried the "I2C Scanner" sketch (from both the SFE GitHub and ArduinoCC) and got the device's I2C recognized. Result follows:
I2C Scanner
I2C device found at address 0x03 !
I then tried the AS3935 SFE sketch again with the same results. See below:
AS3935 Franklin Lightning Detector
Lightning Detector did not start up, freezing!
The AS3935 code is as follows:
Code: Select all
  A basic lightning detector Arduino example sketch. 
  By: Elias Santistevan
  SparkFun Electronics
  Date: January, 2019
  License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
  This example listens for lightning events, which are internally determined by
  the IC to be real or false events. 
  This is SparkFun's Qwiic Lightning Detector and so is compatible with the Qwiic
  system. You can attach a Qwiic cable or solder to the I-squared-C pins.
  You'll also need a wire attached to the interrupt.  

#include <SPI.h>
#include <Wire.h>
#include "SparkFun_AS3935.h"

// 0x03 is default, but the address can also be 0x02, 0x01, or 0x00
// Adjust the address jumpers on the underside of the product. 
#define AS3935_ADDR 0x03 
#define INDOOR 0x12 
#define OUTDOOR 0xE
#define LIGHTNING_INT 0x08
#define DISTURBER_INT 0x04
#define NOISE_INT 0x01

// If you using SPI, instantiate class without address: 
//SparkFun_AS3935 lightning;

// If you're using I-squared-C then keep the following line. Address is set to
// default. 
SparkFun_AS3935 lightning(AS3935_ADDR);

// Interrupt pin for lightning detection 
const int lightningInt = 4; 
int noiseFloor = 2;

// This variable holds the number representing the lightning or non-lightning
// event issued by the lightning detector. 
int intVal = 0;

void setup()
  // When lightning is detected the interrupt pin goes HIGH.
  pinMode(lightningInt, INPUT); 

  Serial.println("AS3935 Franklin Lightning Detector"); 

  Wire.begin(); // Begin Wire before lightning sensor. 

 if( !lightning.begin() ) { // Initialize the sensor. 
  //if( !lightning.beginSPI(9, 2000000){ // Uncomment for SPI.
    Serial.println ("Lightning Detector did not start up, freezing!"); 
    Serial.println("Schmow-ZoW, Lightning Detector Ready!");

  // The lightning detector defaults to an indoor setting at 
  // the cost of less sensitivity, if you plan on using this outdoors 
  // uncomment the following line:

void loop()
  if(digitalRead(lightningInt) == HIGH){
    // Hardware has alerted us to an event, now we read the interrupt register
    // to see exactly what it is. 
    intVal = lightning.readInterruptReg();
    if(intVal == NOISE_INT){
      //reduceNoise(); //See note below above reduceNoise function.
    else if(intVal == DISTURBER_INT){
    else if(intVal == LIGHTNING_INT){
      Serial.println("Lightning Strike Detected!"); 
      // Lightning! Now how far away is it? Distance estimation takes into
      // account any previously seen events in the last 15 seconds. 
      byte distance = lightning.distanceToStorm(); 
      Serial.print("Approximately: "); 
      Serial.println("km away!"); 
  delay(100); //Let's not be too crazy.

// This function helps to adjust the sensor to your environment. More
// environmental noise leads to more false positives. If you see lots of noise
// events, try increasing the noise threshold with this function. I put the
// function call under the if statement checking for noise. The datsheet
// warns that smartphone and smart watch displays, DC-DC converters, and/or
// anything that operates in 500 kHz range are noise sources to be avoided. 
void reduceNoise(){
  ++noiseFloor; // Manufacturer's default is 2 with a max of 7. 
  if(noiseFloor > 7){
    Serial.println("Noise floor is at max!"); 
  Serial.println("Increasing the event threshold.");
Pictures of setup are attached.