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

Moderator: igrr

User avatar
By Luiz Henrique
#53811 Hi Guys!

I need a little help here.
My code doesn't work for receive Get Request from a Node.js hosted in my network.
Using this code below, they return on Receive random caracteres:

Recebi: v
Recebi: I
Recebi: v
Recebi: v
Recebi: 5

And my code in node.js is:

Code: Select allvar express = require('express');
var app = express();

app.get('/teste', function(req, res) {
   res.charset = 'UTF-8'
   res.send('3');
});

var server = app.listen(3000, "192.168.0.108", function () {
   var host = server.address().address;
   var port = server.address().port;

   console.log('Exemplo na URL http://%s:%s', host, port);
});



Code: Select all#define SSID "ssid" //Insert your Wireless SSID Here
#define PASS "keypass" //Insert your Wireless Password Here
#define IP "192.168.0.108" // taurussystem.com

String GET = "GET /teste HTTP/1.0\r\n\r\n";

char resultado;
String conteudo = "";

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

void loop()
{
  updateTaurus();
  delay(4000);
}

void updateTaurus()

  String cmd = "AT+CIPSTART=\"TCP\",\"";
  cmd += IP;
  cmd += "\",3000";
  sendDebug(cmd);
  delay(2000);
  if (Serial1.find("Error")) {
    Serial.print("RECEIVED: Still Conected");
    return;
  }
  cmd = GET;
  cmd += "\r\n";
  Serial1.print("AT+CIPSEND=");
  Serial.print("AT+CIPSEND=");
  Serial1.println(cmd.length());
  Serial.println(cmd.length());
  if (Serial1.find(">"))
  {
    Serial.print(">");
    Serial.print(cmd);
    Serial1.print(cmd);
  } else {
    sendDebug("AT+CIPCLOSE");
  }
  while (Serial1.available() > 0) {
    resultado = Serial1.read();
    conteudo += resultado;
    delay(10);
  }
  Serial.print("Receive ");
  Serial.println(resultado);
}

void sendDebug(String cmd)
{
  Serial.print("SEND: ");
  Serial.println(cmd);
  Serial1.println(cmd);
}

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


Whats i doing wrong? I think i need a other library for ESP, because AT Commands is so dumb.

Srry for the english
User avatar
By techiesms
#54231 I don't know what your are trying to make, but I can help you with this related topic. I have made one project using ESP8266 "Fetching Data From Any Website", through AT Commands.In this project, I have to make a HTTP GET request to get particular response. So I'll suggest you to watch my tutorial video, go through my blog and have a look to my code. May possible It can give your answer.

Visit my blog for every detail,

http://techiesms.com/blog/fetching-data-from-any-website/