Hostname error while connecting to Blynk servers on RPI

I’m trying to run my rpi with a Blynk 2.0 project. I use an ethernet connection. My code is in python. I just want to test the basic write code.
Problem, when I execute my code it gets stuck. So I try ctrl+c to stop it. And when I stop the program, an unhandled error is displayed, in addition to the KeboardInterrupt logic.

import blynklib

BLYNK_AUTH = 'auth'

blynk = blynklib.Blynk(BLYNK_AUTH)
print("##################################")
print("# - Connected to Blynk Servers - #")
print("##################################")


WRITE_EVENT_PRINT_MSG = "[WRITE_VIRTUAL_PIN_EVENT] Pin: V{} Value: '{}'"
@blynk.handle_event('write V0')
def write_virtual_pin_handler(pin, value):
    print(WRITE_EVENT_PRINT_MSG.format(pin, value))

###########################################################
# infinite loop that waits for event
###########################################################
while True:
    blynk.run()

I don’t really know what to do.
Thanks for your help.

Library version?

Pete.

I installed the library with pip 20.3.4 two hours ago, the version is 0.2.6 with python 3.9.

You need to be using version 1.0.0 from here…

It’s not bundled as a release, so you need to manually copy the files.

Pete.

Okay thanks I’ll try this soon.
I also had a problem of stability of connection with a NodeMCU and I see in the recent commit ‘fixed socket disconnecting every 2 min’ of the python library (even if the esp of the nodemcu is programmed in cpp), is the Blynk v1.2.0 library on the Arduino IDE up to date concerning this problem?

I don’t see how you can correlate a bugfix in one library to an issue experienced when using a different library.

Most C++ connectivity issues are caused by either poor coding or unreliable internet issues.

Pete.

All right, this is just a guess.
Concerning python, I encountered several other problems, which I was able to solve:

  1. How to install the blynk-library-python library
    Installing the library for the user didn’t work for me (parameter --user), so I removed it. You also have to be careful to use pip3 and not pip as indicated on the github.
    To install the library I did:
    sudo git clone https://github.com/vshymanskyy/blynk-library-python.git . in the current folder.
    Then sudo pip3 install -e .

  2. I also had a problem with the @blynk.VIRTUAL_WRITE event. This event was proposed in the example on the github. You have to use :
    @blynk.on("V<pin>") instead of @blynk.VIRTUAL_WRITE(<pin>)

here is my last code to test the vpin 0 :

import BlynkLib
# Initialize Blynk
blynk = BlynkLib.Blynk('auth')

# Register Virtual Pins
@blynk.on("V0")
def my_write_handler(value):
    print('Current V0 value: {}'.format(value[0]))

while True:
    blynk.run()

Thanks again for your help Pete.
The topic is closed.

1 Like