Skip to content

Commit b2a65e7

Browse files
committed
Fixed example on README
1 parent aef25c4 commit b2a65e7

File tree

5 files changed

+67
-27
lines changed

5 files changed

+67
-27
lines changed

README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -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

1010
To 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
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
63+
import as3935
6464
import pigpio
6565
6666
irq_pin_number = 4 # BCM number (code after GPIO)
6767
bus = 1 # On newer Raspberrys is 1
6868
address = 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:
8080
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()
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
9090
try:
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
9494
finally:
95-
cb.cancel()
96-
sensor.pi.stop()
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.

README.rst

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ board used is the MOD-1016 from
1212
3. It allows you to perform every action described in the
1313
`datasheet <http://www.embeddedadventures.com/datasheets/AS3935_Datasheet_EN_v2.pdf>`__.
1414

15-
To install it from Pypi: ``$ pip instal as3935``
15+
To install it from Pypi:
16+
17+
::
18+
19+
$ pip install as3935
1620

1721
1. Connection of the device
1822
===========================
@@ -83,14 +87,14 @@ the configuration you need.
8387

8488
::
8589

86-
from as3935 import AS3935
90+
import as3935
8791
import pigpio
8892
8993
irq_pin_number = 4 # BCM number (code after GPIO)
9094
bus = 1 # On newer Raspberrys is 1
9195
address = 0x03 # If using MOD-1016 this is the address
9296

93-
sensor = AS3935.AS3935(irq_pin_number, bus, address)
97+
sensor = as3935.AS3935(irq_pin_number, bus, address)
9498

9599
# We need to calibrate the sensor first. Use the tuning cap provided
96100
# or calculate it using sensor.calculate_tuning_cap(*args)
@@ -102,11 +106,11 @@ the configuration you need.
102106
# interruption request. You can read it like this:
103107
def irq_callback(gpio, level, tick):
104108
interruption = sensor.get_interrupt()
105-
if interruption == AS3935.INT_NH:
109+
if interruption == as3935.INT_NH:
106110
print("Noise floor too high")
107-
elif interruption == AS3935.INT_D:
111+
elif interruption == as3935.INT_D:
108112
print("Disturbance detected. Mask it?")
109-
elif interruption == AS3935.INT_L:
113+
elif interruption == as3935.INT_L:
110114
print("Lightning detected!")
111115
distance = sensor.get_distance()
112116

@@ -116,7 +120,7 @@ the configuration you need.
116120
pass
117121
finally:
118122
cb.cancel()
119-
sensor.pi.stop()
123+
sensor.pi.stop()
120124

121125
This above is a very simple example. Check the full documentation to
122126
learn all the methods you can call.

as3935/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from as3953.AS3935 import AS3935, INT_L, INT_D, INT_NH
1+
from as3935.AS3935 import AS3935, INT_L, INT_D, INT_NH

example.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import as3935
2+
import pigpio
3+
4+
irq_pin_number = 4 # BCM number (code after GPIO)
5+
bus = 1 # On newer Raspberrys is 1
6+
address = 0x03 # If using MOD-1016 this is the address
7+
8+
sensor = as3935.AS3935(irq_pin_number, bus, address)
9+
10+
# We need to calibrate the sensor first. Use the tuning cap provided
11+
# or calculate it using sensor.calculate_tuning_cap(*args)
12+
sensor.full_calibration(12)
13+
14+
sensor.set_indoors(True)
15+
16+
17+
# Every time you sense a pulse on IRQ it means there is an
18+
# interruption request. You can read it like this:
19+
def irq_callback(gpio, level, tick):
20+
interruption = sensor.get_interrupt()
21+
if interruption == as3935.INT_NH:
22+
print("Noise floor too high")
23+
elif interruption == as3935.INT_D:
24+
print("Disturbance detected. Mask it?")
25+
elif interruption == as3935.INT_L:
26+
print("Lightning detected!")
27+
distance = sensor.get_distance()
28+
29+
30+
try:
31+
cb = sensor.pi.callback(irq_pin_number, pigpio.RISING_EDGE, irq_callback)
32+
while True:
33+
pass
34+
finally:
35+
cb.cancel()
36+
sensor.pi.stop()

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
setup(
99
name='as3935',
1010
packages=['as3935'],
11-
version='0.1.1',
11+
version='0.1.3',
1212
license='gpl-3.0',
1313
description="A Python3 module to control the lightning detector AS3935 chip",
1414
long_description=long_description,
1515
long_description_content_type="text/x-rst",
1616
author = 'Eloi Codina',
1717
author_email = 'eloi.codina@gmail.com',
1818
url = 'https://github.com/ecodina/python_as3935',
19-
download_url='https://github.com/ecodina/python_as3935/archive/v0.1.1-beta.tar.gz',
19+
download_url='https://github.com/ecodina/python_as3935/archive/v0.1.3-beta.tar.gz',
2020
keywords = ['python', 'raspberry', 'gpio', 'lightning', 'sensor'],
2121
install_requires=[
2222
'pigpio',

0 commit comments

Comments
 (0)