Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By dominator99
#56529 Following on from my post in July, I've managed to get 4 ESP8266 Adafruit Huzzah 'clients' (STA) to communicate with an Adafruit Huzzah Feather AP sending temperature data from 4 different locations using UDP very reliably.

Is it possible to send this data to a Windows 7 PC wirelessly for display purposes? If so, how would I start?

I'm a newbie to this so please explain any suggestions in detail
User avatar
By mrburnette
#56611 I've used Processing to listen to UDP ... it is cross-platform. The sketch is below:

Code: Select all// Processing UDP example to send and receive binary data
// https://thearduinoandme.wordpress.com/t utorials/esp8266-send-receive-binary-data/
// Badly hacked by Ray B. to display the UDP broadcast from ESP8266

import hypermedia.net.*;             // http://ubaa.net/shared/processing/udp/udp_class_udp.htm

String ip = "10.10.10.1";            // the remote IP address of ESP8266
int port = 8888;                     // the destination port - any unused port
long previousMillis = 0;
long interval = 500;

UDP udp;


void setup() {
  udp = new UDP(this, 8888);
  udp.listen( true );
}

void draw() {
    if (previousMillis < millis() - interval) {
      previousMillis = previousMillis + interval;

        byte[] message = new byte[2];
        message[0] = 0; message[1] = 0;
        udp.send(message, ip, port);
    }
}

void keyPressed() {
  if (key == '-')
  {
      byte[] message = new byte[2];
      message[0] = 0; message[1] = 0;
      udp.send(message, ip, port);
  }
}

void keyReleased() {
  if (key != '-') {
      byte[] message = new byte[2];
      message[0] = 0; message[1] = 0;
      udp.send(message, ip, port);
  }
}

void receive( byte[] data ) {        // <– default handler
  for (int i=0; i < data.length; i++)//void receive( byte[] data, String ip, int port ) { // <– extended handler
      print(char(data[i]));
  println();
}



Ray