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.
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.