Unable to get Thingspeak to display multiple fields in a channel using webhook/web form

I have been struggling with the syntax required to send multiple fields from Particle to Thingspeak using Webhook and a Web Form.

The data is sent to Thingspeak with no errors, but no data is displayed.

My Publish string on the device is:

snprintf(_json, sizeof(_json), "{\"X\":%.0f,\"Y\":%.0f,\"Z\":%.0f\"}", aX, aY ,aZ);

on The Particle Web Hook, I map field 1 as: X > {{{X}}}, field 2 as: Y > {{{Y}}}, field 3 as Z > {{{Z}}}

In Thingspeak, my Field 1 Label is X, Field 2 Label is Y, Field 3 Label is Z

Let me know further info is required to assist, otherwise, what am I doing wrong?

Many thanks

Not sure if this helps, but you don’t need to use a webhook when using Thingspeak with Particle. Just, #include <ThingSpeak.h> will allow you to use read, write, etc. functions for Thingspeak.

HI @pitest,

Thanks for the reply;
Would this send the data directly to Thingspeak, thereby bypassing Particle, or would i still use a particle.publish in my firmware code and send via Thingspeak?

Looks like this will bypass Particle and talk directly to Thingspeak.
If i use this approach, I’m assuming I will still be able to OTA etc via the Particle interface?

Yes you will be ale to OTA with Particle. The extent that I have used Thingspeak with my projects, it removes a good deal of the hassle by not using a webhook.

A word about Thingspeak, if you are using the free personal license, it can only accept “data” every 15 seconds. If you have multiple devices sending data, that can end up eating up your number of messages to Thingspeak. I would recommend saving the data and only publishing it to Thingspeak every minute or so. However, this does differ from project to project.

Thanks for the intro to the thingspeak library - will definitely investigate.

Coming back to my webhook problem ;

The data is being accepted by thingspeak, but it’s just not interpreting the individual fields.

I have a suspicion I’m not populating the field mappings correctly on the Particle webhook config.
The lefthand field i assume is the corresponding fieldname in the thingspeak channel config.
My guess is I’m using the wrong directive in the righthand field…

Do you have your API_writeKey defined in your webhook for the particular channel you are writing to?
If not, or you want the ability to send to various channels, you will need to also send "k" for the channel's API Key in your Publish.

Here's an example:
See post #14 and the webhook definition below it.

Or you can use the ThingSpeak Library, as previously mentioned.

Problem found! In the Webhook config in Particle, I was changing the lefthand field contents to the label defined on Thingspeak for the corresponding field. This needs to be left as field1, field2 etc…
Changing it to anything else ‘breaks’ the mapping of the fields in Thingspeak.

However, thanks for the various input as along the way I learnt some new techniques.

Thanks all :slight_smile: