Chat here is you are connecting ESP-xx type modules to existing AVR based Arduino

Moderator: igrr

User avatar
By Sunspot
#41935 I have a working sketch for the ESP-01
It receives strings by UDP and sends them to a UNO for an attached LCD.
But the ESP also send 8 byte long strings if you let it every 20 seconds or so.
They use odd printing and non printing ASCII.
I do not know where they come from.
My work-around is to send strings longer than 8 bytes

Code: Select all#include <ESP8266WiFi.h>
#include <WiFiUdp.h>

WiFiUDP port;

char packetBuffer[255];
unsigned int localPort = 9999;


void setup() {
Serial.begin(115200);
WiFi.begin("Link", "password");

IPAddress ip(192, 168, 0, 180);
IPAddress gateway(192, 168, 0, 230);
IPAddress subnet(255, 255, 255, 0);
WiFi.config(ip, gateway, subnet);
port.begin(localPort);
}

void loop() {

int packetSize = port.parsePacket();
if (packetSize) {
int len = port.read(packetBuffer, 255);

if (len > 0) {
  packetBuffer[len] = 0;
}

//do not send the 8byte spurious strings to the UNO (what are they?)
if (len > 8) {
Serial.println(packetBuffer);
}

port.beginPacket(port.remoteIP(),port.remotePort());
port.write("Your UDP packet was received OK\r\n");
port.write("180");
port.write(packetBuffer);
port.write("\r\n");
port.endPacket();
}

delay(50);
}


Can anyone say where the unwanted strings are coming from - I do not transmit them from thr UDP server