Skip to content

Commit aef25c4

Browse files
committed
Fixed setup.py
1 parent e570b03 commit aef25c4

4 files changed

Lines changed: 592 additions & 71 deletions

File tree

README.md

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# Welcome to python_as3935!
22

3-
This Python module let's you control the AS3935 lightning detector. The board used is the MOD-1016 from [EmbeddedAdventures](http://www.embeddedadventures.com/as3935_lightning_sensor_module_mod-1016.html).
3+
This Python module let's you control the AS3935 lightning detector. The board used is the MOD-1016 from [EmbeddedAdventures](http://www.embeddedadventures.com/as3935_lightning_sensor_module_mod-1016.html).
44

55

66
1. It works with [Pigpio](http://abyz.me.uk/rpi/pigpio/) instead of the common [RPi.GPIO](https://pypi.org/project/RPi.GPIO/), in order to be able to use it without being root.
77
2. The communication with the device is done via I2C serial protocol.
88
3. It allows you to perform every action described in the [datasheet](http://www.embeddedadventures.com/datasheets/AS3935_Datasheet_EN_v2.pdf).
99

10-
To install it from Pypi:
10+
To install it from Pypi:
1111
```
12-
$ pip instal as3935
12+
$ pip install as3935
1313
```
1414

1515

@@ -31,22 +31,22 @@ If using a [40-pin GPIO](https://www.raspberrypi.org/documentation/usage/gpio/)
3131

3232
Install the Pigpio daemon, either from source or via:
3333
```
34-
$ sudo apt install pigpio
34+
$ sudo apt install pigpio
3535
```
3636
Configure *Remote GPIO* using (if on Raspbian):
3737

3838
```
39-
$ sudo raspi-config
39+
$ sudo raspi-config
4040
```
4141
Enable the daemon and start it now:
4242
```
43-
$ sudo systemctl enable pigpiod
44-
$ sudo systemctl start pigpiod
43+
$ sudo systemctl enable pigpiod
44+
$ sudo systemctl start pigpiod
4545
```
4646
Install the [Python interface](https://pypi.org/project/pigpio/):
4747

4848
```
49-
$ pip install pigpio
49+
$ pip install pigpio
5050
```
5151

5252
For further information, visit [Pigpio's](http://abyz.me.uk/rpi/pigpio/pigpiod.html) webpage.
@@ -60,40 +60,40 @@ This module has been tested on Python 3.7. It might work on other versions as we
6060
It 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
64-
import pigpio
63+
from as3935 import AS3935
64+
import pigpio
6565
66-
irq_pin_number = 4 # BCM number (code after GPIO)
67-
bus = 1 # On newer Raspberrys is 1
68-
address = 0x03 # If using MOD-1016 this is the address
69-
70-
sensor = AS3935.AS3935(irq_pin_number, bus, address)
71-
72-
# We need to calibrate the sensor first. Use the tuning cap provided
73-
# or calculate it using sensor.calculate_tuning_cap(*args)
74-
sensor.full_calibration(12)
75-
76-
sensor.set_indoors(True)
77-
78-
# Every time you sense a pulse on IRQ it means there is an
79-
# interruption request. You can read it like this:
80-
def 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()
89-
90-
try:
91-
cb = sensor.pi.callback(irq_pin_number, pigpio.RISING_EDGE, irq_callback)
92-
while True:
93-
pass
94-
finally:
95-
cb.cancel()
96-
sensor.pi.stop()
66+
irq_pin_number = 4 # BCM number (code after GPIO)
67+
bus = 1 # On newer Raspberrys is 1
68+
address = 0x03 # If using MOD-1016 this is the address
69+
70+
sensor = AS3935.AS3935(irq_pin_number, bus, address)
71+
72+
# We need to calibrate the sensor first. Use the tuning cap provided
73+
# or calculate it using sensor.calculate_tuning_cap(*args)
74+
sensor.full_calibration(12)
75+
76+
sensor.set_indoors(True)
77+
78+
# Every time you sense a pulse on IRQ it means there is an
79+
# interruption request. You can read it like this:
80+
def 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()
89+
90+
try:
91+
cb = sensor.pi.callback(irq_pin_number, pigpio.RISING_EDGE, irq_callback)
92+
while True:
93+
pass
94+
finally:
95+
cb.cancel()
96+
sensor.pi.stop()
9797
```
9898

9999
This above is a very simple example. Check the full documentation to learn all the methods you can call.
@@ -128,7 +128,7 @@ It is licensed under the GNU General Public License v3.0 (please read LICENSE.tx
128128

129129
- *INT_NH*: noise level too high
130130
- *INT_D*: man-made disturbance detected
131-
- *INT_L: lightning detected
131+
- *INT_L*: lightning detected
132132

133133
## 5.2 Class AS3935
134134
It provides an object to control the AS3935.

0 commit comments

Comments
 (0)