(Python & NodeJS) Issue with sending Widget data to hardware after App/Server update

Can you confirm and report here actual version of everything used? Local Server & App, etc.

Show us the code you are using… format it for proper forum viewing after pasting it

Blynk - FTFC

Thanks for helping Gunner! Here is the info you requested:
Blynk python Library version: most recent (no releases on Github)
Blynk Local server: 0.36.4
iOS app: 2.19.0
Code I use to control hardware

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
from MuxLib import *

BLYNK_AUTH = 'Auth code normally goes here'
# Initialize Blynk
blynk = BlynkLib_Outdoor.Blynk(BLYNK_AUTH)
blynk.sync_all()

# Initialize multiplexer
mux = I2C_TCA(0X70, 1)
mux.tca_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)

try:
    bme280 = BME280(t_mode=BME280_OSAMPLE_8, p_mode=BME280_OSAMPLE_8, h_mode=BME280_OSAMPLE_8)
except IOError:
    print('BME280 error')
    bme280.reset_sensor()
    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()

So my project is using a Raspberry Pi to make a weather station that records and reports temp, humidity, dew point, pressure, outdoor brightness, UV index, and lightning strikes. Like I said before, all the values get updated on my app at the correct interval. Issues occur when I try to change some of the settings for the lighting detector from the app.

Edit: Ignore that weird indent on line 61 (%m/%d). It is formatted properly in my actual code.

Here are images of my app setup as well.

Oh, wow… OK, your Python coding goes well beyond what I have been testing so far (blinking and fadeing virtual LEDs and displaying counters) :blush: I may not be of much assistance until I can catch up.

Are you running both Server and Client on the same RPi?

Are you seeing any errors in the client side monitor?

Ya idk if I am being too ambitious with the python library.

The server and client are on different RPi’s. No errors on the client monitor.

OK, I can confirm this as well. My timers keep counting and virtual LED keeps blinking but neither button or slider show any response in the running script.

But I do not see any errors like this either… However, I have noticed some lag between a device going offline and coming back online and the Apps messaging about such.

Only my client is running on the RPi3, my server runs on a Linux netbook and is working just fine on all other libraries and devices.

@vshymanskyy As this Python Library is your baby, do you have any insight as to how the recent App (and/or possibly server) updates could affect this?

Good to hear you can replicate this odd behavior. Thank you Gunner for helping me out!

Hmm… @vshymanskyy I am also seeing the same type of issue with my NodeJS client… everything connected and running, displays update if the device is automatically sending data, but the client is not responding to any App Widget input.

@dhclark18 Sorry, Not meaning to undermine or hijack your topic, but I added NodeJS to the title instead of creating a whole new topic… as I suspect the common factor is either the App or Server update, not the client libraries as much (although C++ v0.5.2 seems to work just fine).

No worries. I’m glad we are discovering these bugs.

1 Like

@dhclark18 could you please check with https://github.com/blynkkk/blynk-server/releases/download/v0.36.4/server-0.36.5-SNAPSHOT.jar version? This should fix the issue.

Or for java 8 - remove current server jar file and download new one (with fix).

1 Like

I downloaded and ran the latest server-0.36.4-java8.jar a couple of hours ago… it said SNAPSHOT… but didn’t make any difference :frowning:

Is there a newer one? How do I tell… it shows released 2 days ago.

Yes. I just updated it.

1 Like

Thanks… I was just booting it up after redownloading & reinstalling it “just in case”… and it verks!! :smiley:

Everything works now. Thank you all!!!

Blynk JS and Python libraries were also updated.
please use the latest version

1 Like

Any tips to determine the actual running versions? I have updated both Py & JS, but the Server admin is mostly useless for telling me exactly what is happening, and I can’t tell on the client side as BLYNK_VERSION is not build into the libraries.

4 posts were split to a new topic: I get duplicate notifications for my lightning detector

EDIT - I cut this snipped out of a split topic as it is in final reference to my posts here.


Well, I had to brute force search and removal of all installed versions and reinstall from scratch… I think I am now running only the latest of both Node.JS & Python.

At least I am fairly sure on the Node.js version as it errored out due to missing my previous Map add in, based on this topic: Using the map with js library - #4 by RemcoJ

@vhymanskyy I guess this Map Widget addition never got officially added in?