Help displaying vpin value on node-red dashboard

Hello folks, I’ve read a variety of forum posts from Pete and others about using the newer node-red blynk package. I’ve got it all installed on an AWS EC2 and I have a simple flow build. However, no data gets sent to the debug window or the gauge. I seems like node-red is connecting to the bynk device/template (a battery). Why am I not seeing any data coming over into nod-red?

Here’s a screenshot of the flow. This is a read event on v64. v64 receives the amp hours remaining from the battery monitor (an esp32). I have confirmed that the correct pin is v64.

…I’m fully expecting that the problem is that I am just missing some particular node that needs to be in place or some config value. But, I have been over and over the configurations and don’t know what else to do.

It should be a Write event node, not a Read event node.

Pete.

Thanks Pete,
I guess I had the perspective that the node-red was reading from the pin that was written to by the actual device. That’s why I chose Read event. Anyow,I added a Write event and I’m still not seeing anything

Do you see the value in the msg debug?
Can you share your settings from the write node (screenshots)?

In addition to what Pete wrote, you also need to add an “inject” node connected to pin v64 in order for Blynk to then send out what is on pin v64 to node-red.

David

1 Like

Node-Red uses the same naming conventions as the C++ library. In C++ the BLYNK_WRITE(Vpin) callback is used to receive values when the virtual pin value changes on the server.

How are you sending the virtual pin values to Node-Red?

Pete.

Pete,
I’m just learning that I need to do that. I’ve never done anything with Node-red - this is the first project. No-code solutions are a foreign concept for me - feels like I have my hands in a mystery box… don’t really know what I’m feeling in there. Anyhow, I assume that I need an ‘inject’ node as @EBM said, is that correct?

I want to read the docs and I have read some but, I’m not sure where I would have learned that I need and inject node. Is there a quickstart or something that could help me get over the hump of not knowing what I don’t know? …I’ve been coding in various languages for 20ish years - python and js these days. Started back up with C++ for Arduino projects only a month ago - it’d been since about 1998.

I think you need to take a step back and clarify exactly what it is that you are trying to achieve.

Generally, people have two different scenarios…

  1. a device is taking readings (let’s at temperature) and you want to get that data into Node-Red so that you can either display it, or apply some logic rules to it.

  2. an input/control widget in the Blynk app (let’s say a switch widget) is being used to turn a device on/off via Node-Red. You want the on/off (1 or 0) value from that widget to be available within Node-Red so that you can use this to perform som actions (sending instructions to one or more pieces of hardware for example.

In both of these scenarios, an external device (a piece of hardware or the Blynk app) is providing the incoming data.

In Scenario 1, that data could come via a Blynk virtual pin, or via an MQTT message (MQTT is my preference).
In Scenario 2, that data has to come via a virtual pin, and will be seen on the Blynk Write Event node.

Explain in simple terms which of these you are trying to do.
If it’s scenario 1 then share the code that is running on your device.

Pete.

you bet.

I have three esp32 based solar battery monitors (bat1-3) that are sending various data values to Blynk on virtual pins. I have the blynk app working and displaying all that I need on a per-battery basis.

However, I need to create a dashboard that roles up data from all three batteries in one display. Specifically, I want to display these two aggregated metrics - each in a gauge.

  1. From vpin 64, Total amp hours remaining (bat1_v64 + bat2_v64 + bat3_v64)
  2. From vpin12, Average State of Charge [SOC] avg(bat1_v12, bat2_v12, bat3_v12)

Thanks,
JB

Okay, do the 3 ESP32’s have separate auth tokens? (the answer should be yes!).

In Node-Red, what have you set-up in terms of connections to Blynk?
What auth tokens have you used in Node-Red?

Pete.

yes, they each their own auth token. I’ve set up battery 3 and battery 1 in Node-red with their unique tokens and the common template id.

The devices are wifi provisioned, btw.

Actually, it’s working now! :grinning: I needed to change to the Write node and add and inject on an interval. Here’s a screenshot.

Thanks everyone!!

JB

Okay so that you understand what’s happening, I’ll explain…

In C++, when you do a Blynk.virtualWrite(vPin) to write data to a virtual pin on the server, the corresponding BLYNK_WRITE(vPin) callback function is not triggered.
This is a safety feature, to prevent an endless loop being created, and to maintain your sanity, as you’d have constant unwanted BLYNK_WRITE(vPin) triggers, echoing back the data you’d just sent to the server.

The same is happening in Node-Red. When your ESP device write data to virtual pin 64, it doesn’t trigger the Write node attached to the same virtual pin/auth token combination in Node-Red.
To get the Blynk server to tell you what the value of virtual pin 64 is, you have trigger either a Blynk.SyncVirtual(V64) in your sketch, or trigger a Sync node attached to pin V64 in Node-Red. You’ve chosen the latter approach.

The “Read” node attached to pin V64 is serving no purpose by the way.

The setup you’ve gone for has the disadvantage described above, and it also has the disadvantage that in the Blynk app/web dashboard the ESP device will appear to be online constantly, even when it’s offline. This is because you have two devices (the ESP and Node-Red) sharing the same auth token. a long as one of them, is connected to the server then that device will appear online.

Thi8s is why I take, and advocate, a different approach.
None of my ESP devices run any Blynk code. Instead, they talk directly to Node-Red via MQTT, and they take their instructions (commands to activate relays for example) from Node-Red via MQTT messages in the opposite direction.

This way, Blynk is totally unaware of my ESP devices. It only knows about the single device that represents the Node-Red connection.
This also overcomes the first issue, as the incoming messages in Node-Red are inbound MQTT messages, not Blynk virtual pin messages.

It’s not a problem using Blynk and Node-Red the way you are, provided you understand the drawbacks and take appropriate precautions. These include adding timeout nodes to alert you when the data from your sensors stops being received, as this probably means that the ESP device has gone off-line.

Also, I wouldn’t use the Node-Red dashboard. It’s better to create another device (the type doesn’t matter) in Blynk, and send the amalgamated data back to that.

Pete.

Wow. Thanks Pete. That’s all pretty enlightening. I read a post you wrote about creating a “device” to aggregate the values from multiple other devices. I must have misunderstood that you meant - I was thinking that you meant to send from multiple physical devices to another physical device (another esp32, for example) and then have that one device communicate everything to Blynk. …I was wrong, clearly.

The bigger problem I need to solve is for a commercial product with many customers, each with their own set of wifi provisioned devices. This is why I started messing with Blynk. We have discussed Blynk Business - that’s on the table.

I cannot wrap my head around getting the amalgamated device approach, not sending data on vpins, easy wifi provisioning, orgs/users/customers, node-red, a role up dashboard and managing it all in a production environment.

I have a version of the sketch/firmware that uses AWS IoT to send json payloads. That worked but I thought Blynk would offer a solution that do the heavy lifting of actual app development, device provisioning AND a platform to build a multi-tenant UI. It seems it has some gaps and even with Business, it seems I have to hire Blynk to write code to do what I need. …I’m not sure what the arch path is at this point.

I’d like to understand the arch and dev path on this system without having to experiment with Blynk Business before I even know if it’ll work for us. …don’t want to drop $$$$+ to do basic exploration of the system arch

What would you do?

-JB

BTW, Here’s the new node-red program with the ah remaining getting summed up…

Difficult decision.

Dynamic provisioning = dynamic auth tokens, which makes Node-Red or HTTP(S) API use for amalgamating the data virtually impossible.

Blynk may be able to offer a white label solution, but it wont be cheap.

Pete.

If Blynk business opens up additional http api functionality that lets the account owner query by org and user for a list of devices and tokens then it’d be possible to use Blynk business as a sort of core for a system and then create a presentation layer using the http API and whatever UI components fit the needs of the business. Do you know if business accounts get that sort of functionality in the http api?