EspruinoWifi - UDP Broadcast ?

Posted on
  • Hi There

    Is it possible to broadcast with the EspruinoWifi ?

    A simple example sending / receiving would be nice.


  • It's not built-in yet, but I merged some code into Espruino's source code to add native UDP support just a few days ago. The hope is to get the Espruino WiFi specific code added for the 1v95 release.

    Having said that, you can still send AT commands directly to send the data you want. Just tried this and it works for me:

    function sendUDP(addr,port,data,callback) {
      if (!callback) callback=function(){};
      data = E.toString(data);
      var at =;
      at.cmd('AT+CIPSTART=4,"UDP","'+addr+'",'­+port+','+port+',2\r\n',2000,function cb(d) {
        if (d=="4,CONNECT") return cb;
        if (d!="OK") return callback("ERROR: "+d);
        at.cmd('AT+CIPSEND=4,'+data.length+'\r\n­', 1000, function cb(d) {
          if (d=="OK") {
            at.register('> ', function() {
               at.unregister('> ');
               return "";
            return cb;
          } else if (d=="Recv "+data.length+" bytes") {
            // all good, we expect this 
            return cb;
          } else if (d=="SEND OK") {
            at.cmd("AT+CIPCLOSE=4\r\n",1000,function­(d) {
              callback(d=="OK"?null:"ERROR: "+d);
          } else {
            callback("ERROR: "+d);
    sendUDP("",4567,"Hello World\r\n")
  • Receiving is more of a pain - and honestly I think you're better off waiting for it to get implemented natively.

  • Thanks Gordon
    I will wait until 1.95 in the hope it will include udp support.

  • Hi.

    I see only few posts about UDP here and surprised a bit.

    I am wondering if there are any plans to make Alexa integration one day. UDP and broadcasting is the corner stone for that. It is very simple protocol: get UDP broadcast, send UDP broadcast (Alexa discovery protocol) and implement simple webserver URL to on/off light or execute other IoT device commands.

    What about taking UDP module from Arduino and rewrite it to Java ? Should not be an issue, except localization for hardware of course.


  • There was a bit of a conversation about this in the Patreon video chat last week. UDP is coming to Espruino WiFi (it's already there for ESP32, Linux and ESP8266), and doing stuff like this would be easy enough once that's in.

    I wasn't aware there was an Alexa protocol though - do you have a link? It seemed that it was just emulating Belkin WeMo sockets

  • Hi Gordon.

    Yes, I mean Belkin WeMo. That is more than enough for any on/off smart switch.

    I have implemented it into arduino basic language, tested - it works great with Alexa.
    It would be very easy to port it into Espruino but UPD needed.
    I can pass you the source code that really works (2 pages code).

    p.s. I've checked several UDP packages on NPM ...
    If this particular can be ported, it should be enough for Alexa integration.

    p.p.s. with a friend we are working on making own Alexa smart skill for IoT devices, would love to collaborate and name it "Espruino-IoT" :-)

  • I guess I've found working UDP implementation in the forum, I will give a try asap.­293517/

  • This was done using a Pico connected to an ESP8266 via serial.
    Espruino was running on the Pico.
    The WiFi driver module was modified.

    It does UDP broadcast and the Application Bonjour will see your device.


  • txs.. we get progress on using new UDP package implementation... UDP send, receive is working already, send has yet a problem of sending longer than 250+ messages. work in progress.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

EspruinoWifi - UDP Broadcast ?

Posted by Avatar for Sacha @Sacha