Particle Console to Google Cloud Firestore to Python


#1

Hi,

I’m trying to get temperature data from my Xenon into Python so I can plot it.
I’m publishing temperature data and can see it in the Particle Console.

So I set up a Google Cloud Platform Project and successfully added the integration between Particle & Google.

Here’s what I see in the Particle Console:

And here’s what I see in the Google Cloud Platform (Firestore):

On the RHS of the Firestore image you can see the “data” field, Hovering over this in Firestore tells me its a ‘blob’. Is this right? I thought I’d see my raw temperature data (float)?

I don’t know what I’m doing. I’ve read about blobs and I’m lost. My ultimate aim is to log temperature data “to the cloud” and be able to use Python to plot that over various time intervals, having the data backed up on the cloud.

At a guess the blanks in the hook-sent/Temperature field in the Particle Console is at the root of my problems. I had expected (with no idea if I’m right or not) to see my raw data in Firestore.

Any help would be much appreciated…

Thanks for your time,
RK.


#2

Hey RK79,

I was wondering how you connected your Xenon to Firestore? We are having problems figuring that out.

Thank you for the help.


#3

@RK79 i’m betting you’ve figured out your issue by now but for posterity, the issue is that the Google PubSub lib provides event data as a buffer (docs) but you want to store it as a string.

it’s simply a matter of converting it - for example:

const obj = {
	gc_pub_sub_id: message.id,
	device_id: message.attributes.device_id,
	event: message.attributes.event,
	published_at: message.attributes.published_at,
	data: message.data.toString('utf8'), // <-- now it's a string
	data_raw: message.data
}

and here’s what it looks like in Firestore:

you can see that the data field is stored as a string while data_raw is stored as a blob

sorry it took a bit to get you this info - hope it helps!