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

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

unpinned #29
0 Likes

#30

Good news here.
I found some time to do a major rewrite of the Python library!
It now contains only my code (previously some code was written by another guy), works better with MicroPython (LoBo/ESP32, etc.), and what’s most interesting - does not have the ugly concept of “tasks”.
It now works similar to Arduino - you have to run Blynk in a loop (but you can also use _thread).

I’m now polishing it, preparing some “getting started” docs, etc.

4 Likes

#31

So, how are things going in the micropython world? Tried importing blynklib to my m5stack module, but isn’t working :\

0 Likes

#32

Hi…Does the python library work with local server? i ran the blynk_write.py example and look what i got… my pi is not connected to the internet.
Connecting to blynk-cloud.com:80
Error: connection with the Blynk servers failed, connection closed

0 Likes

#33

I know nothing about Python, but I’d assume that you need to edit your BlynkLib.py

def connect(self):
       try:
           self.conn = socket.socket()
           self.conn.connect(socket.getaddrinfo("blynk-cloud.com", 80)[0][4])
           self.conn.settimeout(0.05)
           BlynkProtocol.connect(self)
       except:
           raise ValueError('connection with the Blynk servers failed')

Pete.

2 Likes

#34

Yes… and a little searching later… :wink:

1 Like

#35

Be aware that with the next update, it will be easier to change the server (still in the works)

2 Likes

#36

Next update this week.
:thinking:

0 Likes

#37

probably

1 Like

#38

I have been slack in getting to this, but saw some recent changed on github, so after seeing that running the documented install file still gets 0.1.3. I just manually downloaded what looks like the latest Python 0.2.0 library and have it sitting in my RPi… There is a nice file called setup.py, but I can’t seem to get it to actually live up to its name :stuck_out_tongue:

The first lines in the file show this…

#!/usr/bin/env python

from setuptools import setup

Which doesn’t tell me much either… I looked for that folder, thinking I might find that setuptools program, but the folder doesn’t yet exist.

Googling a bit (yep I do that :wink: ) it seems I must setup setuptools in order to setup Blynk’s Python setup?? Wow… This linux/python stuff is hard :blush:

Any hints here? before I totally pooch my RPi setup :laughing:

0 Likes

#39

In the same folder as setup.py, run:

pip3 install ./

or

pip2 install ./

Depending on the Python version you want to use the library with.
Anyway. The library 0.2.0 is almost ready for release (still working on some examples)

0 Likes

#40

v0.2.0 is released and available via github and pip.

Please check out the new README and examples.

:star2: :star2::star2: And of course, do not forget to give it a github star! :slight_smile:

2 Likes

#41

Well that was a lot smoother :stuck_out_tongue: Thanks.

pi@raspberrypi3:~ $ pip install blynk-library-python
Collecting blynk-library-python
  Downloading https://files.pythonhosted.org/packages/37/01/91c464c3f9a36ad96e397c9652a339fbde71a3de99eabc22e7de6b2f3923/blynk-library-python-0.2.0.tar.gz
Building wheels for collected packages: blynk-library-python
  Running setup.py bdist_wheel for blynk-library-python ... done
  Stored in directory: /home/pi/.cache/pip/wheels/fc/d4/df/7128f5d8bf6e86fba6107a971acb3f695fbde461a74dc75205
Successfully built blynk-library-python
Installing collected packages: blynk-library-python
Successfully installed blynk-library-python-0.2.0

Now back to the Local Server issue… but I think an answer was in some other topic already… so back to reading :slight_smile:

Found a reference here - https://github.com/vshymanskyy/blynk-library-python/issues/18

But I want to be able to pick and chose the server option in my sketch :thinking: Like this:

# Initialize Blynk
blynk = BlynkLib.Blynk(BLYNK_AUTH, '10.10.3.13', 8080)
pi@raspberrypi3:~ $ python PythonTest.py

    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ for Python v0.2.0 (Linux)

Traceback (most recent call last):
  File "PythonTest.py", line 17, in <module>
    blynk = BlynkLib.Blynk(BLYNK_AUTH, '10.10.3.13', 8080)
TypeError: __init__() takes exactly 2 arguments (4 given)
pi@raspberrypi3:~ $ 
0 Likes

#42

OK, I figured that out… mostly… the log=print causes compiling error with Python 2.7, so more investigation required.

blynk = BlynkLib.Blynk(BLYNK_AUTH,
                       server='10.10.3.13',    # set server address
                       port=8080,              # set server port
                       heartbeat=30,           # set heartbeat to 30 secs
                       #log=print              # use print function for debug logging
                       )

In fact, it seems lots of rethinking is required as there is no longer tasks? and needing the while true: for blynk.run() and a few other issues with my existing sketches.

Time to relearn Blynk Python by digging into the new examples :smiley: Gave it a star on github (not sure why I hadn’t before)

0 Likes

Raspberry PI + blynk
#43

You can’t use print directly, since it is an intrinsic and not a function. I had to do this:

def myprint(*argv):
    for arg in argv:
        print (arg),
    print

Then you can say:

blynk = BlynkLib.Blynk(BLYNK_AUTH,
                       server='10.10.3.13',    # set server address
                       port=8080,              # set server port
                       heartbeat=30,           # set heartbeat to 30 secs
                       log=myprint             # use myprint function for debug logging
                       )
0 Likes

#44

That’s the reason for

from __future__ import print_function

in this example: https://github.com/vshymanskyy/blynk-library-python/blob/master/examples/other_functions.py

1 Like

Blynk Python RPI local server
#45

@vshymanskyy
Hi,
why isn’t the BlynkTimer.py file installed with the lib? I had to copy/paste the code to make the timers work.

BTW, keep up with the great job you’re doing.

0 Likes

#46

It’s on the master branch, which is not released yet

0 Likes

#47

Please continue discussion here:

0 Likes

closed #48
0 Likes