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

Having Problem While Using HTTP API

httpclient
arduino
python
#1

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.

0 Likes

#2

did you install local server ?

0 Likes

#3

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

0 Likes

#4

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

0 Likes

#5

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

0 Likes

#6

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);
      }
}
0 Likes

#9

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

param.asInt();

will always return 0.

0 Likes

#10

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

0 Likes

#11

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.

0 Likes

#12

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

0 Likes

#13

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

1 Like

#14

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

0 Likes