Having Problem While Using HTTP API

Software and Hardware Used: I am using Arduino Uno and Python for Web Development.

Problem: I am new to IoT so I tried using Blynk to control LED connected to Arduino through the mobile app. I was successful. What I now want is - to have a simple button in HTML which turns on my LED connected to the Arduino to Port - D13 via USB. I want this to be done locally without any cloud if possible.

I tried using the API but wasn’t successful.

did you install local server ?

Yes, But I need the code to run the API (for python). I am doing something wrong there.

I think it is the same for any language

IP server:port /xxxxxxxxxxxxxxxxxxxxxx authtoken/update/V85?value=low // LED off
IP server:port /xxxxxxxxxxxxxxxxxxxxxx authtoken/update/V85?value=high // LED on

where V85 is a led or something else

Okay, and V85 is virtual port (for example) and what about Digital Port (say D13)? I am completely new, sorry for lame question.

You have to attach D13 to Vpin LED with if ( … )

C++
IP server:port /xxxxxxxxxxxxxxxxxxxxxx authtoken/update/V83?value=low // LED off
IP server:port /xxxxxxxxxxxxxxxxxxxxxx authtoken/update/V83?value=high // LED on

where V83 is a led or something else

BLYNK_WRITE(V83){ // virtual LED
  int Value = param.asInt();
    if (Value == HIGH) {
    digitalWrite(D13, HIGH);
  }  else {
    digitalWrite(D13, LOW);
      }
}

Make sure “low” and “high” aren’t sent as strings, otherwise,

param.asInt();

will always return 0.

update/V83?value=low
value is not a string else you have to write “low”

I guess it depends on how you invoke the URL. From the Windows DOS prompt using HTTPie and from the Blynk HTTP RESTful API, low in the context of update/V83?value=low is a string.

I invoke the URL from the web, I have no problem by my side.
it was an example for @Aniket_Dogra :wink:

Thank you everyone. I took another path and didn’t use API. Wrote a python script directly to the ports using PySerial. Thank You @Blynk_Coeur for your help :smiley:

1 Like

Just FYI … you can write directly to the ports using the API as well.