Node Red to Blynk via MQTT

I am having trouble understanding how to get my data from Node Red to Blynk via MQTT.

I have a NCD.IO Gateway and one of their temperature/pressure sensors. I am able to see the sensor data in my debug node:
.

I want to simply send the temperature to Blynk.
I have a template created with pin V0 named Temp1, and my device shows as ONLINE in my dashboard.

From reading through the Blynk docs, it looks like I need a “function node” to tell node red what to send, but the example shown is cryptic to me.

From the info in my debug node, can you tell me what code I would need in my function node and what additional settings I may need in my MQTT OUT node to send the temperature?

Are you using the Blynk IoT contrib, or doing this directly via MQTT commands?
Some details of your flow would be useful.

Pete.

Hi Pete,

Was trying to use the example given here, but with just a single sensor and output:

But if there is an easier way, I am open to anything…

-David

Being able to talk directly to the Blynk server via MQTT is quite a new facility, and one that I’ve not done very much testing with, other than when it was first released.
Prior to that, the only method of using Node-Red with Blynk was via the Blynk contrib, and later the Blynk IoT contrib (when the current Blynk IoT product was released).

As I’ve always used this method to communicate with Blynk, it’s what I still use - because it’s simple and straightforward and works very well.

How to use the Blynk IoT contrib is covered in this topic…

Pay attention to which nodes to use when receiving data and sending data, as the naming isn’t exactly intuitive.

Also, don’t try mixing flows using direct MQTT communication and the Blynk IoT contrib, as you may get conflicts caused by attempting to use the same Auth token at the same time.

Pete.

For clarity:

  1. Are you saying the Blynk IoT nodes do or do not work with MQTT?
  2. I only want to write to Blynk, never need to read from Blynk.

No. Did you read the link I provided?

I’m not sure that makes any difference, although the Blynk example you’ve been following is all about reading data from Blynk.

Pete.

I did read your link. There is so much in there, I am having difficulty determining what part of it applies to my simple requirement.

Are you saying the NCD Environment Air Quality Sensor example is about READING data from Blynk? Now I am even more confused. Per Blynk folks, the example was created to take sensor data from NCD.IO and write it to a Blynk dashboard.

Install the Blynk IoT contrib via the palette manager

Create a NEW template and new device based on that template in Blynk
Set-up some virtual datastreams in the new template and connect some widgets to them in a Blynk dashboard.

Add a Blynk IoT Write node node to a new Node-Red flow, edit the node and create a NIE Blynk connection using the template ID and Auth token from your new device.
Assign the node to the virtual pin that relates to one of the datastreams you created.
Add an inject node and send a value to the Write node. The value you send will appear in your Blynk widget.

Pete.

I have no problems sending data the way you just described and have it displayed in a dashboard, if I am simply sending a number… that works fine.

But the data I am starting with comes from the NCD gateway in the format I showed in my initial post. How do I parse out just the temperature value from that data in order to send it to Blynk?

The NCD example which I referenced above uses a function node which I assume does this, but I am unable to understand the code within their function node.

Personally, I’d just use a Change node to extract the piece of data you want (copy the path from your debug window) and output it as the msg.payload then send it to Blynk.

Pete.

Finally got it working. I found this and adapted to my needs:

Thanks for the help Pete. I appreciate you.