1

I need send http request to my own server from arduino uno.

First of all I connected the board through web client configurator.

I tried different codes, the last one is: /* File: RestClient.ino This example makes an HTTP request after 10 seconds and shows the result both in serial monitor and in the wifi console of the Arduino Uno WiFi.

Note: works only with Arduino Uno WiFi Developer Edition.

http://www.arduino.org/learning/tutorials/boards-tutorials/restserver-and-restclient
*/

#include <Wire.h>
#include <UnoWiFiDevEd.h>

void setup() {

  const char* connector = "rest";
  const char* server = "<MY IP>";
  const char* method = "GET";
  const char* resource = "/";

  Serial.begin(9600);
  Serial.println("prima");
  Ciao.begin();
  Serial.println("dopo");

  pinMode(2, INPUT);

  //delay(1000);
  doRequest(connector, server, resource, method);
}

void loop() {

}

void doRequest(const char* conn, const char* server, const char* command, const char* method){
  Serial.println("Im doing the request");
  CiaoData data = Ciao.write(conn, server, command, method);
  if (!data.isEmpty()){
    Ciao.println( "State: " + String (data.get(1)) );
    Ciao.println( "Response: " + String (data.get(2)) );
    Serial.println( "State: " + String (data.get(1)) );
    Serial.println( "Response: " + String (data.get(2)) );
  }
  else{
    Ciao.println ("Write Error");
    Serial.println ("Write Error");
  }
} 

But I get "Write Error" and the server does not recive any request

3
  • does your server run on port 80 and is it accessible over the Firewall? try to access it from some other device in the network. – Juraj Jun 11 '19 at 15:18
  • I made a mistake. I put PubIP:PORT. After your comment I exposed the server on PORT 80 and works. So The request works only with port 80. Thank you – Christian Sicari Jun 11 '19 at 15:46
  • 1
    If you find out that the UnoWiFiDevEd library is very limited, you can use WiFiLink firmware and library with my UnoWiFiDevEdSerial1 library – Juraj Jun 11 '19 at 16:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.