Go Down

Topic: Receiving data stream on Yún via UDP (Read 344 times) previous topic - next topic


Hi community,

I am currently working on a setup where I'm reading a sensor with an ESP8266 and streaming the data via UDP to a Yún.
The Yún works as an Access point and the ESP connects to it.
This project is time sensitive and I'd like to read data about every 5ms on the Yún.

So far everything works fine, except the Yún seems to be slow when receiving the data stream.

This is my code:
Code: [Select]
#include <Process.h>
#include <BridgeUdp.h>

BridgeUDP Udp;

void setup() {


void loop()

  int packetSize = Udp.parsePacket();
  if (packetSize)
       Serial.print(millis()); Serial.print('\t');
    Serial.print(">Received data:");
    char packetBuffer [5];
    packetBuffer[1] = '\0';
    Udp.read(packetBuffer, 1);


This is basically a reduced version of the code that I found here.

What I receive on the IDE console looks like this:
Code: [Select]
678862 >Received data:⸮
678886 >Received data:⸮
678909 >Received data:⸮
678933 >Received data:⸮
678957 >Received data:⸮
678980 >Received data:
679003 >Received data:

679025 >Received data:
679048 >Received data:
679071 >Received data:!
679094 >Received data:*
679118 >Received data:-
679141 >Received data:/
679163 >Received data:2
679187 >Received data:4
679211 >Received data:6

So it takes something between 20-30ms between the messages.

Now the sender is programmed to send a random character every 2-3 ms. If I send the data stream to my laptop instead I do indeed receive a message every 2-3ms, so I know that the stream itself is as fast as I'd like.

I am pretty sure the code on the Yún is inefficient, but since it's the first time I'm working on any network applications, I have no idea what to look for.

If anyone can help I'd appreciate it.



So it turns out, the bridge is simply too slow (~1 response every 50ms). At least that seems to be the result of reading a bit into other people's problems.

What solved it for me was using udp2serial (https://github.com/cylinderlight/udp2serial) and bypassing the bridge (which means bridge can't be used anymore, which in this case is fine for me).

I can now receive my values every 2 ms.

Go Up