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

Hi all,

To help you out, here are some instructions for the SPI software and the connections.
Use the following connections on a Arduino Mega:

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

Connections on the VMA343 lightning detector:

Connections on the VMA212 mega sensor shield & Arduino Mega:

Connectors orange, yellow, brown and black will need to be bend to accommodate the mega sensor shield later. Be warned! Bending a Dupont wire will work once! You cannot unbend it later!

End result will look like this:

For the code, you can use this sketch. It is an adaptation of the Sparkfun example by Elias Santistevan. You will need the Sparkfun AS3935 library for this sketch to work.
Download it via the library manager in Arduino IDE / sketch / include library / manage libraries
afbeelding
The buzzer of the mega sensor shield will beeb when lightning or a disturber has been detected.

/*
  This example code will walk you through the rest of the functions not
  mentioned in the other example code. This includes different ways to reduce
  false events, how to power down (and what that entails) and wake up your
  board, as well as how to reset all the settings to their factory defaults. 

  By: Elias Santistevan
  SparkFun Electronics
  Date: July, 2019
  License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).

  Modified by PSI @ Velleman NV
  Date: Aug, 2019
*/

#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

// SPI
SparkFun_AS3935 lightning;

//pin setup for speaker
#define BuzzerPin A10

// Interrupt pin for lightning detection 
const int lightningInt = 18; 
// Chip select pin 
int spiCS = 41; 

// Values for modifying the AS395's settings. All of these values are set to their default values. 
byte noiseFloor = 1;    // noise treshold value between 1-7, one being the lowest. Default setting is 2
byte watchDogVal = 1;   // Watchdog threshold value between 1-10, one being the lowest. Default setting is 2
byte spike = 1;         // Spike Rejection value between 1-11, one being the lowest. Default setting is 2. 
byte lightningThresh = 1; //lightning treshold value, can be 1, 5, 9 and 16. Default setting is 1.
boolean maskDisturbers = false; //Mask disturbers. Values can be true or false. Default setting is true.
boolean indoorUse = true;  //Indoor / outdoor use. Values can be true or false. Default setting is true.

// This variable holds the number representing the lightning or non-lightning event issued by the lightning detector. 
byte 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(); // For SPI
  if( !lightning.beginSPI(spiCS, 2000000) ) { 
    Serial.println ("Lightning Detector did not start up, freezing!"); 
    while(1); 
  }
  else
    Serial.println("Schmow-ZoW, Lightning Detector Ready!\n");

  // Clearing previous settings
  lightning.resetSettings();
  delay(250);

  // "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(maskDisturbers);  //true or false 

  int maskVal = lightning.readMaskDisturber();
  Serial.print("Are disturbers being masked: "); 
  if (maskVal == 1)
    Serial.println("YES"); 
  else if (maskVal == 0)
    Serial.println("NO"); 

  // The lightning detector defaults to an indoor setting (less gain/sensitivity).
  if(indoorUse)
  {
    lightning.setIndoorOutdoor(INDOOR); 
  }
  else
  {
    lightning.setIndoorOutdoor(OUTDOOR); 
  }

  int enviVal = lightning.readIndoorOutdoor();
  Serial.print("Are we set for indoor or outdoor: ");  
  if( enviVal == INDOOR )
    Serial.println("Indoor.");  
  else if( enviVal == OUTDOOR )
    Serial.println("Outdoor.");  
  else 
    Serial.println(enviVal, BIN); 

  // Noise floor setting from 1-7, one being the lowest. Default setting is
  // two. If you need to check the setting, the corresponding function for
  // reading the function follows.    
  lightning.setNoiseLevel(noiseFloor);  

  int noiseVal = lightning.readNoiseLevel();
  Serial.print("Noise Level is set at: ");
  Serial.println(noiseVal);

  // Watchdog threshold setting can be from 1-10, one being the lowest. Default setting is
  // two. If you need to check the setting, the corresponding function for
  // reading the function follows.    
  lightning.watchdogThreshold(watchDogVal); 

  int watchVal = lightning.readWatchdogThreshold();
  Serial.print("Watchdog Threshold is set to: ");
  Serial.println(watchVal);

  // Spike Rejection setting from 1-11, one being the lowest. Default setting is
  // two. If you need to check the setting, the corresponding function for
  // reading the function follows.    
  // 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); 

  int spikeVal = lightning.readSpikeRejection();
  Serial.print("Spike Rejection is set to: ");
  Serial.println(spikeVal);

  // This setting will change when the lightning detector issues an interrupt.
  // For example you will only get an interrupt after five lightning strikes
  // instead of one. Default is one, and it takes settings of 1, 5, 9 and 16.   
  // Followed by its corresponding read function. Default is zero. 
  lightning.lightningThreshold(lightningThresh); 

  uint8_t lightVal = lightning.readLightningThreshold();
  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(); 

  // Buzzer
  pinMode(BuzzerPin, OUTPUT);
  digitalWrite(BuzzerPin, LOW);
}

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."); 
    }
    else if(intVal == DISTURBER_INT){
      Serial.println("Disturber."); 
      buzz();
    }
    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(); 
      Serial.print("Approximately: "); 
      Serial.print(distance); 
      Serial.println("km away!"); 

      buzz();

      // "Lightning Energy" and I do place into quotes intentionally, is a pure
      // number that does not have any physical meaning. 
      long lightEnergy = lightning.lightningEnergy(); 
      Serial.print("Lightning Energy: "); 
      Serial.println(lightEnergy); 

    }
  }
}

void buzz() //sound the buzzer on the VMA212 mega sensor shield
{
      digitalWrite(BuzzerPin, HIGH);
      delay(100);
      digitalWrite(BuzzerPin, LOW);
}

Note: I have made the sensor extremely sensitive with the settings above. We got the best results with these settings below. You can experiment with these settings to make the sensor work according to your convenience:

// Values for modifying the AS395's settings. All of these values are set to their default values. 
byte noiseFloor = 2;    // noise treshold value between 1-7, one being the lowest. Default setting is 2
byte watchDogVal = 2;   // Watchdog threshold value between 1-10, one being the lowest. Default setting is 2
byte spike = 2;         // Spike Rejection value between 1-11, one being the lowest. Default setting is 2. 
byte lightningThresh = 1; //lightning treshold value, can be 1, 5, 9 and 16. Default setting is 1.
boolean maskDisturbers = true; //Mask disturbers. Values can be true or false. Default setting is true.
boolean indoorUse = true;  //Indoor / outdoor use. Values can be true or false. Default setting is true.

Happy testing!
Kind regards,

VEL342

1 Like

Ok, the table does not format nicely in a quote. Oh wel . . . . .

Hi Pieter,
This really helps!

I was just going into the change, but I would have used both jumpers, not only JSI.

Assume the SCK on pin 52 is a typo and should be SCL
The help of pictures is obvious.

If you have 4 male-female Dupont wires, you can use a simple piece of wire to get the 4 bent connections.
[edit] changed male-male into male-female Dupont wires [/edit]

First I need to drink some more water as it’s hot here.
Then I’ll start reconfiguring.

Thanks again,
Bert

Can the sketch be implemented to EL 3.7 and the station will work properly with the other sensors?

Do I see this correct?
“orange, yellow, brown and red” red is plugged into the VMA212
so should it be “orange, yellow, brown and black”

Bert

@bert.test : you are right, both spelling errors have been updated.

@Pz83 : no this is a stand alone version, it will not work with the EarthListener. We are currently working on a new firmware version including this stand alone version so everything works smooth together.

Tropical regards,
VEL342

1 Like

Running with variables set as your “best results variables”, as shown above.

Soon after I started this sketch I got a lightning hit at “1 km” not that I noticed such activity.
It may be correct as there is lightning activity mostly at a distance (southern Neterlands and West Germany) . But all are over 40km away.

Just reporting a hit, this is the first I ever had :slight_smile:

It can be a false positive, but I cannot proove that. (And do not want to)

So far for now,

Bert

Hi all!

version 3.8 for the EarthListener VM211 & VM211SE is here :partying_face:
afbeelding
You can download it here: https://velleman.bitrix24.eu/~22PfK. The required libraries are included.

This version will work with both IIC & SPI interface for the VMA343 Lightning sensor.
Via the setup menu (which had a giant facelift) you can choose your interface.
afbeelding
Obviously, you will need to change the connections & jumpers of the VMA343 if you change the interface. If you did something wrong, the sensor will report the error.

Furthermore, the sensitivity of the VMA343 sensor can now be set via the setup menu.
There are 3 settings: low, medium and high sensitivity. Cycle trough them by pressing the icon.

This version should make it much more fun and easy to test what settings are working for you to get the best lightning reports. We will await your feedback before posting it publicly on our GitHub page.

Kind regards,
VEL342 :sleeping:

@VEL342

This is good news:-) Thanks You for Your big effort:-)

I have two questions and the I start today:-)

  1. Both jumpers should be on like the picture You shown above or the right one JCS be at both Pina?
  2. Have You tested on IIC ? Because I don’t know of I have to change to SCI or leave few days at IIC?

Thanks in advance

Przemek

Hi @Pz83,

For IIC (I2C) interface

  • JCS: disconnected
  • JSI: disconnected

For SPI interface

  • JCS: disconnected
  • JSI: connected

Yes, version v3.8 works fine for IIC. You can first test with IIC and later modify to SPI if you don’t like the IIC results.

Kind regards,
VEL342

Hi @VEL342.

You have been busy :wink:
Thank you!

A few things before I reconfigure the EathListener hardware:

  1. I think I see a copy/paste that you forgot to update:
    One of these “For IIC” should be for “For SPI”
    I gamble the second (with JSI connected) is for using SPI
  1. Just for me to be sure “IIC” is the same as “I2C”?

  2. Do you have advise for us to better use the I2C or SPI interface?

  3. Downloaded the firmware.
    Will use it first in the current configuration.
    Hahahahahahahaha,
    I want to take a picture of my current hardware status to show you.
    The moment I switch my phone into camera mode the EL (on the sketch from post 101)
    shows:

    Friday 2019-08-30 09:17:21
    Lightning Strike Detected!
    Approximately: 1km away!
    Lightning Energy: 0
    Friday 2019-08-30 09:17:41
    Lightning Strike Detected!
    Approximately: 1km away!
    Lightning Energy: 0
    Friday 2019-08-30 09:18:54
    Lightning Strike Detected!
    Approximately: 1km away!
    Lightning Energy: 67121664
    Friday 2019-08-30 09:19:00
    Lightning Strike Detected!
    Approximately: 1km away!
    Lightning Energy: 0

Interesting “Energy: 0”
Maybe this should be reported as noise or disturber?

OK as promised: picture

  1. Let me start using the 3.8 firmware.

  2. Thank you Velleman (Pieter) for providing us so much fun. Much more fun than a device that is complete on day 1

That should be enough for today.
Sorry for the long post.

Have a very nice weekend,
Bert

Hi @bert.test

  1. That was indeed a copy-paste mistake. I blame the lack of sleep staring at Arduino code all night :smile:.
  2. Yes, IIC is the same as I2C, I²C or I-squared-C.
  3. In our test case we had a 90% success rate with IIC and a 95% success rate with SPI. If your setup is currently IIC, I would suggest testing that first. If your results are not satisfying, you can move to SPI. Since your current setup is already SPI, go with that ;-).
  4. Yes, if the sensor is on high sensitivity, you will get a report on every static discharge. We even got an EarthListener here that kept reporting lightning because of static discharge from a window.
  5. Good luck!
  6. Glad you enjoy the maker spirit :wink: ! That is what we intended with the EarthListener. Something that’s easy to build and already works with pre-loaded firmware, but can provide hours of fun by adding functionality and features.

Kind regards,
VEL342

1 Like

@VEL342 @bert.test

  1. I will leave I2C connections for a test. I hope that I wouldn’t have to move to SPI - I don’t want to bend the goldpins;)
  2. I leave both jumpers on one pin on JCS and JSI or I should totally remove then from pins?

@Pz83,

  1. Bending the Dupont wire is no problem if you do it once. But don’t try to bend them back again, that will not end well. But indeed, start with IIC.
  2. You can leave the jumper on one pin or remove them completely. We leave them on one pin, since you can easy loose the jumpers.

Kind regards,
VEL342

@VEL342 @bert.test

Right now the station is on I2C interface with both jumpers placed on one of the pins.
When I change from low to high sense I got error:
" IRQ source result 0 not expected… last detection: 2 min ago"

Is there something wrong or this is normal response?

Hi @Pz83,

That behaviour is normal. If you switch the sensitivity, you are recalibrating the board, sending a spike on the interrupt line. The interrupt is noticed by the Arduino and because it’s not a real spike, it is reported as an unexpected IRQ source.
To do for next firmware: mute the interrupt line the first 2 seconds after changing the sensitivity.

Kind regards,
VEL342

@VEL342

Ok, I hope that after few days I can report that it works on I2C:-)
I set medium sensitivity and outdoor mode.

Regards,
Przemek

Thank you Pieter!
Bert

Hi al,

Just an update from me.

Running VM211 at firmware version 4v0 using the SPI interface.
First boot after the update to 4v0 I had to think a bit.
The lightning sensor did not come up.
In hindsight simple: first boot sets defaults, so interface assumes IIC (I2C) interface.
And my box is configured for SPI, so to the setup screen and switch to IIC and reboot.
As said: simple.

Have set the lightning sensitivity to high.

The meteo here promised showers with lighting but they failed to deliver.

While waiting for a real lightning shower,
I am busy with a transperant update to add VMA301 Real Time Clock to the 4v0 code.
By transperant I mean it should be working OK even if no RTC is present.
The code should be working the same as the 4v0_final code if no RTC is available.
Well that’s my goal. Will try to get a pull request to github if it’s ready.

Kind regards,
Bert

Hello.

Made a pull request on github on version 4v0 with some updates.
Important one is: add VMA301 Real Time Clock.

Also made a separate sketch to set the RTC to the correct time.
No need to remove the VMA301 from the Earth Listener.
Date and time can be typed in the serial monitor.

The sketch is available at github repository VM211_set_RealTimeClock

Remarks welcome, of course.

Kind regards,
Bert

1 Like