BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

New! Alpha version of the blynk-library for Python!

#1

Hi all.

Here’s an alpha version of what is Blynk library for Python (this one uses a bi-directional TCP connection, not HTTP API).

Please note that it’s not production ready and I hope for active contributions from our community - unfortunately I don’t have too much time to develop it.
EXPERT USE ONLY! :wink:
Anyway, this is inline with Blynk ideas (as you would expect): simple to use, extensible API, good hardware support (no dependencies), etc.

What do you think?

5 Likes

(Blynk Python) Intermittent connection
Raspberry Pi, Light Sensor Readings
Intermittent failing when calling blynk to write to V5 (Using Python)
Python GET request( http API) to local server
Raspberry Pi, Blynk and Programming in C Language
NEED ADVICE before making a purchase!
Automated sliding lock with fire safety feature using raspberry pi & python
Automated sliding lock with fire safety feature using raspberry pi & python
After import BlynkLib, import RPi.GPIO as GPIO not working?
Camera pi connect to Raspberry with Blynk
Blynk.virtual_write python time input widget
Motor Control with Raspberry on Blynk App
Raspberry pi and pca9685 servo controller blynk
Newbie question - blynk.virtual_write - Python syntax
Python Raspberry Pi and I2C Sensors
OTA updates with newest libraries and Arduino IDE?
Can you use Blynk and MicroPython together?
pinned #2
0 Likes

#3

i like the idea, and would choose any day the python language over the arduino “language”.

but the reality is, that compared to arduino, very few people are using python for embedded stuff, so the chance to find libs / info / support for random sensors / modules is low. the same goes for mcu compatibility. thus, the usability is reduced.

2 Likes

#4

@Gunner
I seem to have a new problem…
I can’t import BlynkLib.
It says, "ImportError : No module named ‘BlynkLib’
Im not sure if anything’s missing or something, but I followed all the steps from here, https://github.com/vshymanskyy/blynk-library-python

0 Likes

#5

@Muhammad_Fitri Sorry, I know nothing about Python. I have moved your question here instead.

Be aware, this is an Alpha test and for…

0 Likes

#6

:tired_face::tired_face::tired_face:

0 Likes

#7

thanx @Gunner

0 Likes

#8

@vshymanskyy, from the code you gave at github, how do i set the virtual pin i need to use??

import BlynkLib
import time

BLYNK_AUTH = 'YourAuthToken'

# Initialize Blynk
blynk = BlynkLib.Blynk(BLYNK_AUTH)

# Register Virtual Pins
@blynk.VIRTUAL_WRITE(1)
def my_write_handler(value):
    print('Current V1 value: {}'.format(value))

@blynk.VIRTUAL_READ(2)
def my_read_handler():
    # this widget will show some time in seconds..
    blynk.virtual_write(2, time.ticks_ms() // 1000)

# Start Blynk (this call should never return)
blynk.run()
0 Likes

#9

@Muhammad_Fitri please pay attention to code formatting when using our forum.
And read this carefully!


I think the code is self-explanatory - what exactly question do you have?

0 Likes

#10

Hi,

it all works fine for Virtual Pin 1 but if I add more pins then I get the following message

Warning: Virtual write to unregistered pin 2

How can I deal with this?

best
mDSP

0 Likes

#11

This is probably becasue you didn’t register pin 2 :stuck_out_tongue_winking_eye:

Start by showing your entire modified & formatted code, otherwise we are guessing at what you did or didn’t do :wink:

0 Likes

#12

Thank you for your reply!

Well. I thought it should work like this (but obviously it doesn’t)

import BlynkLib
import random
import OSC
import time

client = OSC.OSCClient()
client.connect( ( '127.0.0.1', 57120 ) )
msg = OSC.OSCMessage()
msg.setAddress("/print")


BLYNK_AUTH = 'aca20018b97740a59389ca8b47c7baae'

# Initialize Blynk
blynk = BlynkLib.Blynk(BLYNK_AUTH)

# Register Virtual Pins
@blynk.VIRTUAL_WRITE(1)
def my_write_handler(value):
	print('Current V1 value: {}'.format(value))

@blynk.VIRTUAL_WRITE(2)
def my_write_handler(value):
    print('Current V2 value: {}'.format(value))


@blynk.VIRTUAL_READ(2)
def my_read_handler():
    # this widget will show some time in seconds..
    blynk.virtual_write(2, time.ticks_ms() // 1000)

# Start Blynk (this call should never return)
blynk.run()
0 Likes

#13

I have absolutely no idea how Python works… but as a guess with what looks like the actual defining command… you might try something like (value2) as (value) is already taken for the first pin?

0 Likes

#14

Unfortunately it does not work. I did tried it also before. I am wondering where can I register the pins? Even if I use just pin2 in first place without anything else I get the same error. It seems I can get values only from pin1.

any ideas?

0 Likes

#15

its absolutely mad but is seems it works for pin3! I will check others and report.

0 Likes

#16

Yes, it seems it is just pin2 not working! I randomly tried 2-3 others and it works!

0 Likes

#17

Looking at other examples in the Blynk Python Library (above), it seems that defining a virtual pin is determined by the initial wording, not the word (value)…

def my_write_handler(value):
def v3_write_handler(value):
def v4_write_handler(value):

etc.

0 Likes

#18

Also… you are already using V2 (or just pin 2) in this command… for the uptime display.

0 Likes

#19

Ah I am so silly, I did not pay any attention that I am using already VP2. I just cope/pasted the code and forgot the last lines.

Thank you for pointing it out anyway!

1 Like

#20

Hi again,

I have just noticed that when I use the library the CPU goes 100% on RPi3

Strange isn’t it?

0 Likes

Push widgets update with different frequency using Python set_user_task() or NodeJS