Author Topic: Austria Microsystems AS3935 Franklin Lightning Sensor IC  (Read 19860 times)

0 Members and 1 Guest are viewing this topic.

Offline miraculon

  • Sunrise Side Weather
  • Forecaster
  • *****
  • Posts: 4107
  • KE8DAF
    • Sunrise Side Weather in Rogers City MI USA
Austria Microsystems AS3935 Franklin Lightning Sensor IC
« on: June 03, 2012, 06:39:27 PM »
I came across an interesting IC dedicated to lightning detection. I am not much of a programmer, but this could be a cool project for someone who is so inclined. Or maybe, one of the weather equipment suppliers like Davis or AcuRite could integrate it into one of their designs.

It has both SPI and I2C interfaces. Hardware wise, it looks like it requires minimal external circuitry.

http://www.ams.com/eng/Products/RF-Products/Lightning-Sensor/AS3935

I found the datasheet at Future Electronics: http://www1.futureelectronics.com/doc/AUSTRIAMICROSYSTEMS/AS3935.pdf

I also found an Evaluation kit, completely assembled that also includes a "Lightning Emulator" to test it. I found the eval kit manual at:
http://media.digikey.com/pdf/Data%20Sheets/Austriamicrosystems%20PDFs/AS3935_EvalManual_AN.pdf
« Last Edit: June 04, 2012, 08:09:41 PM by miraculon »


Blitzortung Stations #706 and #1682
CoCoRaHS: MI-PI-1
CWOP: CW4114 and KE8DAF-13
WU: KMIROGER7
Amateur Radio Callsign: KE8DAF

Offline rdsman

  • Senior Contributor
  • ****
  • Posts: 249
Re: Austria Microsystems AS3935 Franklin Lightning Sensor IC
« Reply #1 on: January 01, 2013, 02:20:40 PM »
I've ordered a couple of these to play with:

http://embeddedadventures.com/as3935_lightning_sensor_module_mod-1016.html

Maybe I can emulate the Boltek!

Ray

Offline miraculon

  • Sunrise Side Weather
  • Forecaster
  • *****
  • Posts: 4107
  • KE8DAF
    • Sunrise Side Weather in Rogers City MI USA
Re: Austria Microsystems AS3935 Franklin Lightning Sensor IC
« Reply #2 on: January 01, 2013, 05:50:54 PM »
That is a nice project board. Keep us posted on your progress. What are you going to control it with?

Greg


Blitzortung Stations #706 and #1682
CoCoRaHS: MI-PI-1
CWOP: CW4114 and KE8DAF-13
WU: KMIROGER7
Amateur Radio Callsign: KE8DAF

Offline rdsman

  • Senior Contributor
  • ****
  • Posts: 249
Re: Austria Microsystems AS3935 Franklin Lightning Sensor IC
« Reply #3 on: January 01, 2013, 07:21:09 PM »
I don't really have a plan for them.  I will probably just write some code and see if they work well enough to pursue a "real project" using one.

Ray

Offline KC5JIM

  • Senior Contributor
  • ****
  • Posts: 231
    • KC5JIM Weather
Re: Austria Microsystems AS3935 Franklin Lightning Sensor IC
« Reply #4 on: February 12, 2013, 12:29:05 PM »
I have a couple AS3935 Franklin Demo Board kits coming in the mail from Future Electronics.  I will be evaluating these for making a realistically priced lightning detector for hobby use.  There is really no reason for a lightning detector to cost hundred of dollars, it's just not that complicated to implement.  My plan is to link the AS3935 with an ATMega microprocessor for display and analysis purposes.  I believe that this could be produced for well under $100 USD for a basic system, and well under $200 USD for a multi-sensor system to allow for triangulation of the strikes.
Ecowitt Wittboy| FOSHKplugin on Pi 4


Offline Bushman

  • Forecaster
  • *****
  • Posts: 7549
    • Eagle Bay Weather
Re: Austria Microsystems AS3935 Franklin Lightning Sensor IC
« Reply #5 on: February 12, 2013, 03:16:39 PM »
I have a couple AS3935 Franklin Demo Board kits coming in the mail from Future Electronics.  I will be evaluating these for making a realistically priced lightning detector for hobby use.  There is really no reason for a lightning detector to cost hundred of dollars, it's just not that complicated to implement.  My plan is to link the AS3935 with an ATMega microprocessor for display and analysis purposes.  I believe that this could be produced for well under $100 USD for a basic system, and well under $200 USD for a multi-sensor system to allow for triangulation of the strikes.

I'd be in for one of those!  Keep us posted.
Need low cost IP monitoring?  http://wirelesstag.net/wta.aspx?link=NisJxz6FhUa4V67/cwCRWA or PM me for 50% off Wirelesstags!!

Offline rdsman

  • Senior Contributor
  • ****
  • Posts: 249
Re: Austria Microsystems AS3935 Franklin Lightning Sensor IC
« Reply #6 on: February 12, 2013, 07:18:32 PM »
My plan is to link the AS3935 with an ATMega microprocessor for display and analysis purposes.

I2C or SPI?  While the chip supports both, my BOB only does I2C, so I guess that I am leaning in that direction.

Ray

Offline KC5JIM

  • Senior Contributor
  • ****
  • Posts: 231
    • KC5JIM Weather
Re: Austria Microsystems AS3935 Franklin Lightning Sensor IC
« Reply #7 on: February 12, 2013, 07:33:00 PM »
I definitely plan to use I2C for the interface.
Ecowitt Wittboy| FOSHKplugin on Pi 4


Offline rdsman

  • Senior Contributor
  • ****
  • Posts: 249
Re: Austria Microsystems AS3935 Franklin Lightning Sensor IC
« Reply #8 on: February 16, 2013, 07:41:26 PM »
I am leaning towards a stand alone lightning detector, with a USB interface.  It would plot time /distance.  The vertical line colors could change based on distance, intensity, etc.  It could look something like the picture below:
Ray

Offline KC5JIM

  • Senior Contributor
  • ****
  • Posts: 231
    • KC5JIM Weather
Re: Austria Microsystems AS3935 Franklin Lightning Sensor IC
« Reply #9 on: February 22, 2013, 06:08:00 PM »
I finally got the  AS3935 demonstration kits in, so now I can start working on the code and getting some testing done.
Ecowitt Wittboy| FOSHKplugin on Pi 4


Offline miraculon

  • Sunrise Side Weather
  • Forecaster
  • *****
  • Posts: 4107
  • KE8DAF
    • Sunrise Side Weather in Rogers City MI USA
Re: Austria Microsystems AS3935 Franklin Lightning Sensor IC
« Reply #10 on: April 16, 2013, 12:16:57 PM »
Any further progress on these projects? Just wondering.

Greg H


Blitzortung Stations #706 and #1682
CoCoRaHS: MI-PI-1
CWOP: CW4114 and KE8DAF-13
WU: KMIROGER7
Amateur Radio Callsign: KE8DAF

Offline rdsman

  • Senior Contributor
  • ****
  • Posts: 249
Re: Austria Microsystems AS3935 Franklin Lightning Sensor IC
« Reply #11 on: April 16, 2013, 12:42:58 PM »
Quote
Any further progress on these projects? Just wondering.

I did get some code written that would do the calibration/sensitivity functions correctly.  It can detect a grill starter and clasify it as a "Disturber".  One big problem - No Lightning has been around since!

So it's going about the same as my Si4707 Weather Band receiver project - I only get to test it on Wednesdays during the Required Weekly Test (RWT).

Ray

Offline rdsman

  • Senior Contributor
  • ****
  • Posts: 249
Re: Austria Microsystems AS3935 Franklin Lightning Sensor IC
« Reply #12 on: May 19, 2013, 09:45:24 AM »
A line of thunderstorms came through yesterday and early this morning.  They lasted just long enough for me to tweak my code.  The screenshot below shows the results.  I plan to let it run for a while, clean up the code, then I will post it for anyone interested.


Ray

Offline YFandS

  • Member
  • *
  • Posts: 2
Re: Austria Microsystems AS3935 Franklin Lightning Sensor IC
« Reply #13 on: June 22, 2013, 12:42:13 PM »
Hello rdsman,

Looks very promising, I also purchased 3 MOD1016 (1 month ago) from embedded adventures. I found some software on https://github.com/raivisr/AS3935-Arduino-Library
can initialize the mod 1016, but wont detect lightning  :evil: is your software for free, I will settle for what you have. Arduino or PIC..

regards Frank

Offline rdsman

  • Senior Contributor
  • ****
  • Posts: 249
Re: Austria Microsystems AS3935 Franklin Lightning Sensor IC
« Reply #14 on: June 24, 2013, 05:19:50 PM »
I started on this, but a paying project came along!  It is not finished, tested, maybe not even started well.  But for those of you that have asked, here is what I have:

Code: [Select]

/*
    AS3935 Franklin Lightning Sensor
    Demonstration Program
   
    Draft Version!
    by rdsman
    18 MAY 2013
*/
#include "Arduino.h"
#include "Wire.h"
#include "DS3231.h"  //  Real Time Clock.
//
#define IRQ_PIN           2
#define AS3935_ADDR    0x06 >> 1
#define CAL            0x01
#define RUN            0x02
#define INT            0x04
//
#ifndef NO_INTERRUPTS()
#define NO_INTERRUPTS()  byte sreg = SREG; cli()
#define INTERRUPTS()     SREG = sreg
#endif
//
#ifndef TIMER1_START()
#define TIMER1_START()  TCNT1 = 0x00; TCCR1B |= (1 << WGM12 | 1 << CS12 | 1 << CS10)
#define TIMER1_STOP()   TCCR1B = 0x00
#endif
//
volatile word counter;
volatile byte timer;
volatile byte status = 0;
volatile byte best;
byte function;
//
//
//
void setup()
{
  pinMode(IRQ_PIN, INPUT);
  Wire.begin();
  delay(100);
  Serial.begin(115200);
  Serial.println("AS3935 ready..........");
  Serial.println();
  delay(200);
  Serial.println("RTC ready.............");
  Serial.println();
  RTC.getTime();
  printTime();
  Serial.print("  ");
  printDate();
  Serial.print("  ");
  delay(1000);
  Serial.println();
  Serial.println();
  delay(500);
  initialize();
  reset();
  calibrate();
  powerUp();
  readConfig();
   
}
//
//
//
void loop()
{
  if (status & INT)
    {
      status &= ~INT;
      RTC.getTime();
      getIntStatus();
    }
 
  if (Serial.available() > 0)
    doFunction(); 
}
//
//
//
void reset()
{
  writeRegister(0x3C, 0x96);
  delay(3);
}
//
//
//
void calibrate()
{
  int current = 0, previous = 31768;
   
  status = CAL;
   
  writeRegister(0x08, 0x80);
 
  delay(3);
 
  for (byte i = 0; i < 16; i++)
    {
      writeRegister(0x08, (0x80 + i));
      delay(2);
      timer = 1;
      counter = 0;
      TIMER1_START();
      while(timer);
      //Serial.print("Counter: ");
      //Serial.println(counter);
      //Serial.println();
      current = counter - 3125;
      if (previous >= current)
        {
          previous = current;
          best = i;
        } 
      //Serial.print("Current: ");
      //Serial.println(current);
      //Serial.println();
    }
/* 
  Serial.print("Counter: ");
  Serial.println(counter);
  Serial.println();
 
  Serial.print("Current: ");
  Serial.println(current);
  Serial.println();
 
  Serial.print("Previous: ");
  Serial.println(previous);
  Serial.println();
*/ 
  TIMER1_STOP();
  writeRegister(0x08, best);
  delay(2);
  Serial.println("Calibration complete.");
  Serial.println();

//
//
//
void powerUp()
{
  writeRegister(0x3D, 0x96);
  delay(2);
  writeRegister(0x08, (0x10 | best));
  delay(2);
  writeRegister(0x08, (0x00 | best));
  delay(2);
  status = RUN;

//
//
//
void initialize()
{
  NO_INTERRUPTS();
 
  ADCSRA = 0x00;                                    //  Disable the analog comparator.
   
#if defined (__AVR_ATmega168__) || defined (__AVR_ATmega328P__)
  EICRA = 0x00;
  EICRA |= (1 << ISC01 | 1 << ISC00);               // Setup Interrupt 0 for Rising edge.
  EIFR  |= (1 << INTF0);                            // Clear pending interrupts.
  EIMSK |= (1 << INT0);                             // Enable Interrupt 0.
#elif defined (__AVR_ATmega1280__) || defined (__AVR_ATmega2560__)
  EICRB = 0x00;
  EICRB |= (1 << ISC41 | 1 << ISC40);               // Setup Interrupt 4 for Rising edge.
  EIFR  |= (1 << INTF4);                            // Clear pending interrupts.
  EIMSK |= (1 << INT4);                             // Enable Interrupt 4.
#endif   
 
  TCCR1A = 0x00;                                    //  Reset TCCR1A to Normal mode.
  TCCR1B = 0x00;                                    //  Reset TCCR1B.  Defined as TIMER1_STOP.
  //TCCR1B |= (1 << WGM12 | 1 << CS12 | 1 << CS10); //  Set CTC Mode, prescale by 1024.  Defined as TIMER1_START.
  TIFR1 = (1 << OCF1B | 1 << OCF1A | 1 << TOV1);    //  Clear pending interrupts.

#if F_CPU == 8000000
  OCR1A = 0x030C;                                   //  Compare Match at 100 miliseconds. (8 MHz)
#elif F_CPU == 16000000
  OCR1A = 0x61A7;                                   //  Compare Match at 100 miliseconds. (16 MHz)
#endif

  TIMSK1 = 0x00;                                    //  Reset TIMSK1.
  TIMSK1 |= (1 << OCIE1A);                          //  Timer 1 Compare Match A Interrupt Enable.
 
  TCCR2B = 0x00;                                    //  Stop Timer 2.
 
  INTERRUPTS();

//
//
//
void readConfig()
{
  byte temp = 0x24;
 
  writeRegister(0x00, temp);
  Serial.print("AFE Gain Boost: ");
  printHex(temp >> 1);
  Serial.println();
 
  temp = readRegister(0x01);
  Serial.print("Noise Floor: ");
  Serial.println((temp & 0x70) >> 4);
  Serial.print("Watchdog Threshold: ");
  Serial.println(temp & 0x0F);
 
  temp = readRegister(0x02);
  Serial.print("Min Num Lightnings: ");
  Serial.println((temp & 0x30) >> 4);
  Serial.print("Spike Rejection: ");
  Serial.println(temp & 0x0F);
   
  temp =  readRegister(0x03) & 0x0F;
  Serial.print("Int Status: ");
  printHex(temp);
  Serial.println();
  Serial.println();

//
//
//
void getIntStatus()
{
  byte temp, noise;
  float distance;
 
  delay(3);
 
  temp =  readRegister(0x03) & 0x0F;
 
  if (temp > 0)
    {
      Serial.print("Int Status: ");
      printHex(temp);
      Serial.println();
    }
 
  switch(temp)
    {
      case 0x01:
        Serial.println("Adjusting Noise Level.");
        Serial.println();
        noise = readRegister(0x01);
        noise += 0x10;
        writeRegister(0x01, noise);
        status |= INT;
        return;
 
      case 0x04:
        return;
        printTime();
        Serial.print("  ");
        printDate();
        Serial.println();
        Serial.println("Disturber detected.");
        Serial.println();
        break;
   
      case 0x08:
        distance = readRegister(0x07) & 0x3F;
        if (distance > 62)
          return;
        printTime();
        Serial.print("  ");
        printDate();
        Serial.println();
        Serial.println("Lightning detected.");
        distance *= .6214;                       //  Conversion from Km to Miles.
        Serial.print("Distance: ");
        Serial.println(distance, 2);
        Serial.println();
        break;
       
      default:
        break;     
    }   

//
//
//
void writeRegister(byte regAddr, byte data)
{
  Wire.beginTransmission(AS3935_ADDR);
  Wire.write(regAddr);
  Wire.write(data);
  Wire.endTransmission();
}
//
//
//
byte readRegister(byte regAddr)
{
  byte data = 0x00;
 
  Wire.beginTransmission(AS3935_ADDR);
  Wire.write(regAddr);
  Wire.endTransmission(false);
  Wire.requestFrom(AS3935_ADDR, 1, true);
 
  if (Wire.available() > 0)
    {
      data = Wire.read();
    }
  return data;
}
//
//  Functions are performed here.
//
void doFunction()
{
  function = Serial.read();
   
  switch (function)
    {
      case 't':
        RTC.getTime();
        printTime();
        Serial.print("  ");
        printDate();
        Serial.println();
        break;
     
      case 'i':
        getIntStatus();
        break;
     
      default:
        break;
    }
 
  Serial.flush();

//
//
//
void printHex(byte value)
{
  Serial.print("0x");
  Serial.print(value >> 4 & 0x0F, HEX);
  Serial.print(value >> 0 & 0x0F, HEX);
  Serial.print(" ");
}
//
//  Print the Time.
//
void printTime()
{
  for(int i = 0; i < 3; i++)
    {
      printDec(time[i]);
      if(i < 2)
        Serial.print(":");
    }
}
//
//  Print the Date.
//
void printDate()
{
  for(int i = 0; i < 3; i++)
    {
      printDec(date[i]);
      if(i < 2)
        Serial.print("/");
    }
}
//
//  Decimal print utility - prints leading zero.
//
void printDec(int value)
{
  if(value < 10)
    Serial.print("0");
  Serial.print(value);
}
//
//  Interrupt 0 or 4 Service Routine - Triggered on the Rising edge.
//
#if defined (__AVR_ATmega168__) || defined (__AVR_ATmega328P__)
ISR(INT0_vect, ISR_NOBLOCK)
#elif defined (__AVR_ATmega1280__) || defined (__AVR_ATmega2560__)
ISR(INT4_vect, ISR_NOBLOCK)
#endif
{
  if (status & CAL)
    {
      counter++;
      return;
    }
 
  if (status & RUN)
    status |= INT;
}   
//
//  Timer 1 Compare Match A Interrupt Service Routine -  Used as a 100ms timer.
//
ISR(TIMER1_COMPA_vect)
{
  timer = 0;
}

Ray

Offline YFandS

  • Member
  • *
  • Posts: 2
Re: Austria Microsystems AS3935 Franklin Lightning Sensor IC
« Reply #15 on: July 01, 2013, 01:48:22 AM »
Thanks for sharing, eager to test it, where's the bad weather when you need it..

Regards
Frank

Offline SLOweather

  • Global Moderator
  • Forecaster
  • *****
  • Posts: 3456
    • Weatherelement Moline IL
Re: Austria Microsystems AS3935 Franklin Lightning Sensor IC
« Reply #16 on: July 13, 2013, 03:31:43 PM »
We're including this chip on Rev C of the WeatherElement WeatherLab VP2 ISS cellular replacement board. To that end, I just this week received the dev kit, with a built up demo detector and a lightning emulator board.



It's pretty cool...

Offline Bushman

  • Forecaster
  • *****
  • Posts: 7549
    • Eagle Bay Weather
Re: Austria Microsystems AS3935 Franklin Lightning Sensor IC
« Reply #17 on: July 13, 2013, 08:05:47 PM »
How will you integrate the reporting?  It sounds intriguing...
Need low cost IP monitoring?  http://wirelesstag.net/wta.aspx?link=NisJxz6FhUa4V67/cwCRWA or PM me for 50% off Wirelesstags!!

Offline SLOweather

  • Global Moderator
  • Forecaster
  • *****
  • Posts: 3456
    • Weatherelement Moline IL
Re: Austria Microsystems AS3935 Franklin Lightning Sensor IC
« Reply #18 on: July 14, 2013, 01:01:13 AM »
How will you integrate the reporting?  It sounds intriguing...

Since we are cellular based, and data bandwidth is at a premium, unless the client wants more, probably the standard distance to the leading edge of the storm will be the primary output. We already have a firmware version that is rain gauge specific for reporting frequency for precip researchers. It's a small leap to make a lightning one the same way. We can combine report-on-schedule with report-by-exception, which is pretty cool.

 This chip will never be another Boltek. However, for its niche, it seems to me that it's an impressive piece of engineering.

Offline miraculon

  • Sunrise Side Weather
  • Forecaster
  • *****
  • Posts: 4107
  • KE8DAF
    • Sunrise Side Weather in Rogers City MI USA
Re: Austria Microsystems AS3935 Franklin Lightning Sensor IC
« Reply #19 on: December 07, 2013, 09:03:31 PM »
I just received today a small board from Embedded Adventures.
http://www.embeddedadventures.com/as3935_lightning_sensor_module_mod-1016.html


The latest v5.0 firmware of the Blitzortung RED system supports the AS3935. It uses I2C ports on the STM-32 Discovery board to communicate with the chip. I figured for $20 it was worth a try. I still need a few parts.

It should be interesting to play around with.

Too bad that lightning season is pretty much over around here...
 :-(

Greg



Blitzortung Stations #706 and #1682
CoCoRaHS: MI-PI-1
CWOP: CW4114 and KE8DAF-13
WU: KMIROGER7
Amateur Radio Callsign: KE8DAF

Offline Old Tele man

  • Singing in the rain...
  • Forecaster
  • *****
  • Posts: 1365
Re: Austria Microsystems AS3935 Franklin Lightning Sensor IC
« Reply #20 on: December 07, 2013, 10:43:25 PM »
Uh, any old-fashioned AM radio will make an excellent 'detector' of lightning.

Just turn it on, tune "between" stations, and listen for the LOUD broad-band "snap, crackle & pop" that each lightning creates.
• SYS: Davis VP2 Vue/WL-IP & Envoy8X/WL-USB;
• DBX2 & DBX1 Precision Digital Barographs
• CWOP: DW6988 - 2 miles NNE of Cortaro, AZ
• WU - KAZTUCSO202, Countryside

Offline miraculon

  • Sunrise Side Weather
  • Forecaster
  • *****
  • Posts: 4107
  • KE8DAF
    • Sunrise Side Weather in Rogers City MI USA
Re: Austria Microsystems AS3935 Franklin Lightning Sensor IC
« Reply #21 on: December 08, 2013, 06:33:09 AM »
Uh, any old-fashioned AM radio will make an excellent 'detector' of lightning.

Just turn it on, tune "between" stations, and listen for the LOUD broad-band "snap, crackle & pop" that each lightning creates.

Sure enough. That is one of the reasons that they invented FM wasn't it?
I also listen to lightning on an old Radio Shack Realistic DX200 at about 200KHz.
On AM band, near the low end <550KHz is a good place to listen.

Greg


Blitzortung Stations #706 and #1682
CoCoRaHS: MI-PI-1
CWOP: CW4114 and KE8DAF-13
WU: KMIROGER7
Amateur Radio Callsign: KE8DAF

Offline Old Tele man

  • Singing in the rain...
  • Forecaster
  • *****
  • Posts: 1365
Re: Austria Microsystems AS3935 Franklin Lightning Sensor IC
« Reply #22 on: December 08, 2013, 12:38:30 PM »
Just "time" the interval between the "electronic" ZAP and the "acoustic" BANG and you have the longitudinal (radial) distance from the lightning strike.

Velocity of rf-ZAP is effectively 'instantaneous' but longitudinal velocity of sound (BANG) is 343.2 m/s (~1126 ft/sec) at 20ºC (68ºF):

Vsl = 331*SQRT[ Tº/273º ]

...or, approximately:

Vsl ~ 331 + 0.6*Cº

...where:
Vsl = Longitudinal velocity of sound, meter/sec.
Tº = Temperature in degrees_Kº, so: Tº = 273º+Cº
Cº = Temperature in degrees_Cº

Of course, there's also the "rule-of-thumb" formula: 1 mile-per-5 seconds.

Note: Speed of sound through AIR is independent of (a) barometric pressure, (b) frequency, and (c) wavelength...it only depends upon AIR temperature!
« Last Edit: December 08, 2013, 01:50:09 PM by Old Tele man »
• SYS: Davis VP2 Vue/WL-IP & Envoy8X/WL-USB;
• DBX2 & DBX1 Precision Digital Barographs
• CWOP: DW6988 - 2 miles NNE of Cortaro, AZ
• WU - KAZTUCSO202, Countryside