Legacy Platform Help Articles
Metadata
Send and
Metadata is a key:value set of data applied to every device using the same template. Unlinke Datastreams, this data stays mostly unchanged, however, if you need to read/write it, here is how to do it:

Get device Metadata

Device can request value of its own metadata from the cloud using the key (name) of Metadata.
Double check that you have a Metadata field with a correct name configured in the Device Template.
First you need to send a request to Blynk.Cloud
1
BLYNK_CONNECTED() {
2
// Send requests for different metadata
3
Blynk.sendInternal("meta", "get", "Serial Number");
4
Blynk.sendInternal("meta", "get", "Device Model");
5
}
Copied!
Then, parse the data stored in InternalPinMETA, which is a system pin to store metadata values.
1
BLYNK_WRITE(InternalPinMETA) {
2
String field = param[0].asStr();
3
if (field == "Serial Number") {
4
String value = param[1].asStr();
5
// Do something with Metadata value
6
} else if (field == "Device Model") {
7
String value = param[1].asStr();
8
// Do something with Metadata value
9
}
10
}
Copied!

Write device metadata

Device can update the value of the metadata using metadata key (name).
For example, if your devices stores Serial Number and Device Model internally, you can write this values to corresponding metadata fields.
1
sn_value = "123456789" //imaginary serial number
2
model_value = "RX-1-2789" // imaginary device model name
3
4
Blynk.sendInternal("meta", "set", "Serial Number", sn_value);
5
Blynk.sendInternal("meta", "set", "Device Model", model_value);
Copied!