The SparkFun AS3935 Lightning Detector is not working after including the Ethernet Shield

After installing the Ethernet Shield, the sensor doesn’t work.

capscreen.png

kindly check inside the libraries and codes that you’re using. I fear that libraries/codes for these two products are using one or more pins in common.

Looks to me that there are 2 (potential) conflicts :

The ethernet shield is using pin 10 for chip-select and so does the AS3935 by default in the sketches.

Try to set in the AS3935 sketches ‘int spiCS = 9;’ and connect your blue wire to ‘9’ for the AS3935

The ethernet shield is using pin 13 for the green led. Not sure how much that impacts. Maybe it just lights up. Could not find a reference to the source code that is actively addressing this pin. For now, neglect until we learn more.

bidrohini:
kindly check inside the libraries and codes that you’re using. I fear that libraries/codes for these two products are using one or more pins in common.

Thank you for your reply. Currently, I am not including any libraries or code for the ethernet shield, just using the sample code for the AS3935 Lightning Detector. However, the detector is still not working as expected.

paulvha:
Looks to me that there are 2 (potential) conflicts :

The ethernet shield is using pin 10 for chip-select and so does the AS3935 by default in the sketches.

Try to set in the AS3935 sketches ‘int spiCS = 9;’ and connect your blue wire to ‘9’ for the AS3935

The ethernet shield is using pin 13 for the green led. Not sure how much that impacts. Maybe it just lights up. Could not find a reference to the source code that is actively addressing this pin. For now, neglect until we learn more.

Thank you for your reply. As your suggestion, I changed the spiCS to 9 instead of 10 and reconnect the blue wire to ‘9’, but the issues still exist. The detector does not provide any detection feedback, neither lightning nor any noise.

The code I’m using is the example code provided by the SparkFun website without any modifications(Except changing the chip select variable).

#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

SparkFun_AS3935 lightning;

// Interrupt pin for lightning detection

const int lightningInt = 4;

int spiCS = 9; //SPI chip select pin

// This variable holds the number representing the lightning or non-lightning

// event issued by the lightning detector.

int intVal = 0;

int noise = 2; // Value between 1-7

int disturber = 2; // Value between 1-10

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);

}

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.”);

// Too much noise? Uncomment the code below, a higher number means better

// noise rejection.

//lightning.setNoiseLevel(noise);

}

else if(intVal == DISTURBER_INT){

Serial.println(“Disturber.”);

// Too many disturbers? Uncomment the code below, a higher number means better

// disturber rejection.

//lightning.watchdogThreshold(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();

Serial.print("Approximately: ");

Serial.print(distance);

Serial.println(“km away!”);

}

}

delay(100); // Slow it down.

}

try to also move the interrupt pin from pin 4 to pin 8…

Do you really need Ethernet? If not it might be easier to use an Uno without the shield.

paulvha:
try to also move the interrupt pin from pin 4 to pin 8…

Amazing! The program seems to be working again. Thank you.

YellowDog:
Do you really need Ethernet? If not it might be easier to use an Uno without the shield.

Because the sensor will eventually need to do some integration with other systems, in this case, I tried to use ethernet to go to the network and send HTTP requests, another solution is to use a wifi chip, but it doesn’t work in my case.

petertam:

paulvha:
try to also move the interrupt pin from pin 4 to pin 8…

Amazing! The program seems to be working again. Thank you.

Thanks for the solution. Good to know that it worked finally.