REST API Can not Read Digital PIN (ESP8266)

All, any one can assist me on this?
when I launch REST API on my browser:

The command are:
http://192.168.0.23:8080/<my-auth-token>/get/D5

I get this message:
Requested pin doesn't exist in the app.

While accessing the Virtual PIN is a success …
http://192.168.0.23:8080/<my-auth-token>/get/V5

["0"]

is a success …

I’ve just added a new D5 button in Bynk Apps and unfortunately is the same …

You may not have the correct board setting in the App… Also, D5 doesn’t mean the silkscreened D5 on the ESP, rather the GPIO/Arduino reference - Digital Pin 5 (which is probably the silkscreened D1)

And of course the V5 is a totally different reference… with which you could be triggering any pin via code from your V5 Function.

PS the red “Issues and Errors” topic category is for bugs and stuff… this is just a case of using improper syntax.

D5 is not the GPIO_05 right?

I have tried the Blynk apps and D5 is the correct PIN

So what you mean D5 on Blynk Apps is not the D5 on REST API?

With the API… D is for Digital, A is for Analog and V is for Virtual… But the number in both the Digital and Analog are using the GPIO(Arduino) designation NOT the silkscreened (NodeMCU) one.

So try this instead…

http://192.168.0.23:8080/<my-auth-token>/get/D14

Yes … I think I’ve tried the correct PIN … I tried several D PIN and all resulting the same …

Just tried and same result …

And if you are trying to toggle the state of that pin… try this way (the Write pin value via GET method) …

http://192.168.0.23:8080/<my-auth-token>/update/D14?value=0
http://192.168.0.23:8080/<my-auth-token>/update/D14?value=1

But again… make sure you are using the correct board type in your App, as the API uses that device selection to “map out” the proper pin.

BTW, this was all discussed just a day or so ago here…

According to the link you gave: ESP8266 should be like this:

    "name": "ESP8266",
    "map": {
        "digital": {
            "pins": {
                "gp0":  0,  "gp1":  1,  "gp2":  2,  "gp3":  3,  "gp4":  4,
                "gp5":  5,
                                        "gp12": 12, "gp13": 13, "gp14": 14,
                "gp15": 15, "gp16": 16
            },
            "ops": [ "dr", "dw" ]
        },
        "analog": {
            "pins": {
                "adc0": 17
            },
            "ops": [ "ar" ],
            "arRange": [ 0, 1023 ]
        },
        "pwm": {
            "pins": [
                "gp0", "gp1", "gp2", "gp3", "gp4", "gp5", "gp12", "gp13", "gp14", "gp15"
            ],
            "ops": [ "aw" ],
            "awRange": [ 0, 1023 ]
        },
        "virtual":  {
            "pinsRange": [ 0, 127 ],
            "ops": [ "vr", "vw" ]
        }
    }
}```


Unfortunately when I tried gp14 or gp5 it does not recognised :frowning:

To confirm, you are trying to READ the state of a digital pin (silkscreened D5 - GPIO14) probably from a NodeMCU or Wemos Di Mini… correct?

1 Like

I’ve just tried:

http://192.168.0.23:8080/<my-auth-token>/update/D14?value=0
http://192.168.0.23:8080/<my-auth-token>/update/D14?value=1

And surprisingly work like a charm :slight_smile:

But have no luck on :
http://192.168.0.23:8080/<my-auth-token>/get/D14

I am testing on my Mega based testbench, and getting the same error… and with the Mega there is no discrepancies… the button on D12 is digital pin 12, AKA GPIO12, AKA API D12…

image

Further testing…

Yes, correct a NodeMCU 8266

I will test on my NodeMCU then and report back…

1 Like

Really appreciate with your time dude … I’m doing some digging also here …

OK, while I can toggle pins, I can NOT read them, on Arduino or NodeMCU…

On the NodeMCU while entering different pins from D1 and up, I get the rare “1” or “128” but mostly the “Requested pin not exists in app.”, and when I can get a value, it doesnt change when the supposed pin state changes…

I have tried Generic board, ESP8266 and NodeMCU… all same results.

I am starting to see how this supposedly RESTful API is causing some to lose sleep :stuck_out_tongue_winking_eye:

OK, back to the RED Issues and Errors category… something appears quirky with this API

@Dmitriy take a look

@noersaleh All Right!.. Preliminary tests with a clean Project point out what I guess is obvious, after the fact :blush: … but not documented that I am aware of (as far as the API is concerned).

If you don’t have a widget assigned to a digital pin, it will register as “Requested pin doesn’t exist in the app.”… or possibly a random, unchangeable, state.

But if you then assign a widget/reading rate to a digital pin, then the API GET command will read the corresponding pin state [“0”] or [“1”].

The key is that you MUST have an pin assigned widget!.. vPin for Vpin reading, GPIO assigned for Dpin (or Apin) reading.

Toggling a digital pin however WILL work without a widget assigned to the pin… at least with the Write pin value via GET method… go figure.

1 Like