Quickest way to stream data from Photon

I am brand new to the Particle ecosystem and programming my Photon. Just to give some context to my question, I want to do a project where I want to stream data as quickly as possible. I will be dropping my Photon with an motion sensor, and I want to stream the motion data to my laptop in some way. The data will only be available for a few seconds, and I would like to get as much of it recorded as I can. I am indifferent if the data is transferred via a cloud service/dashboard or if I connect my laptop directly to my Photon’s WiFi. I will make calculations on the data with a program on my laptop, either in real time, or after the fact.

What is the best way to transfer data like this? Is there a library available or what is the best cloud service? I have looked at the Particle dashboard and using Particle events, but that is not nearly fast enough for what I want to do.

Thanks in advance for any advice!


Any kind of TCP/IP connection is going to add latency, even on the local network. I think the smallest amount of latency would be to have the Photon send UDP packets to a program listening for them on your laptop – that way there’s no TCP or cloud overhead.

An alternative might be to log all the data to RAM, EEPROM, or an external Flash chip or SD card. That would remove any network overhead and let you capture as fast as possible, then you could transfer and process after the fact.


@potatotron Thanks for the quick response! Where could I go to learn more about a TCP/IP solution? I have never done any network or internet-connected applications before, so I am pretty new to all this.

Here’s some sample code using a Core to send to a Node.js server, hopefully that’s enough to get you started.


I would use SSE Tutorial: Getting Started with Spark.publish()

SSEs are rate limited to 1p/s, which is not nearly enough for a falling object.

1 Like

@cmbrooks here is example code to read udp packets in nodejs. This is currently what I worked out and use very successfully to read data sent from the core. The example code in the Simple UDP program breaks the core will work for sending of the data.

var dgram = require('dgram');
var udpServer = dgram.createSocket('udp4');

function processMonitorMsg(message) {
	// Your logic here to process the udp message

udpServer.on('message', function(message, remote) {


Hope this helps!!

Good Luck,

Sorry for the double post. Just a thought, if you don’t have to react to the data in a “live” fashion and if there was enough space on the photon you could save the data to an array on the photon and transmit after.


have it transmit once every x milliseconds whatever is buffered up via udp constantly. Then you could turn your listening program on when you needed to.

Hi @SomeFixItDude, i’m also interested in streaming stuff from and to my photon’s would you mind adding a small example showing how i can stream data over UDP on the Photon side?

Here is a small example that sends a udp packet to from the linked example.

UDP Udp;

unsigned char TxMsg[12] = { 1, 254, 1, 254, 1, 254, 43, 212, 71, 184, 3, 252 };

void setup() {

void loop() {
	if (WiFi.ready()) {
		Udp.beginPacket(IPAddress(10,0,0,3), 9000);
		// manipulate TxMsg array here
		// or put together your own array here
		Udp.write(TxMsg, 12);

Is that what you were looking for? I haven’t had a chance to pickup a photon yet but that should work just fine. I had some code where I was receiving data on the core but the udp problems with the (old) core prevented me from exploring it further. However, those problems are supposed to be resolved on the photon.


1 Like

So when i get you correct, data streaming does not mean you open a connection and send continue data over the Net, like how serial communication works?
Instead you send short package continue. Thanks

Thanks for all of the advice. It will take me a while to go through and try it all. From a quick glance, it looks like the recommendation for all of the code that would run on my laptop is Node.js. Is there a way to do it in other languages? I am most familiar with Java and C/C++.

hi Cmbrooks

You can use every language that you want on the laptop side. As long you have or can find a lib that can do streaming data as well.

That said, I’m still not sure what the differences are between streaming and sending normal package like commands etc.

@nielsnl Yeah under the covers everything really is broken up in to packets. You might find a cool library that would do the stream for you. I would try to search for RTP and arduino and see if anyone has a library for it. RTP uses udp packets that have a sequence number in the header which is pretty cool. The receiver has a buffer and you basically define how you want to handle missing packets. Skip, request, etc. You get the idea. If you do happen to go RTP and find a nice library or convert one please share.

Good Luck!

  • Brian