Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By Luiz Henrique
#56709 0
down vote
favorite
i don't response from GET request, send from ESP8266 + Arduino Mega to Node.js. My code in node receive the request, but i don't get nothing in Arduino Code.

Node.js

Code: Select allapp.get('/StatusSaidas', function(req,res){
    res.charset = 'UTF-8';
    console.log('Send to Arduino: ' + statusArdu);
    res.send(statusArdu);
});


Console log from Node.js
http://imgur.com/a/rKxYy

Code in Arduino

Code: Select alluint8_t buffer[1024] = {0};
  if (wifi.createTCP(HOST_NAME, HOST_PORT)) {
    Serial.print("Connection with Host OK!\r\n");
  } else {
    Serial.print("Error to connected to Host!\r\n");
  }
  char *ComandoGET = "GET /StatusSaidas HTTP/1.1\r\nHost: SmartHouse\r\nConnection: close\r\n\r\n";
  wifi.send((const uint8_t*)ComandoGET, strlen(ComandoGET));

  uint32_t len = wifi.recv(buffer, sizeof(buffer), 10000);
  char *resposta = buffer;
  for (int i = 0; i < len; i++)
  {
    if (strncmp(resposta++, "\r\n\r\n", 4) == 0) break;
  }
  resposta += 3;
  receive = resposta;
  Serial.print(receive);
  Serial.print("\n\r");


Then the esp don't receive the answer, but the Node.js send strings like a: {QTD1LAMP, ON}
I don't know what is the problem with my code. Using ESP8266 with Arduino Mega
User avatar
By popcorn
#56754 I think your node.js is not closing the http connection and 'thinks' your not ready with sending your data. I'm not sure

Code: Select allapp.get('/StatusSaidas', function(req,res){
    res.charset = 'UTF-8';
    console.log('Send to
ARDUINO
: ' + statusArdu);
    res.send(statusArdu);
/// ADD THIS
    res.end();
/// ADD THIS ?
});


Did you try this code?

And did you try to get the page with your webbrowser from youre node.js program?