Find the ESP8266 by listening for a UDP message.
The program running in the ESP8266 is broadcasting a UDP message every 15 seconds. You can receive it by running this program in Processing. (If you like you could recode this in C, C++, Python, etc.) The message tells you the IP address of the ESP8266 and the fan speed.
/*
Listen for the UDP messages from the ESP8266
*/
import hypermedia.net.*; // UDP library
import processing.net.*;
import java.util.Date;
import java.text.SimpleDateFormat;
final String PATTERN = "dd-MMM-YYYY HH:mm:ss";
final SimpleDateFormat stdDateFmt = new SimpleDateFormat(PATTERN);
UDP udp; // UDP object
final boolean F = false;
final boolean T = true;
int iLineNo = 0;
int iNofLin = 10;
String sDispTxt;
boolean doLine;
int timeOut;
void setup()
{
frameRate(10);
size(580, 230);
surface.setResizable(T);
udp = new UDP(this, 8123);
udp.log(F); // <-- printout the connection activity
udp.listen(T); // and wait for incoming message
background(20);
}
void fade() {
noStroke();
fill(0, 0, 20, 30);
rect(2, 2, width - 4, height - 4);
}
void draw()
{
int textSz = 20;
int iGY;
if (doLine) {
fade();
textAlign(LEFT);
textSize(textSz);
noStroke();
fill(0, 255, 0);
iGY = textSz + iLineNo * (textSz + 0);
text(sDispTxt, 10, iGY);
doLine = F;
}
if (frameCount % 200 == 0) {
timeOut--;
if (timeOut <= 0) {fade();}
}
}
void receive( byte[] data, String ip, int port ) {
String sMsg = "";
String sLine;
Date now = new Date();
String sDateNow = stdDateFmt.format(now);
//print(String.format("%6d ", frameCount));
for (int i=0; i < data.length; i++) {sMsg += (char) data[i];}
sLine = String.format("%s Rcv from %s %s",sDateNow, ip, sMsg);
println(sLine);
sDispTxt = sLine;
doLine = T; while (doLine) {delay(200);}
iLineNo++;
iLineNo %= iNofLin;
timeOut = 6; // * 10 seconds
}
Program Output:
07-Sep-2023 11:19:41 Rcv from 192.168.1.33 ESP_Fan_Speed,0,40,50,0,0,0
07-Sep-2023 11:19:56 Rcv from 192.168.1.33 ESP_Fan_Speed,0,41,5,0,0,0