Blynk 2.0 webhook

Hey all.
I would like to share my new project with you. This project is two in one (http client + parser), so you will be able to get data from external sources or even other Blynk devices and parse it without any effort.
In this project, we will be using blynk get API, In my next project, I’m going to use blynk update API.

  1. Required widgets :

One segmented switch or icon segmented switch.


which will be used to choose between two different methods of getting data: manually with a button click or automatically using a timer.

One button widget.


which will be used to get data manually.

One icon button.


which will be used to reset the menu items back to their default values.

Two text input widgets.



the first one will be used to enter the url, and the second one will be used to enter the variable name.

Two menu widgets.



the first one will be used to choose the duration, and the second one will be used to choose the variable placeholder.

Six labeled value widgets.



the first one will be used to view the http request status, and the rest of them will be used to view the variable valves.

The final result should look like this

  1. Datastream configuration :

Sync with the latest server value option will be enabled for the next datastreams only, V0, V1, V7, V8, V9, V10, and V11

  1. How it works :
    When you start the app, the get method will be set to manually, which is the default, and the timer will be disabled. If you choose a timer, the button will be disabled.
    Let’s assume that we choose the manual method. The following step will be choosing an http API link (https links are not going to work).
    Now, after entering the url and clicking the get button, we should see status 200, which indicates that everything is working properly.


    Now let’s move to the next step, which is parsing the http response. I’m using the ArduinoJson library for that.
    how to parse the data ?
    Let’s assume that we would like to get data from this url
    http://ipinfo.io/161.185.160.93/geo

  2. Open the link in any web browser, and you should get a response like this
    {
    “ip”: “161.185.160.93”,
    “city”: “New York City”,
    “region”: “New York”,
    “country”: “US”,
    “loc”: “40.7143,-74.0060”,
    “org”: “AS22252 The City of New York”,
    “postal”: “10004”,
    “timezone”: “America/New_York”,
    “readme”: “Get the full potential of IPinfo - IPinfo.io
    }

  3. go back to blynk app and choose a placeholder then choose the name of the variable you would like to store in that placeholder.
    for example, choose placeholder 1 then use the text input widget and enter ip, like this


    after that you will notice that the menu item placeholder 1 has been changed to ip

    Which indicates that the placeholder 1 is holding the ip variable, now after clicking the get button, the ip Will be sent to datastream V7

    now let’s choose multiple values, like this
    Placeholder 2 = city
    Placeholder 3 = loc
    Placeholder 4 = org
    Placeholder 5 = postal

then click get, and the result should look like this

If you would like to reset the placeholders back to thier default values, just click the reset button.

another example :
How to get data from other blynk device ?

  1. You should use the get multiple datastream values API, for example
    http://blynk.cloud/external/api/get?token=Rps15JICmtRVbFyS_95houlLbm6xIQ2L&v1&v2&v3&v4
    Open it in any web browser and the result should look like this
    {
    “v1”: -1,
    “v2”: 255,
    “v3”: 55.7,
    “v4”: 5.01
    }

  2. assign variables to the placeholders like this
    Placeholder 1 = v1
    Placeholder 2 = v2
    Placeholder 3 = v3
    Placeholder 4 = v4

then click get and the result should look like this

Hopefully everything is clear. If you have any questions, feel free to ask.

Sketches can be found here

5 Likes

Very good job John :+1:

1 Like

forgot to mention
The timer menu widget items should look like this


You can change it as you wish (you need to change the sketch as well).

and the variable menu widget items should look like this

So sorry about that :sweat_smile:

3 Likes

Cool, so you are doing the POST and GET functions in the ESP micro and send them to the Blynk dashboard?
Very clever.

So this enables us to send/receive data to any external source via the micrcotroller. Cool