/MOD-1016

Source and examples for talking to the MOD-1016 AS3935 lightning sensor module

Primary LanguageC++

MOD-1016

Arduino library and sample sketch for the AS3935 MOD-1016 Lightning Sensor.

Using the library

The MOD-1016 lightning sensor can be interfaced with using I2C or SPI, using Arduino's Wire or SPI library.

init(uns8 irqPin)

Use this function to communicate with the sensor using I2C protocol.

init(uns8 irqPin, uns8 csPin)

Use this function to use Arduino's SPI library for communicating with the sensor. The CS pin is user-defined.

autoTuneCaps(uns8 irqPin)

When you purchase the sensor, it comes pre-set to the best value and includes that value on the label. Should you misplace the label or forget the right tuning value, use this function to automatically set it for you.

getNoiseFloor()	

Use this function to get the current noise floor setting (0-7).

getAFE()

Use this function to determine if the sensor is set for indoors (18) or outdoors (14).

getTuneCaps()

Use this function to get the current antenna tuning (0-15)

getIRQ()

Use this function to get the event type that asserted the interrupt pin.

calculateDistance()

Get the estimated distance of the lightning source. Out of range = -1, 0 = source is overhead, and 1 = not in the distance estimation table (Table 17 in the AS3935 datasheet).

getIntensity()

Get the calculated energy intensity measured by the sensor. It has no physical meaning at all but it's nice to look at :)

Tested with the following boards

  • Arduino Uno/compatible (using SPI and I2C)
  • Arduino Nano (using SPI and I2C)
  • ESP7 breakout and ESP12E breakout (using I2C -> SDA/SCL = IO5/IO4)