2019-10-19 22:23:18 +02:00
AMS AS3935 Franklin Lightning Sensor
====================================
.. seo ::
:description: Instructions for setting up AS3935 lightning sensor
2021-11-16 03:19:33 +01:00
:image: as3935.jpg
2019-10-19 22:23:18 +02:00
:keywords: as3935
2021-02-20 22:02:46 +01:00
The **AS3935** sensor platform allows you to use your AS3935 sensor
2019-10-19 22:23:18 +02:00
(`AliExpress`_ , `AMS_AS3935`_ )
in order to get notified when a thunderstorm is getting close.
The AS3935 can detect the presence of lightning activity and provide an estimation
2019-11-05 21:42:49 +01:00
on the distance to the head of the storm. The chip issues a notification through an interrupt
2019-10-19 22:23:18 +02:00
pin.
2021-02-20 22:02:46 +01:00
Component/Hub
-------------
2020-11-09 02:22:55 +01:00
The AS3935 can be configured to use either the SPI **or** I²C protocol for data communication.
2019-10-19 22:23:18 +02:00
First choose which communication method you want to use for the sensor, set the SI pin for the appropriate
2024-05-07 07:16:56 +02:00
level and set up the ESPHome component for the chosen communication method.
2019-10-19 22:23:18 +02:00
Module Pins
-----------
============ ===============================================================
2020-05-10 21:27:59 +02:00
Module Pin Description
2019-10-19 22:23:18 +02:00
============ ===============================================================
2020-05-10 21:27:59 +02:00
VCC/VDD Positive supply voltage
GND Ground
SCL I²C clock bus or SPI clock bus (according to SI setting)
MOSI I²C data bus or SPI data input bus (according to SI setting)
MISO SPI data output bus
CS Chip Select (active low)
SI Select Interface (GND → SPI or VDD → I²C)
IRQ Interrupt (out)
EN_V Voltage Regulator Enable
A0 I²C address selection LSB
A1 I²C address selection MSB
2019-10-19 22:23:18 +02:00
============ ===============================================================
.. figure :: images/as3935.jpg
:align: center
:width: 50.0%
AS3935 Lightning Sensor.
.. _AliExpress: https://de.aliexpress.com/af/as3935.html?SearchText=as3935
.. _AMS_AS3935: https://ams.com/as3935
2021-02-20 22:02:46 +01:00
Over SPI
--------
The `` as3935_spi `` sensor platform allows you to use your AS3935 sensor
(`AliExpress`_ , `AMS_AS3935`_ ) in order to get notified when a thunderstorm is getting close.
2019-10-19 22:23:18 +02:00
.. code-block :: yaml
2024-05-07 07:40:12 +02:00
# Example configuration for SPI
2019-10-19 22:23:18 +02:00
as3935_spi:
2024-05-07 07:40:12 +02:00
cs_pin: GPIOXX
irq_pin: GPIOXX
2019-10-19 22:23:18 +02:00
2021-02-20 22:02:46 +01:00
Configuration variables:
***** ***** ***** ***** *** *
2019-10-19 22:23:18 +02:00
2021-02-20 22:02:46 +01:00
- **cs_pin** (**Required** , :ref: `Pin Schema <config-pin_schema>` ): The chip select pin.
2019-10-27 12:30:25 +01:00
- **irq_pin** (**Required** , :ref: `config-pin` ): The IRQ pin, which indicates if a lightning strike has been detected.
2019-10-19 22:23:18 +02:00
- **indoor** (*Optional* , boolean): Indicates if the sensor is used indoor. Defaults to `` true `` .
2021-11-28 19:57:01 +01:00
- **noise_level** (*Optional* , int): Noise floor level is compared to known reference voltage.
2019-10-19 22:23:18 +02:00
If this level is exceeded the chip will issue an interrupt to the IRQ pin, broadcasting that it can not
operate properly due to noise (INT_NH). Defaults to `` 2 `` .
2021-11-28 19:57:01 +01:00
- **spike_rejection** (*Optional* , int): Helps to differentiate between false events and actual lightning.
2019-10-19 22:23:18 +02:00
Increasing this value increases robustness at the cost of sensitivity to distant events. Defaults to `` 2 `` .
2021-11-28 19:57:01 +01:00
- **lightning_threshold** (*Optional* , int): The number of lightnings that must appear in a 15-minute time
2019-10-19 22:23:18 +02:00
window before a lightning storm is detected.
15 minutes is the window of time before the number of detected lightning events is reset.
The number of lightning strikes can be set to 1,5,9, or 16. Defaults to `` 1 `` .
- **mask_disturber** (*Optional* , boolean): This setting will return whether or not disturbers trigger
the IRQ Pin. Defaults to `` false `` .
2021-11-28 19:57:01 +01:00
- **div_ratio** (*Optional* , int): The antenna is designed to resonate at 500kHz and so can be tuned
2019-10-19 22:23:18 +02:00
with the following setting. The accuracy of the antenna must be within 3.5 percent of that value for
proper signal validation and distance estimation. Defaults to `` 0 `` .
2021-11-28 19:57:01 +01:00
- **capacitance** (*Optional* , int): This setting will add capacitance to the series RLC antenna on the product
2019-10-19 22:23:18 +02:00
to help tune its resonance. The datasheet specifies being within 3.5 percent of 500kHz to get optimal lightning
detection and distance sensing. It's possible to add up to 120pF in steps of 8pF to the antenna. Defaults to `` 0 `` .
2021-11-28 19:57:01 +01:00
- **watchdog_threshold** (*Optional* , int): Determines the threshold for events that trigger the IRQ pin.
2019-10-19 22:23:18 +02:00
Defaults to `` 2 `` .
2023-10-12 03:27:39 +02:00
- **tune_antenna** (*Optional* , boolean): Start sensor in antenna tuning mode. It will emit oscillator
frequency to be read on the INT pin. Please follow AS3935 documentation. Note that while this mode is enabled,
lightings will not be detected. It should be used for initial calibration only, in order to determine correct value of
`` capacitance `` and/or `` div_ratio `` parameters.
Defaults to `` False `` .
- **calibration** (*Optional* , boolean): Enable/disable oscillator calibration on startup. It is recommended to perform
antenna tuning procedure first and adjust parameters, so that RLC antenna resonance is tuned within optimal range.
Defaults to `` True `` .
2019-10-19 22:23:18 +02:00
2021-02-20 22:02:46 +01:00
Over I²C
--------
2019-10-19 22:23:18 +02:00
2021-02-20 22:02:46 +01:00
The `` as3935_i2c `` sensor platform allows you to use your AS3935 sensor
(`AliExpress`_ , `AMS_AS3935`_ ) in order to get notified when a thunderstorm is getting close.
2019-10-19 22:23:18 +02:00
.. code-block :: yaml
2024-05-07 07:40:12 +02:00
# Example configuration for I²C
2019-10-19 22:23:18 +02:00
as3935_i2c:
2024-05-07 07:40:12 +02:00
irq_pin: GPIOXX
2019-10-19 22:23:18 +02:00
2021-02-20 22:02:46 +01:00
Configuration variables:
***** ***** ***** ***** *** *
2020-11-09 02:22:55 +01:00
- **address** (*Optional* , int): Manually specify the I²C address of
2021-09-13 22:20:15 +02:00
the sensor. Defaults to `` 0x03 `` (`` A0 `` and `` A1 `` pins pulled high).
The address is made up using the state of `` A0 `` as bit 1 and the state of `` A1 `` as bit 2, so a total of four addresses is possible.
2021-02-20 22:02:46 +01:00
- **irq_pin** (**Required** , :ref: `config-pin` ): The IRQ pin, which indicates if a lightning strike has been detected.
- **indoor** (*Optional* , boolean): Indicates if the sensor is used indoor. Defaults to `` true `` .
2021-11-28 19:57:01 +01:00
- **noise_level** (*Optional* , int): Noise floor level is compared to known reference voltage.
2021-02-20 22:02:46 +01:00
If this level is exceeded the chip will issue an interrupt to the IRQ pin, broadcasting that it can not
operate properly due to noise (INT_NH). Defaults to `` 2 `` .
2021-11-28 19:57:01 +01:00
- **spike_rejection** (*Optional* , int): Helps to differentiate between false events and actual lightning.
2021-02-20 22:02:46 +01:00
Increasing this value increases robustness at the cost of sensitivity to distant events. Defaults to `` 2 `` .
2021-11-28 19:57:01 +01:00
- **lightning_threshold** (*Optional* , int): The number of lightnings that must appear in a 15-minute time
2021-02-20 22:02:46 +01:00
window before a lightning storm is detected.
15 minutes is the window of time before the number of detected lightning events is reset.
The number of lightning strikes can be set to 1,5,9, or 16. Defaults to `` 1 `` .
- **mask_disturber** (*Optional* , boolean): This setting will return whether or not disturbers trigger
the IRQ Pin. Defaults to `` false `` .
2021-11-28 19:57:01 +01:00
- **div_ratio** (*Optional* , int): The antenna is designed to resonate at 500kHz and so can be tuned
2021-02-20 22:02:46 +01:00
with the following setting. The accuracy of the antenna must be within 3.5 percent of that value for
proper signal validation and distance estimation. Defaults to `` 0 `` .
2021-11-28 19:57:01 +01:00
- **capacitance** (*Optional* , int): This setting will add capacitance to the series RLC antenna on the product
2021-02-20 22:02:46 +01:00
to help tune its resonance. The datasheet specifies being within 3.5 percent of 500kHz to get optimal lightning
detection and distance sensing. It's possible to add up to 120pF in steps of 8pF to the antenna. Defaults to `` 0 `` .
2021-11-28 19:57:01 +01:00
- **watchdog_threshold** (*Optional* , int): Determines the threshold for events that trigger the IRQ pin.
2021-02-20 22:02:46 +01:00
Defaults to `` 2 `` .
2023-10-12 03:27:39 +02:00
- **tune_antenna** (*Optional* , boolean): Start sensor in antenna tuning mode. It will emit oscillator
frequency to be read on the INT pin. Please follow AS3935 documentation. Note that while this mode is enabled,
lightings will not be detected. It should be used for initial calibration only, in order to determine correct value of
`` capacitance `` and/or `` div_ratio `` parameters.
Defaults to `` False `` .
- **calibration** (*Optional* , boolean): Enable/disable oscillator calibration on startup. It is recommended to perform
antenna tuning procedure first and adjust parameters, so that RLC antenna resonance is tuned within optimal range.
Defaults to `` True `` .
2019-10-19 22:23:18 +02:00
2021-02-20 22:02:46 +01:00
Sensor
------
2019-10-19 22:23:18 +02:00
2021-02-20 22:02:46 +01:00
A sensor platform to read lightning data
2019-10-19 22:23:18 +02:00
2024-05-07 07:40:12 +02:00
.. code-block :: yaml
sensor:
- platform: as3935
lightning_energy:
name: Lightning Energy
distance:
name: Distance Storm
2021-02-20 22:02:46 +01:00
Configuration variables:
- **lightning_energy** (*Optional* ): Lightning energy value. According to the datasheet this is only a pure value that doesn't have any physical meaning.
2024-05-07 07:40:12 +02:00
All options from :ref: `Sensor <config-sensor>` .
2021-02-20 22:02:46 +01:00
- **distance** (*Optional* ): Distance in km to the front of the storm and not the distance to a lightning strike.
2024-05-07 07:40:12 +02:00
All options from :ref: `Sensor <config-sensor>` .
2021-02-20 22:02:46 +01:00
Binary Sensor
-------------
Binary sensor that indicates if a lightning strike was detected.
2024-05-07 07:40:12 +02:00
.. code-block :: yaml
# Example storm alert binary sensor
binary_sensor:
- platform: as3935
name: Storm Alert
2021-02-20 22:02:46 +01:00
Configuration variables:
2024-05-07 07:40:12 +02:00
- All options from :ref: `Binary Sensor <config-binary_sensor>` .
2019-10-19 22:23:18 +02:00
See Also
--------
- :ref: `sensor-filters`
- :apiref: `as3935/as3935.h`
- `AliExpress <https://de.aliexpress.com/af/as3935.html?SearchText=as3935> `__
- `Data Sheet <https://www.embeddedadventures.com/datasheets/AS3935_Datasheet_EN_v2.pdf> `__
- `Little Arduino Projects <https://github.com/tardate/LittleArduinoProjects/tree/master/playground/AS3935> `__
- `AMS AS3935 <https://ams.com/as3935> `__
2020-05-10 21:27:59 +02:00
- `SparkFun Library <https://github.com/sparkfun/SparkFun_AS3935_Lightning_Detector_Arduino_Library> `__
2019-10-19 22:23:18 +02:00
- :ghedit: `Edit`