Skip to content
Blynk library for Lua. Works with Lua 5.1+, LuaJIT, NodeMCU.
Branch: master
Clone or download
Latest commit 8e494c8 Feb 18, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
blynk Use net.socket "sent" event Sep 22, 2018
examples Switch to port 443 and command 29 Feb 13, 2019
.gitignore Initial commit Sep 20, 2018
LICENSE Initial commit Sep 20, 2018 Add tweet() function Feb 18, 2019
blynk.lua Add tweet() function Feb 18, 2019
timer.lua Initial commit Sep 20, 2018

Lua client for Blynk

GitHub version GitHub download GitHub stars GitHub issues License

If you like Blynk - give it a star, or fork it and contribute! GitHub stars GitHub forks

What is Blynk?

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 Banner


Blynk App: Google Play | App Store

Blynk Server


Social: Webpage / Facebook / Twitter / Kickstarter
Help Center:
Community Forum:
Examples Browser:
Blynk for Business:

Usage example

local Blynk = require("blynk.socket")

local blynk ="your_auth_token")

-- callback to run when V1 changes
blynk:on("V1", function(param)
  print("V1:", tonumber(param[1]), tonumber(param[2]))

-- callback to run when cloud requests V2 value
blynk:on("readV2", function(param)
  blynk:virtualWrite(2, os.time())

local sock = getSocketConnection() -- omitted

while true do

You can run the full example:

lua ./examples/client.lua <your_auth_token>


  • Lua 5.1, Lua 5.2, Lua 5.3, LuaJIT support
  • Linux, Windows, MacOS support
  • virtualWrite
  • syncVirtual
  • setProperty
  • notify, tweet
  • logEvent
  • events: Vn, readVn, connected, disconnected
  • TCP and secure TLS/SSL connection support
  • can run on embedded hardware, like NodeMCU or OpenWrt

OpenWrt installation

opkg update
opkg install lua luasocket luasec
# openssl is needed for wget to handle https://
opkg install wget openssl-util libustream-openssl

# Get blynk-library-lua from github
cd /root
wget --no-check-certificate -qO- | tar xvz
cd blynk-library-lua-0.1.4

# Run it
lua ./examples/client.lua <your_auth_token>

NodeMCU installation

It is very easy to get it running on NodeMCU (or any other ESP8266/ESP32-based device):

  • Get the latest nodemcu-firmware running on your device.
    You can use their online build service.
    It is recommended to include encoder, TLS/SSL modules.
  • Edit nodemcu.lua example (put your auth token and wifi credentials)
  • Use nodemcu-tool or any other method to transfer lua files to the device.
    Note: the NodeMCU filesystem is "flat" (folders not supported), but it handles the / symbol nicely.
    Be sure to preserve the relative path when copying files:
    nodemcu-tool upload -mck ./blynk.lua ./blynk/pipe.lua ./blynk/nodemcu.lua
    nodemcu-tool upload ./examples/nodemcu.lua -n init.lua
  • Open device terminal and run dofile("init.lua")
  • blynk object is global, so you can call it from the interactive console:
    blynk:virtualWrite(1, tmr.time())

Ubuntu/Linux/Raspberry Pi installation

sudo apt-get install lua5.3 lua-sec lua-socket


The Timer is included for demonstration purposes.
Here are also some handy functions:

local function millis()
  return math.floor(socket.gettime()*1000)

local function delay(msec)
  return socket.sleep(msec/1000)

Implementations for other platforms


This project is released under The MIT License (MIT)

You can’t perform that action at this time.