Posting to field2 in thingspeak

Using the integration tool and a webhook in the console, I have successfully connected to thingspeak using field1. However if I try to post to field2 there is no data posted. Does anyone know the problem?

Is your webhook similar to this?

Make sure Field #2 is active (check box) in the Channel Settings of ThingSpeak.Com

Post your Code here if you still have trouble.

My code is simple as this is just a trial. field2 is checked in ThingSpeak. I was trying to publish “humidity” to field2 within the ThingSpeak channel. I can do it successfully when I create a separate channel for humidity and use field1. However if I try to post to a channel (that posts temperature data for field1) and use field2, the data doesn’t appear. On the webhooks integration tool, I simply substitute field2 for field1 and create another web integration but there is no data.

Here is the code.

#include "Adafruit_DHT/Adafruit_DHT.h"

#define DHTPIN 5
#define DHTTYPE DHT11
int temperature;
int humidity;


void setup() {

void loop() {
    temperature = dht.getTempCelcius();
    humidity = dht.getHumidity();
    Particle.publish("humidity", String(humidity));

This is over my head… I have no idea how you got this to work w/ ThingSpeak without sending your API key.

I entered the API key in the console -> integration -> webhooks menu not from the code itself.

So, I finally got the webhook to work. I increased the delay from 10 to 60 seconds between the temperature and humidity readings.

Thanks for responding.


I think the problem is Particle throttling events, so only one of the webhooks is activated if two Publish events occur too close together. However, you CAN send multiple data items using one webhook and one call to Particle.Publish().

In the Particle Console, in the webhook definition, presuming you followed the ThingSpeak example, in the forms section you should see:
“api_key”: “your_ThingSpeak_API_Key”,
“field1”: “{{PARTICLE_EVENT_VALUE}}”

The {{PARTICLE_EVENT_VALUE}} is the event value Particle automatically fills in, but there’s only one of those. So EDIT the form (bottom of page) click on Advanced Settings and make sure the third radio button is selected (the Form button).

api_key should be the first row - leave it.

The second row should contain field1 and {{PARTICLE_EVENT_VALUE}}.
Replace the "{{PARTICLE_EVENT_VALUE}} with {{field1Val}}
then click the add row button and enter field2 in the left hand box, and {{field2Val}} in the right hand side. (I assume your ThingSpeak fields are indeed field1 and field2).

Save that, and in the summary it should now show:
“api_key”: “your_ThingSpeak_API_Key”,
“field1”: “{{field1Val}}”,
“field2”: “{{field2Val}}”

Then, in your program, to send both values in one publish call, you need to send a JSON string using field1Val and field2Val as identifiers, along with the relevant values as quoted strings- I used snprint to send a float and an int in JSONbuffer, a cstring:

snprintf(JSONbuffer, sizeof(JSONbuffer),{“field1Val”:"%f",“field2Val”:"%i"}\n",floatvalue,intvalue);

This worked for me- good luck. Others have written extensive analysis about Mustache templates, specifically rickkas7 whose Webhook Tutorial led me to this solution. Webhook intermediate tutorial