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.
User avatar
By TS-Chris
#204167
OK, we're still looking into what could be causing the issues some customers are having and we will post an update when we have more information.

In the meantime, we did update the library and it would be a good idea to update the IDE with the latest version (v1.2.2) to see if that helps.

The latest version can be downloaded through the library manager, or you can manually download it here.
User avatar
By williamlynn
#204174
I tried the new library and nothing changed.

I also tried to connect using jumpers instead of the QWIIK cable and again no changes.

SPI seems to be working but need a lightning storm to verify.

Bill
#204180
We are aware of the issues associated with the Lightning sensor failing to initialize. We are currently working with the development team associated with the product and are working on a fix.

We are still not entirely sure what the issue is and some of the fixes that have been mention in the threads in this topic are not 100% guaranteed to work, however, we have had some success in-house with the following:
  • 1st, Try an I2C scan and make sure that the lightning sensor is responding with 0x03 indicating that the I2C connection is working.
  • Try pulling MISO and CS to ground. Do not use digital low for this and use the GND line on your controller instead. This may require soldering
  • Try the new library we had put out and use the specific I2C example. You may also try the SPI example as that has been more consistent and functional as of now.
  • If using a Qwiic connector system try confirming that the Qwiic cable is making a solid connection with the Qwiic connector on the controller board and lightning sensor
You may also try bypassing the Qwiic system altogether and going straight to I2C pins if you think the Qwiic system is suspect, however, if the Qwiic scan returns 0x03 than there is no issues with the Qwiic system.

If you have tried all of the above and things are still not working, provide a photo of your setup and as much information as possible. We will review it and try to figure what what the next step is.
#204185
I have already tried all the items in your post.

Why is the INT output from the LIGHTNING a contant 3.3 v; I thought this only went high when there is lightning.. I get the same reading on two different boards and PRO MINI's and it is the same whether I have i2c or SPI connected.
#204208
@TS-Chris and @TS-John,
I sent my boards back to you for checking. One thing I noticed one my last tries before I sent them back is that I think the library from PWFusion_AS3935_I2C seemed to communicate with the device. It makes me think there is some timing issue with the I2C library being used. While monitoring with a USB logic analyzer, the SFE library would attempt the communication, would not receive an ACK, and it appeared to quit. The PWFusion library, on the other hand, would miss the first try but on the second try it would receive and ACK and keep moving forward.
#204215
Really strange stuff going on!!!!

I started fresh today and redid the code for SPI using you latest example "Example1_BasicLightning_SPI" and added some of my own minor code revision, attached is sketch"Example1_BasicLightning_SPI_wjl". This is working and I am getting Disturber inputs when I click my BBQ fire starter close to the boards. WOW it looks like its really working. The INT output from the board is zero until I click the BBQ starter.
Code: Select all
/*
  --A basic lightning detector Arduino example sketch--
  Utilizing SPI, this example listens for lightning "events". The IC determines
  whether or not it's actual lightning, disturber, or noise. In the case
  your environment has a lot of noise 
  By: Elias Santistevan
  SparkFun Electronics
  Date: May, 2019
  License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
  Hardware: 
  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"

#define INDOOR 0x12 
#define OUTDOOR 0xE
#define LIGHTNING_INT 0x08
#define DISTURBER_INT 0x04
#define NOISE_INT 0x01

unsigned long Time;
unsigned long Time_s;
unsigned long Time_m;
unsigned long Time_h;

SparkFun_AS3935 lightning;

// Interrupt pin for lightning detection 
const int lightningInt = 4; 
int noiseFloor = 2;
int spiCS = 10; //SPI chip select pin

// 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.begin(115200); 
  Serial.println("AS3935 Franklin Lightning Detector"); 

  SPI.begin(); 

  if( !lightning.beginSPI(spiCS, 2000000) ){ 
    Serial.println ("Lightning Detector did not start up, freezing!"); 
    while(1); 
  }
  else
    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:
  lightning.setIndoorOutdoor(OUTDOOR); 
  Serial.println("STARTING");
}





void loop()
{
   // Hardware has alerted us to an event, now we read the interrupt register
  if(digitalRead(lightningInt) == HIGH){
    intVal = lightning.readInterruptReg();
    if(intVal == NOISE_INT){
      Serial.println("Noise."); 
      //reduceNoise(); //See note below above reduceNoise function.
    }
    else if(intVal == DISTURBER_INT){
      Serial.println("Disturber."); 
    }
    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();
      byte distance_km = lightning.distanceToStorm();     
      byte distance_mi = distance_km * .62;
      Serial.print("Approximately: "); 
      Serial.print(distance_mi); 
      Serial.println(" miles 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!"); 
    return;
  }
  Serial.println("Increasing the event threshold.");
  lightning.setNoiseLevel(noiseFloor);  
}

// This function is similar to the one above in that it will increase the
// antenna's robustness against false positives. However, this function helps to
// increase the robustness against "distrubers" and not "noise". If you have a
// lot of disturbers trying increasing the threshold. The default value is 2 and
// goes up to 10. You can remove the call to watchdogThreshold() from this
// function; the function is a demonstrative tool.  
void changeDisturberThresh(int threshVal){
    lightning.watchdogThreshold(threshVal);  
}
Now I try to use the example code "Example2_More_lightning_Features" and I configure for SPI; now INT out put is continuous at 3.3VDC. The setup code was exactly the same for both files. I had to copy the setup code from the working sketch and paste it to the Example2 file to get it to work; working sketch attached.
Code: Select all
/*
  A more in depth lightning detector Arduino example sketch. 
  This will guide you through some more of the library's functions that aid in
  reducing false events and noise. 
  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. 
  Hardware: 
  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"

#define INDOOR 0x12 
#define OUTDOOR 0xE
#define LIGHTNING_INT 0x08
#define DISTURBER_INT 0x04
#define NOISE_INT 0x01

unsigned long Time;
unsigned long Time_s;
unsigned long Time_m;
unsigned long Time_h;

SparkFun_AS3935 lightning;

// Interrupt pin for lightning detection 
const int lightningInt = 4; 
int spiCS = 10; //SPI chip select pin
// Values for modifying the IC's detection sensitivity. 
int noiseFloor = 2;  //changed from byte to int
int watchDogVal = 2; //changed from byte to int
int spike = 2;       //changed from byte to int

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

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

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

  SPI.begin(); 

  if( !lightning.beginSPI(spiCS, 2000000) ){ 
    Serial.println ("Lightning Detector did not start up, freezing!"); 
    while(1); 
  }
  else
    Serial.println("Schmow-ZoW, Lightning Detector Ready!");
  // "Disturbers" are events that are false lightning events. If you find
  // yourself seeing a lot of disturbers you can have the chip not report those
  // events on the interrupt lines. 
  //lightning.maskDisturber(true); 

  // The lightning detector defaults to an indoor setting (less
  // gain/sensitivity), if you plan on using this outdoors 
  // uncomment the following line:
  //lightning.setIndoorOutdoor(OUTDOOR); 
  Serial.println("starting"); 
}

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){
      Serial.println("Noise."); 
      // reduceNoise();  See note below above function definition.
    }
    else if(intVal == DISTURBER_INT){
      Serial.println("Disturber."); 
    }
    else if(intVal == LIGHTNING_INT){
      Serial.println("Lightning Strike Detected!"); 
      // Lightning! Now how far away is it? Distance estimation takes into
      // account previously seen events. 
      byte distance = lightning.distanceToStorm();
      byte distance_mi = distance * .62;       
      Serial.print("Approximately: "); 
      Serial.print(distance);
      Serial.print("Approximately: "); 
      Serial.print(distance_mi); 
      Serial.println(" miles away!"); 
      // "Lightning Energy" and I do place into quotes intentionally, is a pure
      // number that does not have any physical meaning. 
      //lightEnergy = mylight.lightningEnergy(); 
      //Serial.print("Lightning Energy: "); 
      //Serial.println(lightEnergy); 

    }
  }
  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!"); 
    return;
  }
  Serial.println("Increasing the event threshold.");
  lightning.setNoiseLevel(noiseFloor);  
}

// This function increases the threshold for events that are displayed on the
// interrupt pin. Increase value means more powerful events will need to occur
// to be cause the interrupt pin to go high. 
void increaseWatchdog()
{
  ++watchDogVal; // Starting at defult for demonstrative purposes and so we'll need to increase value before we write it. 
  if(watchDogVal > 7){
    Serial.println("Watchdog threshold is already at max."); 
    return; 
  }
  lightning.watchdogThreshold(watchDogVal); 
}

// This function like the watchdog above can help with to tune your detector to
// more accurate readings. The shape of the pike is analyzed during the chip's
// validation routine. You can round this spike at the cost of sensitivity to
// distant events. 
void dullTheSpike()
{
  ++spike; 
  if(spike > 11) { 
    Serial.println("Spike reduction is at mask!"); 
    return; 
  }
  lightning.spikeRejection(spike); 
}

// The following two functions should be called as a pair. If you're powering
// the IC down, then you should probably wake it up ;). The IC will consume
// 1-2uA while powered down. 
void powerICDown()
{
  Serial.println("Powering down the IC for deep sleep."); 
  lightning.powerDown(); 
}

void wakeItUP()
{
  Serial.println("Waking it up!"); 
  if( lightning.wakeUp() ) 
    Serial.println("Successfully woken up!");  
  else 
    Serial.println("Error recalibrating internal osciallator on wake up."); 
}
Does anyone have a good explanation of what is going on????

I2C operation is still not working, still waiting for resolution from SPARKFUN.

Bill
#204359
I am having the same issues and thought I fried the board somehow. I bought another two and the first one is having the same problem--unable to init. I am seeing from these posts that these boards just don't work. I will try to it again and see if I can make it work.

I was going to use the board with ESP32 and I see that also did not work and I did not see in the posts that folks were making this work.
#206115
Just to closeout my original posts in this thread. After the last update to the AS3935 Sparkfun library, the breakout board is working just fine with the Qwiic system. Thanks to the staff for their awesome support (many thanks to Chris F). And using the Qwiic system with the Blackboard is very flexible because the SDA/SCL lines on the Blackboard support +5V systems, while the Qwiic on the Blackboard supports +3.3V systems. Waiting for a storm to roll by now.