Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

ESP8266MOD response not showing

imranahmed

Advanced Member level 3
Joined
Dec 4, 2011
Messages
768
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,298
Location
Karachi,Pakistan
Activity points
6,134
Please let me know about response of ESP8266MOD is not showing on Serial Monitor I set baud rate to 9600 but still not showing response but program is running well, data is transmitting to database successfully, I need responses of every AT command he sends.
Code:
#include <SoftwareSerial.h>
#define RX 2
#define TX 3
#define DEBUG true
String AP = "****************";
String PASS = "**************";
String sendData = "";
int sendVal;
String ROW1 = "", ROW2 = "";
SoftwareSerial espSerial(RX, TX);

void setup() {

  Serial.begin(9600);
  espSerial.begin(9600);
  pinMode(8, INPUT_PULLUP);
  espData("AT+RST", 1000, DEBUG);                      //Reset the ESP8266 module
  espData("AT+CWMODE=1", 1000, DEBUG);                 //Set the ESP mode as station mode
  espData("AT+CWJAP=\"" + AP + "\",\"" + PASS + "\"", 1000, DEBUG); //Connect to WiFi network
  delay(2000);
}


void loop() {

  sendData = "GET http://"HERE IP ADDRESS"/fileapi.php?ROW1=123&ROW2=878";
  "&ROW1=" + ROW1 +
  "&ROW1=" + ROW2;
  espData("AT+CIPMUX=1", 1000, DEBUG);
  espData("AT+CIPSTART=0,\"TCP\",\"HERE IP ADDRESS\",80", 1000, DEBUG);
  espData("AT+CIPSEND=0," + String(sendData.length() + 4), 1000, DEBUG);
  espSerial.find(">");
  espSerial.println(sendData);

  Serial.print("Value to be sent: ");
  Serial.println(sendData);
  espData("AT+CIPCLOSE=0", 1000, DEBUG);

  delay(2000);

}

String espData(String command, const int timeout, boolean debug)
{
  Serial.print("AT Command ==> ");
  Serial.print(command);
  Serial.println("     ");

  String response = "";
  espSerial.println(command);
  long time = millis();
  while ( (time + timeout) > millis())
  {
    while (espSerial.available())
    {
      char c = espSerial.read();
      response += c;
    }
  }
  if (debug)
  {
    Serial.print(response);
  }

  return response;
}
 

paulfjujo

Advanced Member level 4
Joined
Jun 9, 2008
Messages
1,428
Helped
290
Reputation
580
Reaction score
275
Trophy points
1,363
Location
France 01800
Activity points
10,023
hello,

you are doing string=char
store the char at the location pointed by response
and increment this pointer for next char

pay attention :
* to init the size of string response .. to the maxima possible
* a string must have a zero value as terminator
Code:
   string reponse="                                           ";

or declare a char table and init it, with zero value
char response[20];
for (i=0;i<20;i++) response=0;


Code:
   while (espSerial.available())
    {
      char c = espSerial.read();
     *(response++)= c;
    }
 
Last edited:

LaTeX Commands Quick-Menu:

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top