Blynk Python/Micropython Library
Blynk provides iOS and Android apps to control any hardware over the Internet or directly using Bluetooth. You can easily build graphic interfaces for all your projects by simply dragging and dropping widgets, right on your smartphone. Blynk is the most popular IoT platform used by design studios, makers, educators, and equipment vendors all over the world.
Blynk App: Google Play | App Store
Optionally: Blynk Server. Public Blynk Cloud is free for anyone who is using Blynk for personal (non-commercial) purposes.
sudo pip install blynklib
git clone https://github.com/blynkkk/lib-python.git
cd lib-python
pip install --user -e .
# sudo pip install -e . # if installation needed not for current but for all users
You can run unit tests using the command:
python setup.py test
Library allows to communicate with public or custom Blynk Server.
Supports Python2/Python3/Micropython.
HW support of RaspberryPi/ESP32
- connect/disconnect events subscribe
- read/write virtual pins events subscribe
- virtual pin write
- virtual pin sync
- internal app notifications
- email notifications
- set widget property
Install Blynk python library Download Blynk App (GooglePlay | Apple) and register within it. During registration personal auth token will be provided. Use this token within your python scripts to pass public or custom Blynk server authentification.
import blynklib
BLYNK_AUTH = '<YourAuthToken>'
blynk = blynklib.Blynk(BLYNK_AUTH)
# register handler for virtual pin V11 reading
# for example when some Blynk App widget asks virtual pin data from server periodically
@blynk.handle_event('read V11')
def read_virtual_pin_handler(pin):
# user code for this event goes here
# ...
# Example: calculate, get sensor values, current time etc
# update current virtual pin value on server
blynk.virtual_write(pin, <USER_CALCULATED_VALUE>)
# or any other pin if needed
# blynk.virtual_write(24, '<ANY_OTHER_USER_CALCULATED_VALUE>')
# actions if calculated value become CRITICAL
if <USER_CALCULATED_VALUE> >= <USER_DEFINED_CRITICAL_VALUE>
# set red color for widget that performs periodical virtual pin read operations
blynk.set_property(pin, 'color', '#FF0000')
# send internal notification to Blynk App and notification to defined e-mail
blynk.notify('Warning critical value')
blynk.email(<Your e-mail>, 'Device alarm', 'Critical value!')
# main loop that starts program and handles registered events
while True:
blynk.run()
Examine more examples to be familiar with basic features usage.
This project is released under The MIT License (MIT)