I hate to be the bearer of bad news but I think I found a new bug. I noticed I get duplicate notifications for my lightning detector. I get two notifications with the exact same time stamp in the message so I don’t think it’s two separate lightning bolts. Plus the duplicate message is always 17 min after the original.
Did you get Python successfully updated? Your admin page should show a Library version of 0.1.2
You might need to confirm you don’t have multiple copies of your Python client running… I think that is possible.
@Gunner My admin page says 0.1.2. I also checked my running python processes and only one client is running. Im going to do some more testing to see if I can better understand the duplicate notification behavior. I just wanted to put it on everyone’s radar.
So after “studying” the duplicate app notification behavior, I can reliably reproduce the behavior. In fact with the recent server/app update, I constantly get the same notification over and over. It’s gotten so bad that I had to remove the notification feature from my client. The only way to stop the constant notifications is to restart my client and server. Should I start a new topic or continue in this one? Ill explain my finding more once we determine whether to start a new topic or not.
Sounds like new issue, so I moved this all into a new topic. Explain away
Alright so I’ve noticed over the past few weeks that I keep getting duplicate notifications when my weather station detects a lightning strike. The notification has the same time stamp and my lightning counter is uneffected. For example my lighting counter might say one bolt but I’ll get multiple notifications. Recently it’s gotten worse and I constantly get the same notification. It’s gotten so bad I had to remove the notification feature from my weather station. I’ve noticed it only duplicates the last notification. The only way to stop the notifications is to restart my server and client, but once I get a lightning bolt detection, it whole issue comes back. Here are some pics to show what’s happening.
Notice how I keep getting the same notification even 3 hrs after the original notification was created.
Can you show us your code?
Here is my code for my client.
import BlynkLib_Outdoor
# import time
import Adafruit_TCS34725
from Adafruit_BME280 import *
from RPi_AS3935 import RPi_AS3935
import SI1145.SI1145 as SI1145
import RPi.GPIO as GPIO
from datetime import datetime
BLYNK_AUTH = 'Auth code goes here normally'
# Initialize Blynk
blynk = BlynkLib_Outdoor.Blynk(BLYNK_AUTH)
blynk.sync_all()
# Initialize AS3935 sensor
as3935 = RPi_AS3935(address=0x03, bus=1)
as3935.set_indoors(False)
as3935.set_min_strikes(1)
as3935.set_noise_floor(0)
time.sleep(0.005)
# tun_cap value must be in hexadecimal format
as3935.calibrate(tun_cap=0x02)
time.sleep(0.005)
as3935LastStatus = ""
GPIO.setmode(GPIO.BCM)
count = 0
count_switch = True
message_switch = True
def reset_values():
global count
blynk.virtual_write(7, count)
blynk.virtual_write(6, 'Waiting for Lightning')
def process_as3935_interrupt(channel):
global as3935, as3935LastStatus, count
time.sleep(0.003)
reason = as3935.get_interrupt()
if reason == 0x01:
now = datetime.now().strftime('%H:%M:%S - %m/%d')
as3935LastStatus = "Noise Floor too low - adjusting (%s)" % now
as3935.raise_noise_floor()
elif reason == 0x04:
now = datetime.now().strftime('%H:%M:%S - %m/%d')
as3935LastStatus = 'Disturber detected - masking (%s)' % now
as3935.set_mask_disturber(True)
elif reason == 0x08:
now = datetime.now()
distance = as3935.get_distance()
as3935LastStatus = 'Lightning Detected {}km away {:%H:%M:%S - %m/%d}.'.format(distance, now)
count = count + 1
blynk.virtual_write(6, as3935LastStatus)
blynk.notify(as3935LastStatus)
blynk.virtual_write(7, count)
as3935pin = 17
GPIO.setup(as3935pin, GPIO.IN)
GPIO.add_event_detect(as3935pin, GPIO.RISING, callback=process_as3935_interrupt)
bme280 = BME280(t_mode=BME280_OSAMPLE_8, p_mode=BME280_OSAMPLE_8, h_mode=BME280_OSAMPLE_8)
@blynk.VIRTUAL_READ(1)
def v1_read_handler():
global bme280
degrees = bme280.read_temperature_f()
blynk.virtual_write(1, '{0:0.1f}'.format(degrees))
@blynk.VIRTUAL_READ(2)
def v2_read_handler():
global bme280
# atm = bme280.read_pressure_atm()
pascals = bme280.read_pressure()
hectopascals = pascals / 100
blynk.virtual_write(2, '{0:0.0f}'.format(hectopascals))
@blynk.VIRTUAL_READ(3)
def v3_read_handler():
global bme280
humidity = bme280.read_humidity()
blynk.virtual_write(3, '{0:0.1f}'.format(humidity))
@blynk.VIRTUAL_READ(4)
def v4_read_handler():
tcs = Adafruit_TCS34725.TCS34725(integration_time=Adafruit_TCS34725.TCS34725_INTEGRATIONTIME_154MS,
gain=Adafruit_TCS34725.TCS34725_GAIN_4X)
tcs.set_interrupt(False)
r, g, b, c = tcs.get_raw_data()
lux = Adafruit_TCS34725.calculate_lux(r, g, b)
blynk.virtual_write(4, lux)
@blynk.VIRTUAL_READ(5)
def v5_read_handler():
si1145 = SI1145.SI1145()
vis = si1145.readVisible()
IR = si1145.readIR()
uv = si1145.readUV()
uvindex = uv / 100.0
blynk.virtual_write(5, uvindex)
@blynk.VIRTUAL_READ(6)
def v6_read_handler():
global message_switch
if message_switch == True:
blynk.virtual_write(6, 'Waiting for Lightning')
message_switch = False
elif message_switch == False:
pass
@blynk.VIRTUAL_READ(7)
def v7_read_handler():
global count_switch
if count_switch == True:
blynk.virtual_write(7, '0')
count_switch = False
elif count_switch == False:
pass
@blynk.VIRTUAL_READ(8)
def v8_read_handler():
noise = as3935.get_noise_floor()
blynk.virtual_write(8, noise)
@blynk.VIRTUAL_WRITE(9)
def v9_write_handler(value):
as3935.set_noise_floor(int(value))
@blynk.VIRTUAL_WRITE(10)
def v10_write_handler(value):
if int(value) == 0:
as3935.set_indoors(True)
elif int(value) == 1:
as3935.set_indoors(False)
@blynk.VIRTUAL_READ(11)
def v11_read_handler():
gain = as3935.get_indoors()
if gain == True:
blynk.virtual_write(11, 'Indoor')
elif gain == False:
blynk.virtual_write(11, 'Outdoor')
@blynk.VIRTUAL_READ(12)
def v12_read_handler():
global bme280
dewpoint = bme280.read_dewpoint_f()
blynk.virtual_write(12, '{0:0.0f}'.format(dewpoint))
@blynk.VIRTUAL_WRITE(13)
def v13_write_handler(value):
global count_switch, message_switch, count
if int(value) == 0:
pass
elif int(value) == 1:
count = 0
count_switch = True
message_switch = True
# Start Blynk (this call should never return)
blynk.run()
*Ignore the weird indent at lines 55 and 96.
In your process_as3935_interrupt
add next statement to catch unrecognised reason
else:
as3935LastStatus = 'error'
So you’ll have:
def process_as3935_interrupt(channel):
global as3935, as3935LastStatus, count
time.sleep(0.003)
reason = as3935.get_interrupt()
if reason == 0x01:
now = datetime.now().strftime('%H:%M:%S - %m/%d')
as3935LastStatus = "Noise Floor too low - adjusting (%s)" % now
as3935.raise_noise_floor()
elif reason == 0x04:
now = datetime.now().strftime('%H:%M:%S - %m/%d')
as3935LastStatus = 'Disturber detected - masking (%s)' % now
as3935.set_mask_disturber(True)
elif reason == 0x08:
now = datetime.now()
distance = as3935.get_distance()
as3935LastStatus = 'Lightning Detected {}km away {:%H:%M:%S - %m/%d}.'.format(distance, now)
count = count + 1
else:
as3935LastStatus = 'error'
...