I am trying to use an ESP8266 to receive UDP packets and turn a specific LED using the UDP string received. I have made the Arduino program to get the UDP string and display it in the serial Monitor (BTW I want to use AT commands).
Here is a sample output:
+IPD,6:foobar
+IPD,6:foobar
+IPD,13:foobarhesbbdb
+IPD,13:foobarhesbbdb
Problem:
Code
#include <SoftwareSerial.h>
SoftwareSerial softSerial(8, 9); // RX, TX
String line;
void setup()
{
uint32_t baud = 9600;
Serial.begin(baud);
softSerial.begin(baud);
Serial.print("SETUP!! @");
Serial.println(baud);
Serial.setTimeout(10);
softSerial.println("AT+CWJAP=\"***\",\"***\"");
delay(1000);
softSerial.write("\n");
delay(2000);
softSerial.println("AT+CIPSTART=\"UDP\",\"0\",0,5005,2\"\r");
softSerial.write("\n");
}
void loop()
{
while(softSerial.available() > 0)
{
char a = softSerial.read();
if(a == '\0')
continue;
if(a != '\r' && a != '\n' && (a < 32))
continue;
Serial.print(a);
}
while(Serial.available() > 0)
{
char a = Serial.read();
Serial.write(a);
softSerial.write(a);
}
}
How do I extract only the string without +IPD,x
.
I'm new to ESP8266. Please tell me what I'm doing wrong.