BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

REST API Can not Read Digital PIN (ESP8266)


#21

@Gunner
Thanks, the fact is that I have tried to add a Digital pin (D5 or GPIO14) on a Widget on my Blynk apps (and tested working from Blynk apps), but sill have the same problem on REST API …


#22

I don’t know what you have, but this is what seems to work for my test…

image

image

And of course, if no widget assigned “in the app”… GPIO14

image


#23

I guess the question for the developers is… how do you READ a pin via API on a device that is not assigned a widget, much like it is possible to WRITE to an unassigned pin?


#24

@Gunner Try something like this, which is a catch-all for unassigned handlers.

//
// This is called for all virtual pins that do not have BLYNK_READ handler
//
BLYNK_READ_DEFAULT()
{
    terminalWidget.print("BLYNK_READ for pin ");
    terminalWidget.print(request.pin);
    terminalWidget.println(" not defined.");
    terminalWidget.flush();
}

#25

Yes… while I haven’t tried with the API, I have played around with the BLYNK_READ_DEFAULT() function.

One limitation seems to be that it is a one-shot type deal AKA it will work for any unassigned pin, but it will only do the same thing (whatever you program in the function) regardless of the pin… and you cannot seem to have multiple functions.

So more a default error catch then a usable multi-pin multi-use solution.

Besides, it wasn’t an issue with an unassigned vPin as much as one that was assigned (in code) just not associated with a widget in the App. The solution is simply associate a widget, any widget, even if never used in the App.