BLYNK
BLYNK.IO       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Cannot connect node-red using node-red-contrib-blynk-iot on RPi

I have a setup based on the Pete Knight work, My home automation projects built with MQTT and Node Red - Projects made with Blynk - Blynk Community.

I have managed to build my template, datastreams and IOS app. I was worried about disrupting my current setup so I installed node-red on an old laptop and built a few test nodes. I got them working to my satisfaction so I tried migrating the flows on my RPi.

I tried a very simple case of turning on an LED for 5 seconds. Here are the messages I get:

19 Jul 14:27:30 - [info] Starting flows
19 Jul 14:27:30 - [info] [blynk-iot-client:Blynk IOT] LOG PINS []
19 Jul 14:27:30 - [info] [blynk-iot-client:Blynk IOT] ## FUNC startconn
19 Jul 14:27:30 - [info] [blynk-iot-client:Blynk IOT] ## SET logged FALSE
19 Jul 14:27:30 - [info] [blynk-iot-client:Blynk IOT] Start TLS connection: blynk.cloud:443
19 Jul 14:27:31 - [info] Started flows
19 Jul 14:27:31 - [info] [udp in:d45abbba.f87148] udp listener at 0.0.0.0:1024
19 Jul 14:27:31 - [info] [mqtt-broker:RPI] Connected to broker: mqtt://localhost:1883
19 Jul 14:27:31 - [info] [blynk-iot-client:Blynk IOT] ## TLS state: open
19 Jul 14:27:31 - [red] Uncaught Exception:
19 Jul 14:27:31 - TypeError: Invalid data, chunk must be a string or buffer, not object
nodered.service: Main process exited, code=exited, status=1/FAILURE
nodered.service: Unit entered failed state.
nodered.service: Failed with result ‘exit-code’.
nodered.service: Service hold-off time over, scheduling restart.
Stopped Node-RED graphical event wiring tool.

Any hints as to how to fix this?

Thanks.

What version of node-red-contrib-blynk-iot do you have installed?

Have you googled the error message?

If you uninstall node-red-contrib-blynk-iot does Node-Red start normally?

Pete.

Hi Pete, thanks for the quick response. I had spent so much time Googling “TLS” I didn’t think to Google the error. I’ll try that now.

I’m using version 0.2.0 of node-red-contrib-blynk-iot.

Node-red runs fine after I remove the IOT nodes AND use the backup copy of flows_raspberrypi.json. Darn, it was so easy on the Windows notebook.

Do you mean that you’re un-installing the contrib, either via the command line or the palette manager, or simply removing the nodes from Node-Red flows?

I don’t understand that comment at all. Can you elaborate?

it would be helpful to understand if the error occurs when the contrib is installed, but none of the nodes from the contrib are used in the flows.

This line of your message looks a bit odd to me…

In Node-Red, press CTRL F to open a search dialogue and paste the node ID of d45abbba.f87148 into the search criteria. What node does it show, and is this anything to do with the Blynk IoT contrib?

For info, this is what my console shows on start-up

20 Jul 06:54:34 - [info] Starting flows
20 Jul 06:54:34 - [info] [blynk-iot-client:Blynk 2.0 test] LOG PINS []
20 Jul 06:54:34 - [info] [blynk-iot-client:Blynk 2.0 test] ## FUNC startconn
20 Jul 06:54:34 - [info] [blynk-iot-client:Blynk 2.0 test] ## SET logged FALSE
20 Jul 06:54:34 - [info] [blynk-iot-client:Blynk 2.0 test] Start TLS connection: blynk.cloud:443
20 Jul 06:54:35 - [info] Started flows
20 Jul 06:54:35 - [info] [mqtt-broker:XXX.XXX.XXX.XXX] Connected to broker: mqtt://XXX.XXX.XXX:XXX:PPPP
20 Jul 06:54:35 - [info] [blynk-iot-client:Blynk 2.0 test] login -> ***************************9QwAM
20 Jul 06:54:35 - [info] [blynk-iot-client:Blynk 2.0 test] SEND -> Cmd: HW_LOGIN, Id: 1, len: 32, data: "***************************9QwAM"
20 Jul 06:54:35 - [info] [blynk-iot-client:Blynk 2.0 test] ## TLS state: open
20 Jul 06:54:35 - [info] [blynk-iot-out-write:351073f3.4761fc] ## logged is FALSE
20 Jul 06:54:35 - [info] [blynk-iot-out-write:40ba9844.d2b1b8] ## logged is FALSE
20 Jul 06:54:35 - [info] [blynk-iot-out-write:f3757a83.bc60b8] ## logged is FALSE
20 Jul 06:54:35 - [info] [blynk-iot-out-write:9cdd99e.a8d9768] ## logged is FALSE
20 Jul 06:54:35 - [info] [blynk-iot-out-write:1f1379fb.eb0826] ## logged is FALSE

Pete.

Sorry, I struggled with how to communicate the “backup” part… I copied the file flows_raspberrypi.json to my PC. When node-red on the pi crashes, I copy the file back to the pi before restarting node-red. That way, I know my original flows are still intact.

This action also removes the IOT nodes from the my test flow. The contrib lib is still in the palette, but as no nodes are in the flows, there is no attempt to connect the blynk server.

I was attempting to log some activity. The log file associated with this node was last updated in 2019 so this node is not doing anything useful and I will remove it.

Your console output looks similar to what I see on my laptop test machine. With the login info showing. I’m not getting that far on the pi.

Per your suggestion, I Googled my error message. It appears to be associated with node.js. Further investigation suggests my version of node.js is very out-of-date and may not support TLS. I did start working on all this back in 2018.

I’m in the process of backing up my pi’s SD card. I’ll then update my node.js and try the new IOT nodes again.

Thank you for your help.

Larry

Okay. Go for Node.js 12.17.x or later (preferably 14.x) as Node-Red 2.0 has been released today, and 12.17.x is the earliest version that it supports.

At this stage, I wouldn’t recommend going to 2.0, as I’ve not tested it with the Blynk IoT contrib yet.

Pete.

Which platform(s) are you using? Windows? RPi?

Thanks,
Larry

RPI4 running Buster.

Pete.

I’m running RPI3, Stretch. Did you go through installing SSL certificates?

No.

Pete.

In the process of updating node.js. I really don’t want to update my OS if I don’t have to. I have a pretty extensive project running on the RPI and would hate to have to rebuild that.

Thanks for your help. Its nice to have someone point out the things you’ve missed.

Larry

1 Like

Updated to Node-RED version: v2.0.1 (I know, you suggested to stay 1.xx, it came along with the node.js) and Node.js version: v12.22.2.

My simple test flow is working. I’ll move on to moving the other nodes over. I’ll update as to whether everything works or if I have more problems.

Thanks again!

Larry

1 Like

That’s good to hear.

You should read this:

and look at the other open and closed issues for the new Blynk IOT contrib, so you understand the limitations and the working features.

Are you using MQTT to communicate with the devices you’re controlling?

Pete.

Pete,

I had read your Feedback comments before attempting my conversion. Very helpful.

Yes, I am using MQTT. I’ve modelled my implementation after your work, My home automation projects built with MQTT and Node Red - Projects made with Blynk - Blynk Community.

I am happy to report I’ve completed my conversion and everything appears to be working as expected. I have implemented the LCD node and it is functioning for me.

To summarize my issue, the problem appears to have been an outdated version of Node.js.

Thanks again for helping find that solution.

Larry

1 Like

Good to hear Larry.
It’s always nice to hear of another convert to the dark side :smiley:

One of the things I’m doing with my migration to Blynk 2.0 with the new version of the Blynk contrib is to use a single device.

Previously, I’d started by going down the route if one Blynk device per physical device. However, this quickly became quite messy, so I switched to one device per room, but that wasn’t ideal.
Because of the way that the Blynk 2.0 app forces the use of tiles, and I only want to use one tile for my UK home and one for my holiday home, I’ve used one device per home.
This allows me to use the 256 virtual pins to display data in the one tile, ln multiple tabs.

This isn’t done to save devices (I have free access to the PRO plan, so that’s not an issue) but simply want everything in one place to allow me to to use a single tile.

Pete.

Just did some more testing, and it seems I was injecting data in the wrong format when I did my testing. I’ve updated the issues log to reflect the fact that it works as expected.

Pete.

I agree with you about the device/tiles. My project is very simple. It would be nice to go straight to my screen with the tabs instead of the tile first. The price of progress ;-).

Good to hear the LCD is working for you now. Again, my project is very simple and the conversion, while time consuming, was pretty straight forward. In most cases, I simply replaced the write event and write nodes from the old ws lib with their counterparts in the iot lib. It took me days to get to the Node.js solution. I went down too many wrong rabbit holes.

Larry

1 Like

So, I’ve found something that acts differently between the old websockets lib and the IOT lib. I’m using the terminal on my IOS device app. Neither lib had a terminal node but I found if I send strings to the terminal virtual pin, the terminal acted as expected in the old lib but not in the new lib.

The IOS device must be unlocked and open to the Blynk app for the terminal to display anything sent to it with the new lib.

Do you have any experience with the terminal widget?

Larry

That sounds like an issue with the new app rather than the Node-Red contrib.

Have you tested it doing Blynk.virtualWrites from C++ ?

Are you using Android or iOS?

Pete.

Agreed. Move to a new topic? Should we ask Gab to look into adding a terminal node? I am, after all, essentially using virtualwrite rather than terminal.write. But that seemed to work just fine under blynk 0.1.

I’m not running Blynk code anywhere, only using node-red.

iOS, both iPad and iPhone.