VM211 Earth Listener - VMA343 Lightning sensor does not report any lightning

@Pz83: Ah,… that’s a pity. By the way, how far is the AS3935 sensor away from the TFT screen and the Arduino?

Hi all!

@beva you are right, the screen and development board do generate some noise. However, the sensor is smart enough to filter most of the noise out, so it will only report electronic discharge related to lightning.
In version 3.4 we did mute any reports where there was no clear disturber (IRQ source result not expected).

Since the EarthListener is fully hackable, you can choose to include the sensor in the case, outside the case, or even farther from the case by putting the wires trough the case (that’s why there is a split in the piece on the right).

However, we did multiple testings with different locations, and it all depends on the general setup of the EarthListener. If you place the lightning sensor to close to a computer, it will pickup to much noise, generating the message “please move the sensor”.

Will post some updates about the code soon.
Kind regards,

VEL342

1 Like

Hi all,

We have written some debug code to find out what is responsible for not reporting the lightning events.
Since we are currently not having any lighting storms in Belgium, any feedback is welcome!

/*
  LightiningI2C_v2 by Velleman - Aug 2019

  Based on the examples from Sparkfun example1 & example2. All hail Sparkfun!
  Original 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).

  Connections:
  VMA343 lightning sensor Board <-> Arduino Mega (with Velleman sensor shield VMA212)
  VCC <-> 3V3
  GND <-> GND
  SDA <-> SDA
  SCL <-> SCL
  IRQ <-> I18
*/

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

// 0x03 is default, but the address can also be 0x02, 0x01.
// 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

SparkFun_AS3935 lightning(AS3935_ADDR);

// Interrupt pin for lightning detection 
const int AS3935_IRQPIN = 18; 

// Values for modifying the IC's settings.
byte noiseFloor = 4;        //Noise floor setting from 1-7, one being the lowest. Default setting is two.     
byte watchDogVal = 3;       // Watchdog threshold setting can be from 1-10, one being the lowest. Default setting is two.
byte spike = 2;             // Spike Rejection setting from 1-11, one being the lowest. Default setting is two. 
byte lightningThresh = 1;   // Lightning detector interrupt reporing. Default is one, and it takes settings of 1, 5, 9 and 16.
boolean maskDisturbers = false; //If you notice a lot of disturbers, you can have the chip not report those events on the interrupt lines. 

//check if the sensor has triggerd an interrupt
volatile int AS3935IrqTriggered;

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

void setup()
{
  Serial.begin(9600); 
  Serial.println("AS3935 Franklin Lightning Detector"); 

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

  if( !lightning.begin() ) { // Initialize the sensor. 
Serial.println ("Lightning Detector did not start up, freezing! Please reboot!"); 
while(1); 
  }
  else
  {
Serial.println("Schmow-ZoW, Lightning Detector Ready!");
Serial.println("Setting up the sensor:");

// Set everything to default values
lightning.resetSettings(); delay(50); //set, but don't spam the I2C bus

// The lightning detector defaults to an indoor setting (less gain/sensitivity), but this can be modified via the setup page in the GUI
//lightning.setIndoorOutdoor(OUTDOOR); delay(50); //set, but don't spam the I2C bus
//lightning.setIndoorOutdoor(INDOOR); delay(50); //set, but don't spam the I2C bus

//report current indoor/outdoor setting:
int enviVal = lightning.readIndoorOutdoor(); delay(50); //read value, but don't spam the I2C bus
Serial.print("Current setting (indoor/outdoor): ");  
if( enviVal == INDOOR )  Serial.println("Indoor");  
else if( enviVal == OUTDOOR ) Serial.println("Outdoor");  
else Serial.println(enviVal, BIN); 

// Mask Disturbers
//lightning.maskDisturber(maskDisturbers); delay(50); //set, but don't spam the I2C bus
int maskVal = lightning.readMaskDisturber(); delay(50); //read value, but don't spam the I2C bus
Serial.print("Are disturbers being masked: "); 
if (maskVal == 1) Serial.println("YES"); 
else if (maskVal == 0) Serial.println("NO"); 

//Noise floor setting   
//lightning.setNoiseLevel(noiseFloor); delay(50); //set, but don't spam the I2C bus
int noiseVal = lightning.readNoiseLevel(); delay(50); //read value, but don't spam the I2C bus
Serial.print("Noise Level is set at: ");
Serial.println(noiseVal);

// Watchdog threshold setting     
// lightning.watchdogThreshold(watchDogVal); delay(50); //set, but don't spam the I2C bus
int watchVal = lightning.readWatchdogThreshold(); delay(50); //read value, but don't spam the I2C bus
Serial.print("Watchdog Threshold is set to: ");
Serial.println(watchVal);

// Spike Rejection setting 
// The shape of the spike is analyzed during the chip's validation routine. You can round this spike at the cost of sensitivity to distant events. 
//lightning.spikeRejection(spike); delay(50); //set, but don't spam the I2C bus
int spikeVal = lightning.readSpikeRejection(); delay(50); //read value, but don't spam the I2C bus
Serial.print("Spike Rejection is set to: ");
Serial.println(spikeVal);

// Lightning detector interrupt reporing
// For example you will only get an interrupt after five lightning strikes instead of one if you set this to 5
//lightning.lightningThreshold(lightningThresh); delay(50); //set, but don't spam the I2C bus
uint8_t lightVal = lightning.readLightningThreshold(); delay(50); //read value, but don't spam the I2C bus
Serial.print("The number of strikes before interrupt is triggerd: "); 
Serial.println(lightVal); 

// When the distance to the storm is estimated, it takes into account other lightning that was sensed in the past 15 minutes. 
// If you want to reset time, then you can call this function. 
lightning.clearStatistics(1); delay(50); //set, but don't spam the I2C bus
  
// enable interrupt (hook IRQ pin to Arduino Uno/Mega interrupt to AS3935_IRQPIN -> 18)
pinMode(AS3935_IRQPIN, INPUT);   // See http://arduino.cc/en/Tutorial/DigitalPins
attachInterrupt(digitalPinToInterrupt(AS3935_IRQPIN), interruptFunction, CHANGE);

//mask the first interrupt
AS3935IrqTriggered = 0;
delay(500); 
  }

  Serial.println("Setup done, start listening for lightning...");
  Serial.println("");
}

void loop()
{
  if(AS3935IrqTriggered)
  {
// 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."); 
}
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(); 
  Serial.print("Approximately: "); 
  Serial.print(distance); 
  Serial.println("km away!"); 
}
else
{
  Serial.print("Interrupt from sensor, source ");
  Serial.print(intVal);
  Serial.println(" unknown");
}

AS3935IrqTriggered = 0;
  }

  delay(500); //wait untill reporting again
}

//interrupt from AS3935 sensor, set var so loop handles this first
void interruptFunction()
{
  AS3935IrqTriggered = 1;
}

Remarks:

  • This code will only send output to your serial port, the LCD is not operational with this code.
  • It doesn’t really matter where your sensor is located, but please do tell when you post your findings.
  • You can play with the values of the IC, but do not forget to uncomment the corresponding set function.
  • You will need the Sparkfun library https://github.com/sparkfun/SparkFun_AS3935_Lightning_Detector_Arduino_Library

Kind regards,
VEL342

This is what the output looks like with artificial lightning:

Kind regards,
VEL342

@VEL342 This Sparkfun library should be put in src directory under EL 3.7?
Where should I paste this code?

@Pz83 only if you use v3.7, for this testing code, the Sparkfun library should be in the Arduino library folder.
This is normally located in C:\Program Files (x86)\Arduino\libraries

Kind regards,
VEL342

@VEL342 This code must be pasted in 3.7 update code, right?

The usual place on “newer” arduino gui’s is in
C:\Users\THISUSER\Documents\Arduino\libraries

Looks like the Sparkfun library can be installed on the usual way via
menu → tools → Manage libraries
Then wait until the wizard is ready loading things.
Type “AS3935” in the upper right search field.
Scroll down until “Sparkfun AS3935…” this provides at the moment 1.4.0 which is the same as on github.
Press “install”
Wait for the Library manager to complete.
Quit the Arduino GUI File → Quit
And restart so the gui knows about the new library.

Will attempt your code Pieter.
Assume: copy your code and paste into a new sketch.

Thanks Pieter!

Bert

@VEL342 no lightning here either, plenty of rain.

@Pz83 :
Copy/paste your code into a new sketch is indeed a good and simple way. After the Sparkfun library has been installed.

The first start shows on Serial:

AS39AS3935 Franklin Lightning Detector
Schmow-ZoW, Lightning Detector Ready!
Setting up the sensor:
Current setting (indoor/outdoor): Indoor
Are disturbers being masked: NO
Noise Level is set at: 2
Watchdog Threshold is set to: 2
Spike Rejection is set to: 2
The number of strikes before interrupt is triggerd: 1
Setup done, start listening for lightning...

@VEL342 As far as I can see only difference is noise level:

  • here 2
  • on your screenshot 4
    So you probably have SET noiseFloor?

Bert

Yes, I was playing around with the noise level and watchdog threshold.
To make the sensor very sensitive keep these levels low (1-2-3).

Kind regards,
VEL342

1 Like

So the default 2 is fine :wink:
Will keep you updated, though lightning is not foreseen here soon…

Bert

@VEL342 @bert.test

Hello,

Any update? The forecast says there can be thunderstorm tonight… I shall see if there is at least one lightning.

Have a nice day,

Przemek

Hi Przemek,

Similar here, rain and heavy showers are predicted, but lightning is hard to be sure about.

I have the AS3935 debug sketch running here and will be keeping an eye on the serial port.

Still sunny here,

Bert

Hello @VEL342 @Pz83 @Guus.Assmann

Showers here with a lot of rumbling between clouds,
some faint flashes without recognizable related thunder.
Due to the cloud-cloud noise.

No indication on Serial running the debug code (YET I hope).
To be sure rebooted the debug sketch an hour before the rumbling started (it got a lot darker outside, so I anticipated some showers).

It’s getting lighter outside. THIS attempt of the weather failed :wink:

Bert

Visible lightning flashes now with very long (how do you call them?) streaks. Thunder comes after 10 / 20 seconds, so not too remote.
The lightning is visible from the place the Earth Listener is standing (2 meters from the window.
(As the measurements are reported via Serial, I have to use the USB cable to my PC to enable serial)

No measurements on the Serial interface, sadly.

Bert

Hi all,

Good news, we had several lightning storms in the past week, so we were able to test the new v3.7 firmware. We are detecting the lightning, but not all of the strikes are reported, hence further investigation is necessary. We have seen some irregularities in the AS3935 I2C communication what might be the reason why some spikes are not reported.

We are therefore also testing the sensor on the SPI bus. The results are stable, but we need more time to confirm this. You can test this yourself by using this example:

Use the following connections on a Arduino Mega:

Arduino Mega Lightning Detector
5V VCC
GND GND
52 SCK
50 MISO
51 MOSI
41 CS
18 INT

The 5V, GND and pin 18 can be connected via the sensor board. The 41, 50, 51 and 52 pins need to be connected on the board under the sensor board. This means bending the Dupont wires to fit them.

Change these lines in the example code:

const int lightningInt = 4; 
int spiCS = 10; //SPI chip select pin

to:

const int lightningInt = 18; 
int spiCS = 41; //SPI chip select pin

Do not forget to connect headers JCS & JSI on the sensor board!

Kind regards,
VEL342

1 Like

Pieter @VEL342,

Have seen the post, but I will not be able to do the reconfigure for a few days.

Will try to find the time though.

Bert
[edit] Any chance of a picture of the connections? :wink:

Especially these:

A little off-topic showing the power of the thunderstorm:

BBC News - Poland lightning strike kills four, injures 100, in Tatra mountains storm
https://www.bbc.co.uk/news/world-europe-49439619

@Pz83 A bit Off-topic allright, but indeed horrible.

Yes, indeed horrible accident and that is one of the reasons for me to get the weather station working properly. Safety.

1 Like