Restful API - pin types, what is what?

Using digital vs virtual vs ‘d’ pins is rather unclear in the restful api section so I would like this assumption verfief by someone who actually knows what is going on, this is how I think it works:

http://10.10.3.13:8080/xxxxxxx/update/6?value=255

updates (digital pin) gpio 6

http://10.10.3.13:8080/xxxxxxx/update/V6?value=255

updates virtual pin 6

http://10.10.3.13:8080/xxxxxxx/update/D6?value=255

updates digital mapped pin D6 (depending on device compilation and assuming you have selected the right board, e.g. for Wemos D6 = gpio 12)

Is this correct?

Well based on some recent testng with a NodeMCU I found I DID need the D in front of the pin… just not the silkscreened Dx designation.

For example…the silkscreened pin D3 = GPIO 0 but you need to write it as D0 in the API URL… does that make sense? :stuck_out_tongue:

And at least with direct pin manipulation, PWM values don’t seem to register, only 0 & 1

http://10.10.3.13:8080/xxxxxxx/update/D0?value=0
http://10.10.3.13:8080/xxxxxxx/update/D0?value=1

Virtual pins seem to work as normal… Display widget on V0

http://10.10.3.13:8080/xxxxxxx/update/V0?value=Hello World

Or a BLYNK_WRITE(V0) Function

http://10.10.3.13:8080/xxxxxxx/update/V0?value=0
http://10.10.3.13:8080/xxxxxxx/update/V0?value=1

Ok so new assumption:
///

http://10.10.3.13:8080/xxxxxxx/update/6?value=1

DOES NOT WORK??
///

http://10.10.3.13:8080/xxxxxxx/update/V6?value=1

updates virtual pin 6, where any value is registered, also strings e.g.: “Hello World”
///

http://10.10.3.13:8080/xxxxxxx/update/D6?value=1

updates GPIO pin 6, where ONLY the values 0 and 1 are registered.
///

Is that correct?

Virtual pins should work as normal, for digital/analog - you could check correct index here: https://github.com/blynkkk/boards

I’m familiar with that one, but its really vague whether theres any difference between pins: 6, V6 and D6 when using the API and what they mean. Sometimes (like now) your implying that D6 refers to the mapped D6 to e…g GPIO 12 (for wemos) while in other ocassions its suggested that D6 always refers to GPIO 6. So which one is it? and does pin ‘6’ do anything? Is it recognized as Virtual, Digitally mapped or gpio?

I don’t know if an entered index (without D/A/V) is leading somewhere - @Dmitriy please correct me here.

You need to add pin type (D - for digital, A - for analog, V - for virtual) and it’s index. For Virtual pins (as they are an invention) - you need to use same indexes as in the app, for Analog and Digital - you need to use a correct index from board’s info JSON file.

thank you for the elaboration, indeed I forgot the ‘A’. As for the index, this:

seems to contradict what you’re saying!

I think this is where choosing right board type in project properties REALLY matter :slight_smile:

1 Like

well…that’s the part that is rather unclear. If D3 refers to gpio 3 as Gunners findings appear to lead, then it completely not relevant which board your using…however if the dev is right then its VERY relevant which board you use.

So what the dev thinks how it should work and the user finds how it is working are contradicting eachother! So which is right?

OK, so lets check:

  • NodeMCU BLYNK Pin defs:
"name": "NodeMCU",
    "map": {
        "digital": {
            "pins": {
                "D0":  16, "D1":   5, "D2":   4,  "D3":  0, "D4":  2,
                "D5":  14, "D6":  12, "D7":  13,  "D8": 15, "D9":  3,
                "D10":  1
            },
  • Arduino MEGA Blynk pin defs:
"name": "Arduino Mega",
    "map": {
        "digital": {
            "pins": {
                "D0":  0,  "D1":  1,  "D2":  2,  "D3":  3,  "D4":  4,
                "D5":  5,  "D6":  6,  "D7":  7,  "D8":  8,  "D9":  9,
                "D10": 10, "D11": 11, "D12": 12, "D13": 13,
                "D20": 20, "D21": 21, "D22": 22, "D23": 23, "D24": 24,
                "D25": 25, "D26": 26, "D27": 27, "D28": 28, "D29": 29,
                "D30": 30, "D31": 31, "D32": 32, "D33": 33, "D34": 34,
                "D35": 35, "D36": 36, "D37": 37, "D38": 38, "D39": 39,
                "D40": 40, "D41": 41, "D42": 42, "D43": 43, "D44": 44,
                "D45": 45, "D46": 46, "D47": 47, "D48": 48, "D49": 49,
                "D50": 50, "D51": 51, "D52": 52, "D53": 53
            },
            "ops": [ "dr", "dw" ]
        },

Now imagine the situation, where a real NodeMcu hardware has been defined as ArduinoMega in Blynk Project.

Then we have: You tell the Blynk to drive the D0 pin. This pin is mapped to GPIO0. But on NodeMCU a Silk screened D3 reacts. But hey, This silk screened D3 is actually a GPIO0!! Am I right?

1 Like

yes, same though occured to me…however I don’t think @Gunner makes that type of a mistake!

A mistake? Perhaps… An overlook? More likely… Personally I’m mostly using just “Generic”, where (as it seems) Dx pins are not used at all.

I appreciate your confidence in me… but I just have to trial and error at times to figure things out :stuck_out_tongue_winking_eye:

Which way works for you?

Using an LED between Silkscreened pin D7 and GND on a Node MCU, set correctly in the IDE and App…

This fails (and putting a D in front would just turn on the wrong pin)

image

This works

image

Please excuse the dusty board… dust is a constant losing battle for me in a small RV :blush:

well, thats what I was trying to figure out but I got the http fail -11 (time out) so…no clue

Ah… OK, not the “wrong pin format” error… so you are running into some other issue then.

Are you controlling over Cloud or a Local Server?

local. There’s another topic covering this, but basically: the url works in the browser but no in the code (and I copy pasted the url from serial output so it really is the same!).

Got ya… so something else besides pin designation then. Well, I haven’t graduated to using API via code yet, so I have no contribution for that topic :stuck_out_tongue:

at least for the viewer :wink: Perhaps binary-mind sees more??

I guess the answer as usual is: 101010

2 Likes

don’t argue with binary world- you will lose - they are incredibly patient and stubborn :stuck_out_tongue: If it says to you “you are wrong” then YOU ARE WRONG :wink: