Cesar Abascal
Cesar Abascal

Reputation: 69

Data "streaming" using WiFi/Ethernet

I wrote a simple Python3 code that takes readings from a sensor at 250Hz. I wish to send these readings to my laptop so the values can be used in real time in an application that I'm creating in Python.

Therefore, I would like to be able to add code into my existing Python code that instead of simply printing the sensor readings on the Pi, sends the values to my laptop in a way that can be read by my Python application.

I'm thinking to use wireless or ethernet on the Pi, so I intend to send the data via a cable or WiFi.

UDP protocol can be used at this sample rate (250Hz)? Or I need to develop some way to bufferize the data until to send over UDP?

Any advice on how I could achieve this would be very appreciated, thanks.

Upvotes: 0

Views: 1037

Answers (1)

Brad
Brad

Reputation: 163240

UDP protocol can be used at this sample rate (250Hz)?

Sure.

Or I need to develop some way to bufferize the data until to send over UDP?

Yes. There are 28 bytes of overhead to every UDP packet you send. If your sensor data is only 2 bytes long and you send this at 250 Hz, 93% of the data you're sending is overhead. Send several samples at once per-packet.

The other thing to keep in mind is that lower layers will also add overhead. There is also some overhead in switching and routing. Fit as many samples in a packet as you can, for your latency requirements.

Upvotes: 1

Related Questions