# Stream data using Photon at each 10milisecond and upload to cloud

**URL:** <https://community.particle.io/t/stream-data-using-photon-at-each-10milisecond-and-upload-to-cloud/25165>\
**Category:** Getting Started\
**Created:** [August 16, 2016, 5:19am UTC](https://community.particle.io/t/stream-data-using-photon-at-each-10milisecond-and-upload-to-cloud/25165 "2016-08-16T05:19:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dakiwaki](https://avatars.discourse-cdn.com/v4/letter/d/ce7236/32.png) [@Dakiwaki](https://community.particle.io/u/Dakiwaki)\
**Post date:** [August 16, 2016, 5:19am UTC](https://community.particle.io/t/stream-data-using-photon-at-each-10milisecond-and-upload-to-cloud/25165/1 "2016-08-16T05:19:03Z")

</div>

I am trying to capture motion sensing data using Photon. As I want minor details of this motion since it happen so fast I would like to capture data at each 10miliseconds.

As I understand there is a head-loss in uploading data onto cloud system. So I want to work around this and capture data and stream them without missing action points. One way I thought; capture and store data in an array and then stream them after each second. Even thought it’s not realtime at least I won’t miss any points. If I could make this a realtime streaming that is the end goal.

Also how fast can Photon processor can capture accelerometer sensor value. Is it cloud put me impossible to make this realtime or is there another inherent issue that I am not aware of. Just curious ?

I highly appreciate your support on this. Seeing forward to your valuable insights.

---

<div class="post-metadata">

**Author:** ![Moors7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/moors7/32/588_2.png) [@Moors7](https://community.particle.io/u/Moors7)\
**Post date:** [August 16, 2016, 8:11am UTC](https://community.particle.io/t/stream-data-using-photon-at-each-10milisecond-and-upload-to-cloud/25165/2 "2016-08-16T08:11:15Z")

</div>

Have you seen this?

> [@Photon/node.js live streaming graph web page example](https://community.particle.io/t/photon-node-js-live-streaming-graph-web-page-example/22286):
>
> I got a request this morning for a tutorial/example of streaming data from a Photon to a local node.js server, and then graphing it on a web page. I thought that sounded interesting, so here it is. It’s currently sending a sample every 20 milliseconds (50 samples per second) though it can go faster than that. My demo has a potentiometer and when you adjust it, the graph updates in real time! Video: The node.js code has two parts: A HTTP web server that serves the html/css/Javascr…

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [August 16, 2016, 10:22am UTC](https://community.particle.io/t/stream-data-using-photon-at-each-10milisecond-and-upload-to-cloud/25165/3 "2016-08-16T10:22:48Z")

</div>

I’d think the bottle neck for capturing motion via consumer accelerometers are the sensors and not necessarily the Photon.  
What sensor are you looking at?  
Also what interface will you be using?  
If you get an analog output you could read the sensor in an timed interrupt making the data acquisition relatively independent of your other code.

---

<div class="post-metadata">

**Author:** ![rickkas7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/rickkas7/32/8681_2.png) [@rickkas7](https://community.particle.io/u/rickkas7)\
**Post date:** [August 16, 2016, 10:42am UTC](https://community.particle.io/t/stream-data-using-photon-at-each-10milisecond-and-upload-to-cloud/25165/4 "2016-08-16T10:42:14Z")

</div>

In this project, I was able to stream 200 12-bit XYZ samples per second from an ADXL362 accelerometer attached to a Photon with no difficulties. Like ScruffR said, you have to be careful with the accelerometer and driver. I wrote a custom SPI DMA driver that uses the ADXL362 queuing feature so it puts almost no load on the Photon and the samples are precisely timed, regardless of what the Photon is doing.

> [@Gathering continuous data at 200 Hz](https://community.particle.io/t/gathering-continuous-data-at-200-hz/23435/4):
>
> This got me thinking about how fast can you reasonably send sensor data off the Photon. To make a somewhat plausible proof-of-concept I connected an ADXL362 accelerometer to a Photon. It’s the sensor in the [Electron Sensor Kit] ([https://docs.particle.io/datasheets/particle-shields/#electron-sensor-kit](https://docs.particle.io/datasheets/particle-shields/#electron-sensor-kit)), but it’s just a basic SPI 12-bit X, Y, Z accelerometer. I set it up to acquire 200 samples per second to a local server. It worked! The accelerometer is programmed to gather the samp…

---

<div class="post-metadata">

**Author:** ![Dakiwaki](https://avatars.discourse-cdn.com/v4/letter/d/ce7236/32.png) [@Dakiwaki](https://community.particle.io/u/Dakiwaki)\
**Post date:** [August 17, 2016, 11:21am UTC](https://community.particle.io/t/stream-data-using-photon-at-each-10milisecond-and-upload-to-cloud/25165/5 "2016-08-17T11:21:51Z")

</div>

I’m using ADXL337 accelerometer. What I have done so far; used “[build.particle.io](http://build.particle.io)” online IDE host to program. In my program I basically capture (analog read) and use publish it in the logger. In that logger it only shows data at each second. Can I reduce this interval to 10mili seconds.

---

<div class="post-metadata">

**Author:** ![Moors7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/moors7/32/588_2.png) [@Moors7](https://community.particle.io/u/Moors7)\
**Post date:** [August 17, 2016, 11:28am UTC](https://community.particle.io/t/stream-data-using-photon-at-each-10milisecond-and-upload-to-cloud/25165/6 "2016-08-17T11:28:48Z")

</div>

> [@Dakiwaki](#):
>
> In my program I basically capture (analog read) and use publish it in the logger. In that logger it only shows data at each second.

Is that 'logger' by any chance '[console.particle.io](http://console.particle.io)'?  
If so, then 1p/s is the rate limit as described in the docs. If you need to go faster, you'll need to make a direct connection, as is described in the linked topics above.

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [August 17, 2016, 12:15pm UTC](https://community.particle.io/t/stream-data-using-photon-at-each-10milisecond-and-upload-to-cloud/25165/7 "2016-08-17T12:15:14Z")

</div>

> [@Dakiwaki](#):
>
> I basically capture (analog read)

In this case you could use the `SparkIntervalTimer` library to give you interrupts every _x_ milliseconds (actually _half milliseconds_ or _microseconds_) to do your readings and just push the data out from time to time without any (noticable) impact on your readings.

But we'd need to know _how_ you are pushing the data _where_ to.
