Use Node-RED to create a bridge between MySensors and Blynk (local server) [Exclusive Guide]

12:17 am May 7, 201715460

Blynk is great to use and order its connected from its iOS or Android smartphone objects. If you have developed objects connected with the library MySensors to communicate long distance by radio waves, it is very easy to return data using Node-RED . This tutorial deals with sending data from a MySensors probe. We will see in a next tutorial how to control actuators MySensors since the Blynk application.

If you do not have Node-red, follow the tutorial that matches your environment:

you can also read this tutorial to learn how manage modules.

Open the palette manager and do a search on the keyword Blynk. You should get 2 modules:

  • node-red-contrib-blynk

node-red plugin blynk

the first (node-red-contrib-blynk) plugin is now obsolete. It still works but will no longer update. Install the 2nd plugin node-red-contrib-blynk-websockets . Once installation is complete, you will have a new palette composed of 4 tools

  • read event : allows to retrieve the events of reading
  • write event : allows to recover the writing events
  • write : allows to publish something on Blynk
  • email : allows you to use an email through the server Blynk

at the time of the writing of this article the plugin is not yet documented. I have a little look. We apologize if there are errors. In any case feel free to share if you have any other info than mine.

node-red-contrib-blynk-websockets palette

Node-RED lends itself very well to this game. Apart from decode messages (the flow is lower) from the Gateway MySensors, there will be no programming. Here’s how we do:

  • the sensor transmits by radio (2.4 GHz) measures to the MySensors Gateway (follow this tutorial to make a WiFi network gateway).
  • It connects to the gateway network from Node-RED MySensors using the TCP/IP flow.
  • Decoding messages MySensors
  • we send each measure on the virtual Pin of the Blynk project
  • Blynk server receives the data
  • mobile app connects to server Blynk to recover measures

Node-RED MySensors to blynk gateway.

connection to the Gateway MySensors

to connect to a network gateway , we will use the TCP Node

node-red tcp mysensors lan gateway

configure the connection as well:

  • Type : Connect to
  • Port: 5003 by default (to adapt to your configuration)
  • at host : ip address of the gateway network
  • output : stream of… String
  • name
  • save with Done

node-red tcp mysensors lan gateway settings parametres

decode messages MySensors

in this tutorial previous , we have seen how decode the messages received by the gateway MySensors on the fly. We will use it again because we need to send the data individually to Blynk. Paste the flow of decoder in your project Node-RED and connect the aau Node TCP previously created.

Mise en place de la passerelle

Maintenant que les messages sont décodés We can extract what interests us and send it to Blynk. To do this, you need to retrieve the following information:

  • the Token of the project on which you want to publish the data
  • the virtual pines on which to send the data. Here, it will be V0 to V1 and temperature to moisture
  • address Blynk server IP and port websocket

Node-RED will contact the server Blynk in Websocket. For an unsecured link, the default port is the 8082.

Si vous disposez de votre propre serveur Blynk local, remplacez IP_BLYNK_SERVER par l’adresse IP. If you used your official Blynk, the server account is cloud . blynk . cc .

Enfin si vous avez mis en place un certificat SSL, vous pouvez sécuriser les échanges avec Node-RED en vous connectant sur le websocket

Vous pouvez modifier les ports dans le fichier de configuration de Blynk

Dans the Node-RED palette, do a search on the keyword Blynk. Place the write on the flow Node

node-red blynk contrib websocket write

press the pencil to the right of the selection list to add a connection

  • Url : the url of the websocket
  • Project key : the token to which data is to be sent
  • Name : give a name to the connection
  • save configuration

node-red blynk contrib websockets url

of back in the write Node:

  • select the connection in the list.
  • Specify the virtual Pin (just the number).
  • Give a name
  • save

 node red blynk websocket mysensors write virtual pin

do the same for moisture. Connect the Write Node on the filter of extraction of the measure. {[Here’swhatyouget

node-red mysensor blynk gateway passerelle

the complete code for the flow

Déployez le flow et ouvrez l’application Blynk sur votre smartphone iOS ou Android. You now receive data from your MySensors items with no changes to the code of the latter.

blynk mysensors node-red gateway