Very nice automation program. I am still looking to automate the weather here.
Testing 3 lightning sensors here and wondering...
Base RPi2 - using Wheezy - 9097 USB to Serial + ZWave dot me GPIO + PiFace RTC shim.
Combo temperature and humidity sensors - old AAG and Midon and Hobby boards combo sensors. Weather station is using Meteo stick and Davis. Dallas rain tipping bucket (1-wire) and Digital Rain sensor.
1 - Hobby Boards Lightning sensor - dual 1-wire counters - one is a total count and the other counter is a rate count.
Is there anything I can do to adjust display?
2 - EMP sensor - testing with Python and it works fine.
This one just counts pulses on GPIO port. I am testing 3. Each board has a flashing white LED and sound chirp board plus a digital and analogue output.
3 - AS3935 Lightning sensor
This one uses two GPIO ports and one IRQ pin for lightning and a distance count. Testing with Python and it works fine.
1-Wire Lightning
Moderator: leecollings
- PeteC
- Posts: 4
- Joined: Friday 07 July 2017 13:39
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.5877
- Location: Time
- Contact:
1-Wire Lightning
Automator
Hardware: ARM, Intel, AMD based Linux boxes
OS: now all Linux (and a bit of Wintel)
Automation: X10, Inteon, UPB, Zigbee and ZWave - HAI Leviton OmniPro 2 panel (security and automation)
Hardware: ARM, Intel, AMD based Linux boxes
OS: now all Linux (and a bit of Wintel)
Automation: X10, Inteon, UPB, Zigbee and ZWave - HAI Leviton OmniPro 2 panel (security and automation)
-
- Posts: 4
- Joined: Tuesday 18 July 2017 11:19
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.9700
- Location: Netherlands
- Contact:
Re: 1-Wire Lightning
Can you elaborate on the hardware setup and the python scripting used for the AS3935?
-
- Posts: 536
- Joined: Friday 23 December 2016 16:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: Netherlands Purmerend
- Contact:
Re: 1-Wire Lightning
Pete,
Have you tried the custom sensor ?
There you can change labels and so. Unfortunately I am struggling/not happy with tally it up per day.
So lables and flexability for a custom sensor is great and perhaps what you are looking for, but the totals in the way you do it now seems better.
Please have a look yourself perhaps reporting to both ( split and dual report? )
Have you tried the custom sensor ?
There you can change labels and so. Unfortunately I am struggling/not happy with tally it up per day.
So lables and flexability for a custom sensor is great and perhaps what you are looking for, but the totals in the way you do it now seems better.
Please have a look yourself perhaps reporting to both ( split and dual report? )
- PeteC
- Posts: 4
- Joined: Friday 07 July 2017 13:39
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.5877
- Location: Time
- Contact:
Re: 1-Wire Lightning
Here is a picture of the hardware set up.
And here is the Python script I am using. Currently just writing a log then sharing the log file to the Domoticz server.Code: Select all
# -*- coding: utf-8 -*-
#! /usr/bin/env python
"""
AS3935-monitor.py: A monitoring script for the AS3935 lightning
sensor on the MOD-1016 v6 breakout board. Requires both the
RaspberryPi-AS3935 and RPi.GPIO Python modules. Note that
the reset function requires VCT fork of RaspberryPi-AS3935.
simple invocation:
$ sudo python AS3935-monitor.py
error logging invocation:
$ sudo python -u AS3935-monitor.py > >(tee -a output.log) 2> >(tee error.log >&2)
Licensed under the GNU General Public License (GPL) version 2 or greater.
Copyright 2014 Vanguard Computer Technology Labs, Inc.
"""
from RPi_AS3935 import RPi_AS3935
import RPi.GPIO as GPIO
import time
from datetime import datetime
GPIO.setmode(GPIO.BCM)
## Rev 1 Raspberry Pi: bus=0
## Rev 2 and later Raspberry Pi: bus=1
## All: address=<i2c add>
sensor = RPi_AS3935(address=0x03, bus=1)
## Uncomment to reset all registers to factory default values.
sensor.reset()
sensor.calibrate(tun_cap=0x0D)
time.sleep(0.002)
sensor.set_indoors(False)
sensor.set_noise_floor(0)
## uncomment/set to filter out false positives
sensor.set_min_strikes(1)
def log_raw_data(data):
# need to pass time as parameter and convert to UTC here
utcnow = datetime.utcnow()
version = 01
timestamp = utcnow.strftime("%Y-%m-%d %H:%M:%S.%f")
outstring = str(version)+" "+str(timestamp)+" "+str(data)+" "+str(min_strikes)+" "+str(noise_floor)+"\n"
print(outstring)
f.write(outstring)
f.flush
def handle_interrupt(channel):
time.sleep(0.003)
global sensor
reason = sensor.get_interrupt()
if reason == 0x01:
print("Noise level too high - adjusting")
sensor.raise_noise_floor()
elif reason == 0x04:
print("Disturber detected - masking")
sensor.set_mask_disturber(True)
elif reason == 0x08:
now = datetime.now()
distance = sensor.get_distance()
if 0 < distance < 63:
log_raw_data(distance)
if distance == 1:
print("Overhead lightning detected - distance = " + str(distance) + " km at %s ") % now.strftime("%H:%M:%S.%f")[:-3],now.strftime("%Y-%m-%d")
elif 40 < distance < 63:
print("Distant lightning detected - distance = " + str(distance) + " kms at %s") % now.strftime("%H:%M:%S.%f")[:-3],now.strftime("%Y-%m-%d")
elif 2 <= distance <= 40:
print("Lightning detected - distance = " + str(distance) + " kms at %s") % now.strftime("%H:%M:%S.%f")[:-3],now.strftime("%Y-%m-%d")
else:
print("Invalid data; distance out of range.")
irq_pin = 17
cs_pin = 24
GPIO.setup(irq_pin, GPIO.IN)
GPIO.add_event_detect(irq_pin, GPIO.RISING, callback=handle_interrupt)
def read_settings():
global min_strikes, noise_floor
min_strikes = sensor.get_min_strikes()
noise_floor = sensor.get_noise_floor()
def print_settings():
print("Minimum allowed strikes is " + str(min_strikes))
print("Current noise floor is " + str(noise_floor))
running = True
try:
print("AS3935 Lightning Detection Monitor Script - v0.1")
print(" Monitor Status: ONLINE")
print("")
## log raw data to file
f=open('AS3935-data.txt','a')
read_settings()
while running:
time.sleep(1.0)
except KeyboardInterrupt:
print(" Monitor Status: OFFLINE")
print_settings()
print("")
finally:
GPIO.cleanup() # clean up GPIO on CTRL+C exit
f.close()
Automator
Hardware: ARM, Intel, AMD based Linux boxes
OS: now all Linux (and a bit of Wintel)
Automation: X10, Inteon, UPB, Zigbee and ZWave - HAI Leviton OmniPro 2 panel (security and automation)
Hardware: ARM, Intel, AMD based Linux boxes
OS: now all Linux (and a bit of Wintel)
Automation: X10, Inteon, UPB, Zigbee and ZWave - HAI Leviton OmniPro 2 panel (security and automation)
- PeteC
- Posts: 4
- Joined: Friday 07 July 2017 13:39
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.5877
- Location: Time
- Contact:
Re: 1-Wire Lightning
Thank you freijn.Have you tried the custom sensor ?
Yes been trying with just the counter variable.
It would ideally be a lua script.
The script would use the two variables.
Variable 1 lightning counter would be set to zero every night at midnight for a total count per day.
Variable 2 would subract from previous read and divide by the time between reads for a lightning counter per minute.
I was able to do this with xAP / xPL in Windows many many years ago.
Automator
Hardware: ARM, Intel, AMD based Linux boxes
OS: now all Linux (and a bit of Wintel)
Automation: X10, Inteon, UPB, Zigbee and ZWave - HAI Leviton OmniPro 2 panel (security and automation)
Hardware: ARM, Intel, AMD based Linux boxes
OS: now all Linux (and a bit of Wintel)
Automation: X10, Inteon, UPB, Zigbee and ZWave - HAI Leviton OmniPro 2 panel (security and automation)
Who is online
Users browsing this forum: No registered users and 0 guests