Blynking Wonderful

As of yesterday, a new release of the Blynk App has been released which makes me want to look at this  again.

Regular readers know that I’m into the idea of using a central controller for home control – so that instead of trying to give every peripheral every feature on the planet, I’ve chosen to use Node-Red on a Raspberry Pi or similar. This has the ability to send emails, send and receive data to and from peripherals and to handle a variety of functions – many as simple as dragging a box onto the screen – yet allows complex programming in the same environment if required.

There are as many ways to fit a UI to Node-Red as there are ways to talk to peripherals – node-red-contrib-ui is one of the leading candidates but you can easily talk to NR via HTTP, web sockets and other drop-in technologies. At one time, NETIO was a great candidate but I’ve not seen that improving for a long time – a shame as there’s a nice visual web editor. Node-Red-Contrib-UI is a very hot contender as it is easy to use but I suspect the sole developer is busy elsewhere right now.

BlynkMeanwhile there is Blynk – available for Android and IOS. The basic principle is that this app talks to a “blynk server” – either theirs or a local copy (a pair of JAR files), which keeps track of changes to devices. The likes of Arduino, ESP and others can talk to the Blynk server via special (and freely available) oftware.   Some time ago a set of nodes was released for Node-Red which would talk to the server and hence the Blynk app – but the nodes were not reliable – I spent ages talking to the author and was about to give up when he adopted a new approach – and suddenly the nodes became super-reliable – no doubt a combination of his work and improvements to the Blynk server.

The designers of Blynk had (I think) always imagined that only their APP would be controlling devices – it didn’t seem to occur to them that there might be people like me using Node-Red to perform all sorts of automation tasks on devices and merely using Blynk as a remote control mechanism. Until now, if changes were made to, say, the state of a relay while the Blynk app was on pause (perhaps the phone was handling emails, the App would not know about this until the user logged out and back in.

And so for some time I gave this a miss. That has all changed now and so it is time to look again.

So – the Blynk server – make sure you have at least Java 8 on whatever device you are running Node-Red on – in my case a Raspberry Pi 2 – http://docs.blynk.cc/#blynk-server

I created the directory  /home/pi/Blynk  and dropped in the server.jar and admin.jar files – and created a text file called server.properties.

The latter file contains nothing more than this.

#web sockets ssl port
ssl.websocket.port=8081
#web sockets plain tcp port
tcp.websocket.port=8082

I chose to give full permissions to the folder Blynk – if someone understands permissions better and would like to suggest a sensible minimum for that  – happy to get feedback You can also put gmail details in here if you want so the server can email you but we’ll leave that for now.

To activate this at powerup I went into a Pi terminal and typed..

crontab –e

As this was the first use of that command on the particular machine – it asked me which editor I’d like to use – sadly you don’t get the choice of Notepad++ on the Pi so I settled for Nano.

At the end of the file I added..

@reboot java -jar /home/pi/Blynk/server.jar -dataFolder /home/pi/Blynk &

and saved the file – and rebooted the Pi. Server now running locally. You can test that with the APP by (in the app) registering with the server.

Finally you need the Node Red nodes from here.

npm install node-red-contrib-blynk-websockets

The connection in the Node-Red-Node will look something like this.. depending on your port setup – and yes you could make it available externally via a port redirect..

ws://127.0.0.1:8082/websocket

and a long ID number you get off the app.

And that, in a nutshell just works – well it works for me. I now have this running on 2 Raspberry PIs and will tomorrow add it to my Orange Pi installation.

Apparently the App will not always be free so I’d be getting yours now while it is! I just hope when they go commercial, they remember all the people who have contributed to getting it this far – oh and GIVE US A SMALLER RGB controller!!

Let’s hope node-red-contrib-UI continues to develop to keep the competition healthy!

11 thoughts on “Blynking Wonderful

  1. Hi

    I have justed started with Blynk and the Photon and impressed with how easy it was. I also like the fact (I think) I can have different sensors and actuators based on Photon, Arduino, Pi Zero etc in one system all talking to the same Blynk instance – though I haven’t tried this yet so may be wrong.

    I saw on the Synology forum you were trying to get Blynk running on your DS214+ Diskstation.

    Did you manage it? I have one as well and was looking to do the same thing to keep it “in-house” so to speak.

    1. Blynk server on DS, I think that must’ve been very early on – I have it running on my controlling Raspberry Pi.

      Pete.

  2. Its is looking a lot better – but I think it needs MQTT support and a better way to parcel up and distribute the finished apps with any allowed system access locked down securely

    1. David – of course you can. Just put a port redirect on your router so that whatever external port you choose – goes through to the relevant IP address and port on your Pi or whatever you’re using.

      So given the new setup – latest server .JAR file, latest websockets interface, latest APP as of a couple of days ago – I’ve been unable to kill this – which is a good start.

      1. how do you keep all the not “apt-get upgrade”-able stuff updated on your linux system?
        I mean, the npm stuff, and the source ones…

  3. Hey Peter, You really should try and put some time into Docker containers with all the changes etc that you do on your PI – it would give you an easy Roll Back/Roll Forward environment if nothing else.

    Have a look at this blog where he goes through the setup process (admitedly Arch instead of Debian – but plenty of other tutorials – interestingly he also does NODE-RED

    https://opensource.com/life/15/9/experimenting-docker-raspberry-pi

    1. I have no idea as I have no intention of using the global server – the local server is trivial to put in so why bother with a server over which you have no control.

  4. Time to dig out an ESP 12 and revisit Blynk I think I always really liked to look of Blynk and now they’ve fixed some big issues it’s time to have another go.

    I’ve been looking at thingstud.io for a couple of weeks and it’s pretty good at displaying data, espacially outside my home network …. or at least it would be but I just can’t get it working with cloudmqtt on my phone.

Comments are closed.