Introduction
A CircuitPython driver library for the Franklin AS3935 lightning detector. The driver supports connections via SPI and I2C.
See the AS3935 datasheet for more details of chip operation.
Dependencies
This driver depends on:
Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle or individual libraries can be installed using circup.
Installing from PyPI
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:
pip3 install adafruit-circuitpython-as3935
To install system-wide (this may be required in some cases):
sudo pip3 install adafruit-circuitpython-as3935
To install in a virtual environment in your current project:
mkdir project-name && cd project-name
python3 -m venv .env
source .env/bin/activate
pip3 install adafruit-circuitpython-as3935
Running The Unittests
To run the unittests on you will need to install Pytest and Pytest Mock.
pip3 install pytest pytest-mock
To install system-wide (this may be required in some cases):
sudo pip3 install pytest pytest-mock
Usage Example
For a SPI connection:
"""Loop and wait for an event.
Note that the sensor only responds to lightning and certain kinds of noise,
so unless it is stormy, there's not much to see here.
"""
import time
import board
import biffobear_as3935
# Edit the chip select and interrupt pins to match the connections to your board
interrupt_pin = board.D7 # Connected to the sensor interrupt pin
# For a SPI connection (recommended)
spi = board.SPI() # Works for most Adafruit and Blinka boards
cs_pin = board.D5 # Connect to the sensor chip select pin
sensor = biffobear_as3935.AS3935(spi, cs_pin, interrupt_pin=interrupt_pin)
# For an I2C connection
# i2c = board.I2C() # Works for most Adafruit and Blinka boards
# sensor = biffobear_as3935.AS3935_I2C(i2c, interrupt_pin=interrupt_pin)
while True:
if sensor.interrupt_set: # An event has occurred
# The interrupt_status is cleared after a read, so assign it
# to a variable in case you need the value later.
event_type = sensor.interrupt_status
if event_type == sensor.LIGHTNING: # It's a lightning event
print(f"Strike Energy = {sensor.energy}")
print(f"Distance to storm front = {sensor.distance} km")
elif event_type == sensor.DISTURBER:
print("False alarm")
else:
print("No event detected")
# Minimum time between strike events is 1 second so poll frequently!
time.sleep(0.5)
Contributing
Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.
Documentation
For information on building library documentation, please check out this guide.
Metadata
Release files for biffobear-circuitpython-as3935 2.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| biffobear-circuitpython-as3935-2.0.3.tar.gz | 42.5 kB | Without provenance | Details |
Release files / biffobear-circuitpython-as3935-2.0.3.tar.gz
| Download URL | biffobear-circuitpython-as3935-2.0.3.tar.gz |
|---|---|
| Size | 42.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2bba754776f9b6af1daa0384474a77e6b2347050a29e94d0a30f14a4e94ca331
|
|
BLAKE2b-256 checksum How to use checksums |
4a836b476e3e20ff99406f1ac6b3bbff9732ef42471f4bca43bc767a6525643c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
|
Security for biffobear-circuitpython-as3935 2.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.