Hello, again.
Second trial, I made tcp/ip socket server with Catus Micro r2.
The message from client is received as expected but it was not possible to send message from Cactus server.
Again, I only see "Busy s…"
It would be really helpful if you give me some advice.
Here are full source code and serial output
Source
#include <avr/pgmspace.h>
#define WIFI_ENABLE_PIN 13
#define DEBUG true
#define SSID "ssid" //your wifi ssid here
#define PASS "passwod" //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+CWMODE=1",5000);
sendData("AT+CIPMUX=1",5000);
sendData("AT+CIPSERVER=1", 5000);
sendData("AT+CIFSR",5000);
Serial.println( "Start Socket server 31" );
}
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;
}
Serial output
AT+CIPMUX=1
OK
AT+CIPSERVER=1
OK
AT+CIFSR
+CIFSR:STAIP,"192.168.0.23"
+CIFSR:STAMAC,"18:fe:34:f2:93:2d"
OK
Start Socket server 31
AT+CIPSEND=0,4
OK
>
+IPD,0,20:Hello! from client
iopd
busy s...
SEND OK
AT+CIPSEND=0,4
OK
> iopd
busy s...
SEND OK
AT+CIPSEND=0,4
OK
>
Thanks for follow up comment
AT command seems working ok but I cannot read the result from ESP8266. I think this is related to your last comment hardwareSerialMonitor will not work.
How can I read character from ESP8266 correctly?