webhook/Particle.publish: sending two variables to Thingspeak not working

I am trying to post two variables to the Thingspeak console. I started with the tutorial on webhook (https://docs.particle.io/tutorials/device-cloud/webhooks/#your-first-webhook)

and made the following changes:

  1. on Thingsspeak created a channel “test” with two fields

  2. On Particle console, created a webhook with two fields:

  3. my code is sending to the webhook:

  1. I can see it sending to Particle console:

I expect to see the two graphs one at 60 and one at 80, but nothing shows.

what am I doing wrong? Any help appreciated!


You don’t link {{{PARTICLE_EVENT_VALUE}}} to the individual fields but their respective key names ({{{Field1}}} and {{{Field2}}}).
(it might be required to wrap the number literals into double quotes too)

The way you did it would cram the entire event value string into both fields resulting in none of them being parsable.

If I understand correctly, keep only one event field on the Particle console. Would you have an example of how I can modify the Particle publish to correctly parse two keys?

Particle.publish(“test”, “{“Field1”:60,“Field2”:80}”,PRIVATE);

Have you tried my suggestion?
{{{Field1}}} and {{{Field2}}}

Take a look at this post, for sending 2 values to ThingSpeak.

The WebHook Definition handles "up-to" all 8 ThingSpeak Fields from each publish.
The common use case (for myself anyway) is to send the ThingSpeak API Write key with every publish.
That way, you will only need 1 webhook to send data to any of your ThingSpeak Channels.

Or you can save the API Write Key inside each Webhook Definition (as it appears you are doing now) and not publish the API Write Key each time, but you will need a separate Webhook for every channel with that method.

1 Like

I tried the starter code and it works. I got the hang of it. Thank you both for your help.