Sending Array from Photon to Pi


I have been trying to send an array of numbers from the Particle Photon device to the Raspberry Pi. I was trying out the particle function, but it only seems to return an integer.

What are other alternatives?
I was thinking of using particle.variable where I can append all the integers in the array together separated by commas to create one giant string and then putting that into particle.variable. The raspberry pi could then call once a minute or so to get the particle.variable and decode the string array.


Particle.publish() would be the way to push data to the RPi.
The RPi can subscribe to this SSE (e.g. via particle subscribe)

Where can I find an example of subscribing a pi to the particle cloud? I seem to only find examples of installing the particle agent onto the pi and controlling a led. But nothing much about subscribing a pi to the cloud.

When you install CLI on the RPi you can use the command I mentioned above.

You could also use the JavaScript SDK to subscribe to an event stream.
SSE is nothing specific to Particle but a common technique you can virtually use with any programming or script language.

1 Like

So I see my pi printing out all the events. I guess that every time I want my Pi to subscribe to the cloud, I would need my python code to type into the terminal the particle subscribe command and then have a function in my code to subscribe to the event stream.

try this one

from sseclient import SSEClient
import json

devID = "xxx_your_dev_id_here"
AToken = "xxx_your_token_here"

particleURL = '' + devID + '/events/?access_token=' + AToken

messages = SSEClient(particleURL)

for msg in messages:
    outputMsg =
    if type(outputMsg) is not str:
        outputJS = json.loads(outputMsg)
        FilterName = "data"

this example is in Python 3 and original idea comes from here



This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.