Coder Social home page Coder Social logo

blynk-node-red's Introduction

Blynk + Node-RED

  • The most popular mobile app for the IOT. Works with anything: ESP8266, Arduino, Raspberry Pi, SparkFun and others....from Blynk
  • Flow-based programming for the Internet of Things ...from Node-RED

Getting Started

Example 1. LCD, Gauge, Live Chart Display

Blynk App to monitor IoT sensor data

Node-RED to collect and push IoT sensor data

All data are simulated from Node-RED function node. Must acquire AUTH_TOKEN to work.

npm install node-red-contrib-blynk-ws

Node-RED flow

[{"id":"68b37c86.451a84","type":"blynk-ws-out-lcd","z":"158f41f0.3c873e","name":"V2 LCD Greeting","pin":"2","client":"86fe6b36.cbe288","x":680,"y":566,"wires":[]},{"id":"a2f6bcfd.13cab","type":"function","z":"158f41f0.3c873e","name":"Message Position Adjustment","func":"\nvar count=context.get('count') || 0;\nvar rcount=context.get('rcount') || 15;\n\n\nif (count >= 15) count = 0;\nelse count++;\n\nif (rcount <= 0) rcount = 15;\nelse rcount--;\n\n// text for the top row\nmsg.clear = 1;\nmsg.text = \"Okie Dokie\";\nmsg.x = count ;\nmsg.y = 0;\n// text1 for the bottom row\nmsg.text1 = \"Welcome Back!\";\nmsg.x1 = rcount ;\nmsg.y1 = 1;\n\ncontext.set('count', count) ;\ncontext.set('rcount', rcount) ;\n\nreturn msg;","outputs":1,"noerr":0,"x":406,"y":566,"wires":[["68b37c86.451a84"]]},{"id":"bdff2d1a.a7d5a","type":"comment","z":"158f41f0.3c873e","name":"V2: LCD Push Event","info":"","x":674,"y":520,"wires":[]},{"id":"9c47c417.0968d8","type":"function","z":"158f41f0.3c873e","name":"Measure Current Temperature","func":"\nvar value = Math.floor(Math.random()*40+ 60);\nvar new_msg = {payload : value};\n\nreturn new_msg;","outputs":1,"noerr":0,"x":407,"y":669,"wires":[["7e3a5b36.8f8d54"]]},{"id":"7e3a5b36.8f8d54","type":"blynk-ws-out-write","z":"158f41f0.3c873e","name":"V4 Report Current Temperature","pin":"4","pinmode":0,"client":"86fe6b36.cbe288","x":720,"y":671,"wires":[]},{"id":"b1a9fe44.8efbf","type":"inject","z":"158f41f0.3c873e","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":139,"y":640,"wires":[["9c47c417.0968d8","a101f80.db42f08","a2f6bcfd.13cab"]]},{"id":"a101f80.db42f08","type":"function","z":"158f41f0.3c873e","name":"Measure Current Humidity","func":"var value = Math.floor(Math.random()*30+ 40);\nvar new_msg = {payload : value};\n\nreturn new_msg;\n","outputs":1,"noerr":0,"x":393,"y":706,"wires":[["f498aeeb.0d232"]]},{"id":"f498aeeb.0d232","type":"blynk-ws-out-write","z":"158f41f0.3c873e","name":"V3 Report Current Humidity","pin":"3","pinmode":0,"client":"86fe6b36.cbe288","x":710,"y":710,"wires":[]},{"id":"1ae35dd4.a35ba2","type":"comment","z":"158f41f0.3c873e","name":"V3,V4 : Gauge Push Event","info":"","x":698,"y":624,"wires":[]},{"id":"86fe6b36.cbe288","type":"blynk-ws-client","z":"","name":"","path":"ws://blynk-cloud.com/websockets","key":"**********************","dbg_all":true,"dbg_read":true,"dbg_write":true,"dbg_notify":false,"dbg_mail":false,"dbg_prop":false,"dbg_sync":true,"dbg_bridge":false,"dbg_low":false,"dbg_pins":"","multi_cmd":true,"proxy_type":"no","proxy_url":""}]

Example 2. Home Automation with Xiaomi miIO devices

Monitor & Control Xiaomi devices ( Motion Detector, Window/Door Sensor, Temperature and Humidity Sensor, Air Purifier, etc) via Blynk App

npm install node-red-contrib-xiaomi-miio

Just an imaginary scenario(I don't own any Xiaomi devices). Use blynk-ws to connect between Home Automation Kit and Blynk server (local or cloud). miio-senssor-ht(Temperature and Humidity Sensor) returns temperature, humidity and voltage.

Related Posts

FYI : node-red-contrib-blynk-ws/nodes

Review msg format of each node-red-contrib-blynk-ws/nodes.

text, x, y for the first row display. text1, x1, y1 for the second row display. No payload.

msg = { clear : 1, text : "Okie Dokie", x : count, y : 0, text1 : "Welcome Back!", x1 : rcount , y1 : 1};
return msg;
  • JoyStick if MERGE Output is selected.

write event node returns msg.arrayOfValues for [x,y].

  • Pull Request from Virtual Pin 3 (Blynk App)

read event node returns a pin number.

  • Send a notification to Blynk App

The content of msg.payload will be appeared on Blynk App.

In function node,

var value = Math.floor(Math.random()*40+ 60);
var new_msg = {payload : value};
// OUTPUT 1 -> VPIN4
// OUTPUT 2 -> notify
// return [ OUTPUT1, OUTPUT2 ]
if ( value > 90 || value < 70 ) 
     return [new_msg, { payload : "Out of your comfort zone. Please make the necessary adjustments."}]
else return [new_msg, null ];

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.