raspberryPi V0.2

pull/2/head
ouki-wang 6 years ago
parent 26a9bf394f
commit 8d6a26ece5
  1. 31
      RaspberryPi/Python/example/DFRobot_AS3935_detailed.py
  2. 12
      RaspberryPi/Python/example/DFRobot_AS3935_ordinary.py

@ -4,16 +4,16 @@
# This sensor can detect lightning and display the distance and intensity of the lightning within 40 km # This sensor can detect lightning and display the distance and intensity of the lightning within 40 km
# It can be set as indoor or outdoor mode. # It can be set as indoor or outdoor mode.
# The module has three I2C, these addresses are: # The module has three I2C, these addresses are:
# AS3935_ADD1 0x01 A0 = High A1 = Low # AS3935_ADD1 0x01 A0 = 1 A1 = 0
# AS3935_ADD3 0x03 A0 = High A1 = High # AS3935_ADD2 0x02 A0 = 0 A1 = 1
# AS3935_ADD2 0x02 A0 = Low A1 = High # AS3935_ADD3 0x03 A0 = 1 A1 = 1
# #
# #
# Copyright [DFRobot](http://www.dfrobot.com), 2018 # Copyright [DFRobot](http://www.dfrobot.com), 2018
# Copyright GNU Lesser General Public License # Copyright GNU Lesser General Public License
# #
# version V0.1 # version V0.2
# date 2018-11-13 # date 2018-11-28
import sys import sys
sys.path.append('../') sys.path.append('../')
@ -29,17 +29,7 @@ AS3935_I2C_ADDR3 = 0X03
#Antenna tuning capcitance (must be integer multiple of 8, 8 - 120 pf) #Antenna tuning capcitance (must be integer multiple of 8, 8 - 120 pf)
AS3935_CAPACITANCE = 96 AS3935_CAPACITANCE = 96
IRQ_PIN = 37 IRQ_PIN = 7
#Indoor/outdoor mode selection
AS3935_INDOORS = 0
AS3935_OUTDOORS = 1
AS3935_MODE = AS3935_INDOORS
#Enable/disable disturber detection
AS3935_DIST_DIS = 0
AS3935_DIST_EN = 1
AS3935_DIST = AS3935_DIST_EN
GPIO.setmode(GPIO.BOARD) GPIO.setmode(GPIO.BOARD)
@ -51,7 +41,7 @@ else:
while True: while True:
pass pass
#Configure sensor #Configure sensor
sensor.manualCal(AS3935_CAPACITANCE, AS3935_MODE, AS3935_DIST) sensor.powerUp()
#set indoors or outdoors models #set indoors or outdoors models
sensor.setIndoors() sensor.setIndoors()
@ -61,6 +51,11 @@ sensor.setIndoors()
sensor.disturberEn() sensor.disturberEn()
#sensor.disturberDis() #sensor.disturberDis()
sensor.setIrqOutputSource(0)
time.sleep(0.5)
#set capacitance
sensor.setTuningCaps(AS3935_CAPACITANCE)
# Connect the IRQ and GND pin to the oscilloscope. # Connect the IRQ and GND pin to the oscilloscope.
# uncomment the following sentences to fine tune the antenna for better performance. # uncomment the following sentences to fine tune the antenna for better performance.
# This will dispaly the antenna's resonance frequency/16 on IRQ pin (The resonance frequency will be divided by 16 on this pin) # This will dispaly the antenna's resonance frequency/16 on IRQ pin (The resonance frequency will be divided by 16 on this pin)
@ -74,7 +69,7 @@ sensor.setNoiseFloorLv1(2)
#noiseLv = sensor.getNoiseFloorLv1() #noiseLv = sensor.getNoiseFloorLv1()
#used to modify WDTH,alues should only be between 0x00 and 0x0F (0 and 7) #used to modify WDTH,alues should only be between 0x00 and 0x0F (0 and 7)
sensor.setWatchdogThreshold(0) sensor.setWatchdogThreshold(1)
#wtdgThreshold = sensor.getWatchdogThreshold() #wtdgThreshold = sensor.getWatchdogThreshold()
#used to modify SREJ (spike rejection),values should only be between 0x00 and 0x0F (0 and 7) #used to modify SREJ (spike rejection),values should only be between 0x00 and 0x0F (0 and 7)

@ -4,16 +4,16 @@
# This sensor can detect lightning and display the distance and intensity of the lightning within 40 km # This sensor can detect lightning and display the distance and intensity of the lightning within 40 km
# It can be set as indoor or outdoor mode. # It can be set as indoor or outdoor mode.
# The module has three I2C, these addresses are: # The module has three I2C, these addresses are:
# AS3935_ADD1 0x01 A0 = High A1 = Low # AS3935_ADD1 0x01 A0 = 1 A1 = 0
# AS3935_ADD3 0x03 A0 = High A1 = High # AS3935_ADD2 0x02 A0 = 0 A1 = 1
# AS3935_ADD2 0x02 A0 = Low A1 = High # AS3935_ADD3 0x03 A0 = 1 A1 = 1
# #
# #
# Copyright [DFRobot](http://www.dfrobot.com), 2018 # Copyright [DFRobot](http://www.dfrobot.com), 2018
# Copyright GNU Lesser General Public License # Copyright GNU Lesser General Public License
# #
# version V0.1 # version V0.2
# date 2018-11-13 # date 2018-11-28
import sys import sys
sys.path.append('../') sys.path.append('../')
@ -29,7 +29,7 @@ AS3935_I2C_ADDR3 = 0X03
#Antenna tuning capcitance (must be integer multiple of 8, 8 - 120 pf) #Antenna tuning capcitance (must be integer multiple of 8, 8 - 120 pf)
AS3935_CAPACITANCE = 96 AS3935_CAPACITANCE = 96
IRQ_PIN = 37 IRQ_PIN = 7
#Indoor/outdoor mode selection #Indoor/outdoor mode selection
AS3935_INDOORS = 0 AS3935_INDOORS = 0

Loading…
Cancel
Save