I cannot read this message


#1

Hello, again!

I am making Soket Program to send and receive byte data

I am setting a wifi module but I cannot read the message

How can I resolve this problem?

Here is my source code and following the result

#include <avr/pgmspace.h>

#define WIFI_ENABLE_PIN 13
#define DEBUG true

#define SSID "Project11x"      //your wifi ssid here
#define PASS "abcd1234"   //your wifi wep key here

void setup()
{
  Serial1.begin(9600);
  Serial1.setTimeout(10000);
  Serial.begin(9600);  //can't be faster than 19200 for softserial

  if(DEBUG) {  
    while(!Serial);
  }

  pinMode(WIFI_ENABLE_PIN, OUTPUT);
  digitalWrite(WIFI_ENABLE_PIN, HIGH);

  sendData("AT\r\n", 5000);//Test AT startup
  sendData("AT+GMR\r\n", 5000);//View version info
  sendData("AT+CWMODE=1\r\n",5000);//WiFi mode
  sendData("AT+CWLAP\r\n", 5000);//List available APs
  sendData("AT+CWJAP=\"Project11x\",\"abcd1234\"\r\n",5000);
  sendData("AT+CIPMUX=0\r\n",5000);//get ip address
  sendData("AT+CIFSR\r\n",5000);
    
  Serial.println( "Start Socket server 1" );
}

void loop() {
  delay(5000);
  clearRx();
  sendData("AT+CIPSEND=0,4",6000);
  delay(1000);
  sendData("iopd",6000);
  delay(1000);
}

void clearRx() {
  while(Serial1.available() > 0) {
    Serial1.read();
  } 
}


String sendData(String command, const int timeout)
{
  String response = "";
  Serial1.println(command); // send the read character to the esp8266
  long int time = millis();
  while( (time+timeout) > millis()) {
    while(Serial1.available()) {
      // The esp has data so display its output to the serial window 
      char c = Serial1.read(); // read the next character.
      response+=c;
    }  
  }
  if(DEBUG)  {
    Serial.print(response);
  }
  return response;
}

result:

L �
;�a�+�’껩V|���TxxpA�뢹Χ��


#2

What’s the baud rate of the serial monitor?


#3

the baud rate of the serial monitor is 9600!


#4

Have you re-flash the firmware for esp8266 to AT firmware? Please upload the sketch hardwareSerialMonitor to test AT command directly.

You can type AT command directly in serial monitor after sketch is uploaded. For example:

AT+GMR