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

Make HTTP REQUEST

hey guys,
I am working on a project for which I need to make certain Web Request from the nodemu and I am not able to do so,
here is the code.

    BLYNK_WRITE(V5)
    {
      
      if ( param.asInt() == HIGH){
      String url = "http://192.168.0.18:1234/msg?code=B2BF50:COOLIX:24&pass=43616&simple=1";  // url


     http.begin(url);
      http.GET();
      delay(50);
      http.end();
      delay(10);
    }
      else{
      
      }
    }

I fixed your post formatting… again.

these are not too useful details…
could you provide a bit more sciencific information?

  • did the code compiles?
  • did the http request arrives to the server?
  • did the server returns any http code?
  • etc
1 Like

thanks

the code compiles but it does not arrives at the server.

how do you know that for sure the request doesn’t arrive to the server?

the next logical question is “why”…

  • the “if” condition gets ever executed?
  • the url format is correct?
  • test another url and see if that works
  1. the if statement does in fact works perfectly.
  2. the url format is correct.
  3. i tested it with an ifttt url which does not work.

possible reason
i think that there is some problem with my code.

ps:- i am not at all good at coding (just an 18 year old)
when i enter the url in the blynk app using the WebHook Widget. it works.

basically this url turns on my Air Conditioner so by using the WebHook widet attached to a virtual pin and using a switch widget attached to the same Pin. i can turn on the ac but in order turn the AC off i need to send another url. which i don’t know how to send using the same swtch when in off position.

similarly i plan to use this approach. to controll by TV’s volume and my KODI’s media controlll using the blynk widgets for the same.

what i want is a sample code that i can enter into the then part of my if statement to send pretty much any url that works when entered into the url Tab of the browser.

please respond

If this is a Button widget, set to Switch mode in the app then it will send a “1” when on and a “0” when off.

Pete.

yes, i know that but you see thats not the problem. i want to send http requests to the internet and thats where i face the problem

I’ve just given you the answer to that question, but you don’t seem interested.
I’ll take a back seat and let others help you with your problem.

Pete.

i was able to turn on AC by using a WebHook Widget in the Blynk app. i did nothing to the code. as far as Blynk_write is concerned i know how to use that. i just don’t know how to send WEB REQUEST. and don’t be that rude bro

Official Example Reference

please post full code!!
Where you have declared the variable “http”?

you can try this code, and watch the return variable of GET command:

    Serial.print("[HTTP] begin...\n");
    // configure traged server and url
    http.begin("http://192.168.0.18:1234/msg?code=B2BF50:COOLIX:24&pass=43616&simple=1"); //HTTP

    Serial.print("[HTTP] GET...\n");
    // start connection and send HTTP header
    int httpCode = http.GET();

    // httpCode will be negative on error
    if (httpCode > 0) {
      // HTTP header has been send and Server response header has been handled
      Serial.printf("[HTTP] GET... code: %d\n", httpCode);

      // file found at server
      if (httpCode == HTTP_CODE_OK) {
        String payload = http.getString();
        Serial.println(payload);
      }
    } else {
      Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
    }

    http.end();

Or maybe a problem of non standart http port “1234” ??

have you tried to replace “:” with “%3A” ?

http://192.168.0.18:1234/msg?code=B2BF50%3ACOOLIX%3A24&pass=43616&simple=1