A minimal example showing how to get sensor data from a Particle device into Blynk, without any Blynk library on the device.
Particle device --Particle.publish(JSON)--> Particle Cloud --Webhook--> Blynk HTTP Data Converter
Every 30 seconds the device publishes a small JSON payload (dummy temperature/humidity readings) as a Particle Cloud event. A Particle webhook integration forwards that event to a Blynk HTTP Data Converter, which maps the JSON fields onto datastreams on your Blynk device.
Example payload:
{ "temperature": 24.3, "humidity": 55.1, "uptime": 120 }-
Blynk: create a Datastream and an HTTP Data Converter on your Blynk template/device, and copy the converter's URL.
-
Update
BLYNK_TEMPLATE_NAMEinsrc/Blynk-Particle-Example.cppto match your Blynk template - slugified (lowercase, hyphenated, e.g.hvac-monitorfor a template named "HVAC Monitor"). This is used to build the Particle event name, so it's easy to trace an event in the Particle console back to the Blynk template it feeds.Avoid names starting with
particleorspark- those prefixes are reserved for Particle's own system events (spark/status,particle/device/...), and events using them get silently dropped:Particle.publish()still returnstrueon the device, but the event never reaches your event stream in the Particle console. -
Particle: in the Particle console, go to Integrations > New Integration > Webhook and configure:
- Name: your Blynk Template name (e.g.
blynk-particle-example) - Event Name:
<BLYNK_TEMPLATE_NAME>/data(e.g.blynk-particle-example/data) - URL: the Blynk HTTP Data Converter URL from step 1
- Leave everything else at its default.
The key thing is the event name must match what the firmware is using in the
Particle.publish().
- Name: your Blynk Template name (e.g.
-
Flash
src/Blynk-Particle-Example.cppto your device (any Wi-Fi or cellular Particle device works - updateparticle.targetPlatformin.vscode/settings.jsonif you're not using an Argon). -
Watch the values arrive in Blynk.
This is the complete code for the Blynk HTTP Data Convertor
function initialize(context) {
const { handler } = context;
handler.useAuthMetaField("ParticleDeviceId")
}
function handleRequest(context) {
const { request, server } = context;
const { uri, headers, body, isSecure } = request;
// Parse incoming JSON payload
const bodyJson = JSON.parse(new TextDecoder().decode(body));
// Authenticate the device
const device = server.authenticateDevice(bodyJson.coreid);
// Set all the datastreams from the data
const data = JSON.parse(bodyJson.data);
for (const [key, value] of Object.entries(data)) {
device.setDataStreamValue(key, value);
}
return { status: 200, body: 'Datastreams updated' };
}
Replace the random() calls in publishSensorData() with real sensor
readings, and add any extra fields to the JSON payload and to the webhook
mapping in Blynk.