@@ -8,9 +8,9 @@ This Python module let's you control the AS3935 lightning detector. The board us
88 3 . It allows you to perform every action described in the [ datasheet] ( http://www.embeddedadventures.com/datasheets/AS3935_Datasheet_EN_v2.pdf ) .
99
1010To install it from Pypi:
11- ```
11+ ```
1212$ pip install as3935
13- ```
13+ ```
1414
1515
1616# 1. Connection of the device
@@ -60,14 +60,14 @@ This module has been tested on Python 3.7. It might work on other versions as we
6060It is very simple to use. Just import it and create a new object with the configuration you need.
6161
6262```
63- from as3935 import AS3935
63+ import as3935
6464import pigpio
6565
6666irq_pin_number = 4 # BCM number (code after GPIO)
6767bus = 1 # On newer Raspberrys is 1
6868address = 0x03 # If using MOD-1016 this is the address
6969
70- sensor = AS3935 .AS3935(irq_pin_number, bus, address)
70+ sensor = as3935 .AS3935(irq_pin_number, bus, address)
7171
7272# We need to calibrate the sensor first. Use the tuning cap provided
7373# or calculate it using sensor.calculate_tuning_cap(*args)
@@ -78,22 +78,22 @@ sensor.set_indoors(True)
7878# Every time you sense a pulse on IRQ it means there is an
7979# interruption request. You can read it like this:
8080def irq_callback(gpio, level, tick):
81- interruption = sensor.get_interrupt()
82- if interruption == AS3935 .INT_NH:
83- print("Noise floor too high")
84- elif interruption == AS3935 .INT_D:
85- print("Disturbance detected. Mask it?")
86- elif interruption == AS3935 .INT_L:
87- print("Lightning detected!")
88- distance = sensor.get_distance()
81+ interruption = sensor.get_interrupt()
82+ if interruption == as3935 .INT_NH:
83+ print("Noise floor too high")
84+ elif interruption == as3935 .INT_D:
85+ print("Disturbance detected. Mask it?")
86+ elif interruption == as3935 .INT_L:
87+ print("Lightning detected!")
88+ distance = sensor.get_distance()
8989
9090try:
91- cb = sensor.pi.callback(irq_pin_number, pigpio.RISING_EDGE, irq_callback)
92- while True:
93- pass
91+ cb = sensor.pi.callback(irq_pin_number, pigpio.RISING_EDGE, irq_callback)
92+ while True:
93+ pass
9494finally:
95- cb.cancel()
96- sensor.pi.stop()
95+ cb.cancel()
96+ sensor.pi.stop()
9797```
9898
9999This above is a very simple example. Check the full documentation to learn all the methods you can call.
0 commit comments