https://github.com/vshymanskyy/blynk-library-lua
Blynk library for Lua. Works with Lua 5.1+, LuaJIT, NodeMCU.
https://github.com/vshymanskyy/blynk-library-lua
blynk esp32 esp8266 iot lua lua-library luajit openwrt
Last synced: 2 months ago
JSON representation
Blynk library for Lua. Works with Lua 5.1+, LuaJIT, NodeMCU.
- Host: GitHub
- URL: https://github.com/vshymanskyy/blynk-library-lua
- Owner: vshymanskyy
- License: mit
- Created: 2018-09-20T11:44:45.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-02-22T14:32:52.000Z (over 2 years ago)
- Last Synced: 2025-04-10T17:20:37.261Z (2 months ago)
- Topics: blynk, esp32, esp8266, iot, lua, lua-library, luajit, openwrt
- Language: Lua
- Homepage: https://blynk.io/
- Size: 46.9 KB
- Stars: 41
- Watchers: 5
- Forks: 15
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Lua client for Blynk IoT
**Note:** The library has been updated for Blynk 2.0
[](https://github.com/vshymanskyy/blynk-library-lua/releases/latest)
[](https://github.com/vshymanskyy/blynk-library-lua/releases/latest)
[](https://github.com/vshymanskyy/blynk-library-lua/stargazers)
[](https://github.com/vshymanskyy/blynk-library-lua/issues)
[](https://github.com/vshymanskyy/blynk-library-lua/blob/master/LICENSE)If you like **Blynk** - give it a star, or fork it and contribute!
[](https://github.com/blynkkk/blynk-library/stargazers)
[](https://github.com/blynkkk/blynk-library/network)
__________## 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.
## Download
**Blynk Mobile App:
[Google Play](https://play.google.com/store/apps/details?id=cloud.blynk) |
[App Store](https://apps.apple.com/us/app/blynk-iot/id1559317868)**
## Documentation
Social: [Webpage](http://www.blynk.cc) / [Facebook](http://www.fb.com/blynkapp) / [Twitter](http://twitter.com/blynk_app) / [Kickstarter](https://www.kickstarter.com/projects/167134865/blynk-build-an-app-for-your-arduino-project-in-5-m/description)
Documentation: https://docs.blynk.io
Community Forum: http://community.blynk.cc
Blynk for Business: http://www.blynk.io## Usage example
```lua
local Blynk = require("blynk.socket")local blynk = Blynk.new("your_auth_token")
-- callback to run when V1 changes
blynk:on("V1", function(param)
print("V1:", tonumber(param[1]), tonumber(param[2]))
end)-- callback to run when cloud requests V2 value
blynk:on("readV2", function(param)
blynk:virtualWrite(2, os.time())
end)local sock = getSocketConnection() -- omitted
blynk:connect(sock)while true do
blynk:run()
end
```You can run the [full example](examples/client.lua):
```sh
lua ./examples/client.lua
```## Features
- **Lua 5.1, Lua 5.2, Lua 5.3, LuaJIT** support
- **Linux,
Windows,
MacOS** support
- `virtualWrite`
- `syncVirtual`
- `setProperty`
- `logEvent`
- events: `Vn`, `readVn`, `connected`, `disconnected`, `redirect`
- `TCP` and secure `TLS/SSL` connection support
- can run on embedded hardware, like `NodeMCU` or `OpenWrt`## OpenWrt installation
```sh
opkg update
opkg install lua luasocket luasec
# openssl is needed for wget to handle https://
opkg install wget openssl-util libustream-wolfssl# Get blynk-library-lua from github
cd /root
wget --no-check-certificate -qO- https://github.com/vshymanskyy/blynk-library-lua/archive/v0.2.0.tar.gz | tar xvz
cd blynk-library-lua-0.2.0# Run it
lua ./examples/client.lua
```## NodeMCU installation
It is very easy to get it running on NodeMCU (or any other `ESP8266`/`ESP32`-based device):
- Get the latest [nodemcu-firmware](https://github.com/nodemcu/nodemcu-firmware) running on your device.
You can use their [online build service](https://nodemcu-build.com/).
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:
```sh
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:
```lua
blynk:virtualWrite(1, tmr.time())
```## Ubuntu/Linux/Raspberry Pi installation
```sh
sudo apt-get install lua5.3 lua-sec lua-socket
```## Bonus
The `Timer` is included for demonstration purposes.
Here are also some handy functions:```lua
local function millis()
return math.floor(socket.gettime()*1000)
endlocal function delay(msec)
return socket.sleep(msec/1000)
end
```
__________### Implementations for other platforms
* [Arduino](https://github.com/blynkkk/blynk-library)
* [Particle](https://github.com/vshymanskyy/blynk-library-spark)
* [Node.js, Espruino, Browsers](https://github.com/vshymanskyy/blynk-library-js)
* [Python, MicroPython](https://github.com/vshymanskyy/blynk-library-python)
* [OpenWrt packages](https://github.com/vshymanskyy/blynk-library-openwrt)
* [MBED](https://developer.mbed.org/users/vshymanskyy/code/Blynk/)
* [Node-RED for Blynk IoT](https://flows.nodered.org/node/node-red-contrib-blynk-iot)
* [LabVIEW](https://github.com/juncaofish/NI-LabVIEWInterfaceforBlynk)
* [C#](https://github.com/sverrefroy/BlynkLibrary)### License
This project is released under The MIT License (MIT)