ThingSpeak Integration.


#1

As someone just getting into this area I’m pretty lost in trying to get my data sent over to ThingSpeak. Going through some of the earlier posts I think I need to put this:

https://api.thingspeak.com/update?api_key=YOURAPIKEY<>

for the destination URL

NONE

for Payload for POST

and no idea what to use for headers or if I need the auth header.

Here’s the data as it’s coming in:

Pi:83.3F / Vent:78.3F / Ambient:77.5F / EnclT:77.0F / EnclH:29.0% / DI-1: ON

which I can obviously reformat if required. Currently I’m just having that sent out as email and SMS.
And help or links to good documentation would be greatly appreciated.


#2

I send data to thingspeak from my own server (a route on Hologram calls the php script) using:

https://api.thingspeak.com/update?api_key=APIKEY&field1=$temp&field2=$volts

From my playing with thingspeak it wants stuff coming in as fields, you then set up what each field means on your channel.

So if you’re trying to set up a route then on your dash/whatever you’d construct the outgoing message as JSON.

 HologramCloud.print("{ \"p\":");
 HologramCloud.print(Pi);      // i.e. the variable with 83.3 in it
 HologramCloud.print(", \"v\":");
 HologramCloud.print(Vent);  // 78.3
 HologramCloud.print(", \"a\":");
 HologramCloud.print(Ambient);  // 77.5
 HologramCloud.print(",\"e\":");
 HologramCloud.print(EnclT);   // 29.0
 HologramCloud.print(",\"d\":");
 HologramCloud.print(DI);     // 0 or 1
 HologramCloud.print("}");
 HologramCloud.attachTag("TS"); // whatever your topic is
 HologramCloud.sendMessage();
 HologramCloud.clear();

That should result in JSON (just use numbers, not 83.3F) that looks like:

{"p":83.3, "v":78.3, "a":77.5, "e":29.0, "d":1}

Then in your route with a “TS” topic the destination URL could look like:

https://api.thingspeak.com/update?api_key=APIKEY&field1=<<decdata.p>>&field2=<<decdata.v>>&field3=<<decdata.a>>&field4=<<decdata.e>>&field5=<<decdata.d>>

There’s surely other ways to do this, but that’s what comes to mind.


Route Setup to Pushbullet.com
#3

More noob questions, but I try this and get a syntax error. I’m trying this with a Raspberry pi running Python 3. Should it work as written there or do I need to reformat?

Thanks.


#4

Nevermind, I was able to parse it out. Thanks for the blueprint though! Got it working.


#5

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