HTTPS API with 2.0

just wondering if any one has used this yet
not sure how to structure it in my sketch does it just go in the main loop?

No, putting an API call in your void loop would attempt to call it hundreds of times per second.

You wouldn’t normally use the API in a Blynk sketch, there are other tools built-in to Blynk to do that automatically.

I think you should start by explaining what it is that you are trying to achieve.


Thanks Peter
I have IOT devices that are in a field that wake up once every 6 hours to send a reading back to the gateway. The IOT device has the Auth token and just needs to connect to the gateway using the https tunnelling.

The loop will only be called every 6 hours for 10sec

What gateway? Do you mean the Blynk cloud server?

The API example that you posted (which by the way exposes your secret Auth token) is used to read the value from the server, not update the server with a new reading.

What’s the thought process behind wanting to use the HTTP(S) API rather than conventional Blynk.virtualWrite commands?


The getaway is an iot device with wifi that connects to the internet using blynk. Edgnet

The nodes sends the auth token in an encrypted message not exposing the authtoken

Originally I was using Blynk.configure(auth) and then Blynk connect this worked great in Blynk 1.0. After speaking to Pavel he suggested HTTPS API with Blynk 2.0 would be better. I just can’t find a working example and don’t want to bug him for it.

Blynk.virtualwrite won’t work if the node can’t connect with its unique auth token.

The message gets sent to the gateway from the node. The gateway shakes hands and sends the nodes sensor data to

but you’ve exposed the token on a public forum…

I’m not really clear why the nodes need to send the auth token to the gateway in the first place. If the gateway has a connection to the Blynk server as you implied…

then I’m not sure why you don’t just use a single auth token on the gateway then simply write the data from different nodes to different groups of virtual pin datastreams.

Here’s one I posted recently…

It’s for the ESP32, but the follow-up post from @Blynk_Coeur explains the changes needed for an ESP8266.


1 Like

Thanks Pete
I now have it sorted. Yes the delay on the response time was causing issues…


Hi Pete

Your example is working perfectly. its updating my virtual pins no worries at all. I was also able to adapt it to my sketch and integrate it with Edgnet…

What would I need to do to get a DataStream value using the Https method? I tried a few things but cant quite get the concept of how that would work.

appreciate your help.

Can you describe your scenario?
You wouldn’t normally need to use the HTTP(S) method to get a datastream value, you’d normally simply use the BLYNK_WRITE(vPin) callback to obtain values automatically when the virtual pin value changes.

If you do need to obtain a value using an HTTP(S) call then the syntax is described here…


I need to be able to send data back to my Nodes. It it just a value the user enters so the device knows when to wake. Because the nodes aren’t connected to the internet when they check in they also need to be able to get the value set by the user. This example does work because the node is not connected to the internet.


waketimer = param.asInt();


You need to use BLYNK_CONNECTED() and a Blynk.syncVirtual(vPin) command for each pin you want to get the latest values for.
This will force the server to send these values and this will trigger the relevant BLYNK_WRITE(vPin) callback to trigger.


Perfect that worked
Thanks Pete

1 Like