Send Device ID in Webhook


I am working on a project involving multiple Electrons. The hope is to setup a custom database to store and graph sensor data coming from the electrons. At the moment, I have webhooks setup for each electron to send data to Thingspeak. I would like to start migrating data to my custom database, but i don’t want to have to create a new webhook for each device. One webhook, triggered with any of my devices, would be ideal, but I’m not sure how to sort the data based on which device its coming from. Is it possible to send the device ID of my electron with the webhook?


one way is to use one webhook for multiple devices using the Device ID as a responseTopic:

	"event": "current_weather",
	"url": "{{my-state}}/{{my-city}}.json",
	"requestType": "POST",
	"headers": null,
	"query": null,
	"responseTemplate": "{{#response}}{{#current_observation}}{{#estimated}}{{weather}}~{{temp_f}}~{{relative_humidity}}~{{wind_dir}}~{{wind_gust_mph}}~{{dewpoint_f}}~{{/estimated}}{{/current_observation}}{{/response}}",
	"responseTopic": "{{SPARK_CORE_ID}}_current_weather",
	"json": null,
	"auth": null,
	"coreid": null,
	"deviceid": null,
	"mydevices": true

and in setup():

  String deviceID = System.deviceID();
  Particle.subscribe(responseTopic, webhookHandler, MY_DEVICES);

and call it like this:

  Particle.publish("current_weather", publishString, 60, PRIVATE);

where publishString is defined in setup() as:

   sprintf(publishString, "{\"my-city\": \"%s\", \"my-state\": \"%s\" }", cityLocation, stateLocation);


SPARK_CORE_ID has been updated to PARTICLE_DEVICE_ID in the latest updates…