2

I'm trying to send some test request to http://requestb.in/qucuwrqu?inspect with ESP8622 but without luck. I tried a lot and still it doesn't seems to work.

Endpoints works fine when requesting them via cURL.

AT+RST

AT+CWMODE=1

AT+CIPMUX=0

AT+CWJAP="wifi ssid","password"

AT+CIPSTART="TCP","requestb.in",80"

AT+CIPSEND=53
POST /qucuwrqu HTTP/1.1\r\n\r\n1234567890123456789012

AT+CIPCLOSE

All commands except line with POST (none) I'm sending with NL/CR.

To be honest I will need to send more complex request, but wanted to make it work with simpler one first hoping that it will help me finish more complex one.

More complex should have something like that in data:

PUT /rooms/2.json HTTP/1.1\r\nHost: some_host\r\nContent-Type: application/x-www-form-urlencoded\r\nConnection: close\r\nContent-Length: 15\r\n\r\n{"empty": true}

Will it also work with https:// ?

If you see what might be wrong, let me know please.

UPDATE with some aditional info

I've tried something like this (empty sample, just sending AT commands):

AT

OK
AT+CWJAP="SSID","password"

OK
AT+CIPSTART="TCP","50.16.237.179",80

OK
Linked
AT+CIPSEND=30

> GET /qucuwrqu?key=sometest\r\n
SEND OK

OK
Unlink

But there is no response on web side. I am getting corect response from ESP8622 so it should work fine I hope. Also tried this code:

#define SSID "Dawid"
#define PASS "somepass"
#define IP "50.16.237.179" // requestb.in
String GET = "GET /qucuwrqu?key=some_test";

void setup()
{
  Serial.begin(9600);
  Serial.println("AT");
  delay(5000);
  if(Serial.find("OK")){
    connectWiFi();
  }
}

void loop(){
  updateTemp("teesst");
  delay(60000);
}

void updateTemp(String tenmpF){
  String cmd = "AT+CIPSTART=\"TCP\",\"";
  cmd += IP;
  cmd += "\",80";
  Serial.println(cmd);
  delay(2000);
  if(Serial.find("Error")){
    return;
  }
  cmd = GET;
  cmd += tenmpF;
  cmd += "\r\n";
  Serial.print("AT+CIPSEND=");
  Serial.println(cmd.length());
  if(Serial.find(">")){
    Serial.print(cmd);
  }else{
    Serial.println("AT+CIPCLOSE");
  }
}


boolean connectWiFi(){
  Serial.println("AT+CWMODE=1");
  delay(2000);
  String cmd="AT+CWJAP=\"";
  cmd+=SSID;
  cmd+="\",\"";
  cmd+=PASS;
  cmd+="\"";
  Serial.println(cmd);
  delay(5000);
  if(Serial.find("OK")){
    return true;
  }else{
    return false;
  }
}

And I've noticed that it isn't connecting to WiFi.

What might be wrong?

Thanks in adavance, Regards David

poslinski.net
  • 201
  • 1
  • 3
  • 15

0 Answers0