Read String Data on Blynk Widget as Int

Hello everyone,

I’m new to MQTT and IOT and want to use that to send data to Blynk Cloud. How to read string data on the Blynk widget? Am I need to use something before send it to Blynk cloud?

Please help me, thank you

Blynk has lots of different widget types, and the types vary between the mobile and the web dashboard, so its impossible to say without information about which specific widget(s) you’re referring to.

The first step is to ensure that the datastream that you’re sending your data to is configured as the correct data type (String, Integer, Double) because when you add a widget to your dashboard then attempt to link it to a datastream, the datastrams that you can choose are filtered according to the data type that the specific widget can accept.


So I chose double type to my datastream for my widget, but I sent data with string type.

I want to send voltage value from my sensor, it is float type. Is this possible? Or do I have to go back to HTTP?

1 Like

Well, you haven’t really answered my question about widgets, and you’ve made some other comments that don’t really make sense to me.

Once again, what sort of widgets are you talking about?
What sort of system are you sending the MQTT data from, and why are you sending it as a string when you’ve said that the data type at the device end is a Float?

Have you done any testing?


sorry, I’m using gauge and label widgets. Why I’m sending string type? Because I know MQTT only supports string value. These are what I want to send.

      mqtt.publish("ds/powerInput", String(powerInput).c_str());
      mqtt.publish("ds/batteryPercent", String(batteryPercent).c_str());
      mqtt.publish("ds/voltageInput", String(voltageInput).c_str());
      mqtt.publish("ds/currentInput", String(currentInput).c_str());
      mqtt.publish("ds/voltageOutput", String(voltageOutput).c_str());
      mqtt.publish("ds/currentOutput", String(currentOutput).c_str());

You really don’t like answering direct questions do you?

I assume you’re using Nick O’Leary’s PubSub client v2.8 library?
This requires published data to be in a Char variable type, so your code is transforming your values into String variables then using C_str to convert that into a suitable Char variable. This is the approach I use, as I find working directly with Char variables to be a pain.

However, I use this approach to send my data to Node-Red, then use the Blynk plug-in for Node-Red to then send data to Blynk. I’ve not tested using this approach with the new Blynk MQTT functionality, but I don’t see why it shouldn’t work - but is the reason why I asked the question…

which you didn’t answer.


Sure, I have done testing it and it’s not working, that’s why I made this post. Hmm, so it looks like I need to use Node-Red to send data to Blynk.

What results are you seeing?
What tests have you done?


Nothing, widgets didn’t receive or read anything. I sent like what I said before, powerInput, VoltageInput, etc

Can you show me a link or tutorial on how to do Node-Red with Blynk, sir?

Did your device show as being online?
Did you recieve data from other widgets?