Skip to content

NodeJS and Python libraries for using Blynk APP on Raspberry Pi

License

Notifications You must be signed in to change notification settings

BLavery/PiBlynk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PiBlynk

Javascript and Python libraries for using Blynk APP on Raspberry Pi.
Two working libraries designed to easily connect with the Blynk smartphone APP.

May 2018 - This is no longer being maintained by the original author.

Please feel free to fork, copy, adapt if you find it useable

The libraries are designed specifically for Raspberry Pi. The overall design target is for:

  1. stability in connection to server
  2. full suite of interfacing functions
  3. similarity of functions/functionality in the two versions, as far as the languages allow
  4. easy compatibility with Raspberry Pi GPIO and PiCamera

Both are forked code, “standing on the shoulders of others.”

Features (both versions) include:

  • Automatic connecting to Blynk server, and maintaining that connection.
  • Full suite of functions for interfacing to GPIO and virtual pins of the Blynk protocol.
  • Widget object for LCD
  • Widget for GPS (with distance and direction),
  • Widget for accelerometer (with pitch and roll)
  • Generic buffering widget for any sensor pushing data from APP (eg lightmeter)
  • Send email, tweet, smartphone notification.
  • Change phone widget properties (colour, label)
  • Widget for a “bridge”, ie gpio or virtual commands to another hardware device.
  • Compatible with PiCamera
  • Extensive example files.

Features specific to javascript version:

  • Uses OnOff gpio module to allow simplistic GPIO in and out without specific coding.
  • Compatible also with rpio and pigpio modules as more competent GPIO libraries.
  • Connects to Blynk server in plain TCP or in SSL.

The javascript version requires nodejs greater than either 0.10.x as distributed on Raspbian, nor the 0.12.x as found on https://node-arm.herokuapp.com/. I upgraded my nodejs using the recommended update-nodejs-and-nodered as per https://nodered.org/docs/hardware/raspberrypi to 6.x. Unfortunately I find that all the later versions of nodejs (past 0.12.x) seem to run only on my Raspberry Pi 3 (armv7), but not on my new Pi zero-W (armv6). On the RPi3, the javascript Blynk code works great. The javascript version is inherently single-threaded.

API? See here

Features specific to python version:

  • By default, “hardware agnostic”. Operates on any linux, and probably on Windows (unchecked)
  • Operates comfortably with gpiozero module, but gpiozero not loaded by default.
  • Python (2) or python 3.
  • TCP connection, but no SSL.
  • User Tasks, ie interval timer, threaded/concurrent
  • One-shot Timer functions, threaded/concurrent
  • Reentrancy protection for threaded “write” calls.
  • Simple “Ticker” periodic function (not threaded)

The python version runs fine on any version of RPi. It uses threading/timers for user code. It should easily adapt to any linux machine, and probably to a windows python too.

API? See here

Installation:

These libraries were prepared for a classroom, and I train my students using basic low-brow skills involving geany IDE and command terminal. I am leaving the library files in the same format/structure here.

I am suggesting simple manual download as a zip file, and "extract-here". The two separate project workspaces are in folders piblynk-js and PiBlynk-py, and you can move them to wherever you normally put your user projects.

In both libraries you will need to edit your blynk AUTH TOKEN for your RPi device into file mytoken.py or mytoken.js.

Installing NodeJS version:

The folder node_modules/piblynk holds the library code. You will additionally need to use npm to install locally several support modules. Adjust this command to wherever is your workspace:

xxx@xxx ~/Documents/NodejsScripts $ npm install onoff
And note the example files will also need:
npm install rpio my-local-ip campi oled-font-5x7 pigpio

And by all means, it that's in your usual practice, install these modules instead to nodejs' global area.

Load any example file into geany. Click Build/Set Build Commands and check that the execute command is set to nodejs %f

In geany, clicking the Run or View Current File icon should execute it, and connect to the blynk server.

Installing Python version:

The folder PiBlynk holds the library code. You should have (or create) an images folder parallel to PiBlynk if you are going to use the camera example.

Load any example file into geany. Click Build/Set Build Commands and check that the execute command is set to python %f or preferably python3 %f

Click the Run or View Current File icon to execute your example, and to connect to the blynk server.

Both versions also include incidentally a library for oled display 128x64 ssd1306. These are not an intrinsic part of the PiBlynk libraries, but they were used just to add the oled item in the hardware suite used for the example files.

Examples, and Test Hardware used:

See separate file

Attributions:

The PiBlynk-py library was inspired by, and leveraged from, the work of the WIPY project. https://github.com/wipy/wipy/blob/master/lib/blynk/BlynkLib.py
and thence from
https://github.com/youngsoul/BlynkLib

The piblynk-js library was derived from:
https://github.com/vshymanskyy/blynk-library-js
MIT licence

About

NodeJS and Python libraries for using Blynk APP on Raspberry Pi

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published