Read Metadata values of Location or Text

I have copied this code from documentation-
https://docs.blynk.io/en/blynk.edgent/api/metadata#write-device-metadata

I followed the steps to read the metadatas-
I was able to read numeric but unable to read string or location metadata values.
Thank you

Any idea on this, how to read the meta data ?

Please don’t keep tagging people, especially the Blynk staff, in post like this.

Have you tried the example in the documentation?
What results did you get?

Pete.

Please show your code and metadata setup.

Example code from documentations only.

That’s not very helpful!

Pete.

//
//// Fill-in information from your Blynk Template here
#define BLYNK_TEMPLATE_ID           "TMPLxxxxxx"
#define BLYNK_DEVICE_NAME           "Device"

#define BLYNK_FIRMWARE_VERSION        "0.1.0"

#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG

#define APP_DEBUG

// Uncomment your board, or configure a custom board in Settings.h
//#define USE_SPARKFUN_BLYNK_BOARD
//#define USE_NODE_MCU_BOARD
//#define USE_WITTY_CLOUD_BOARD

#include "BlynkEdgent.h"

void setup()
{
  Serial.begin(115200);
  delay(100);

  BlynkEdgent.begin();
}

void loop() {
  BlynkEdgent.run();
}
BLYNK_WRITE(InternalPinMETA) {
    String field = param[0].asStr();
Serial.println(field);
    if (field == "Location") {
        String value = param[1].asStr();

Serial.println(value);
        // Do something with Metadata value
    } 
}
BLYNK_CONNECTED() {
  // Send requests for different metadata
  Blynk.sendInternal("meta", "get", "Location");
//  Blynk.sendInternal("meta", "get", "Device Model");
}

Where is your screenshot showing the metadata you have set-up?

Pete.

Here is it.

I even tried changing meta name to location1 . Still not working

It seems that you have a Location metadata type called Location, and have added a Coordinates metadata type also called Location, which has no coordinate values in it.

Did you add some coordinates, and did you change your sketch to reflect the new name?

Pete.

Yes sir tried

if not possible,
tell m how t read it using http api

@VIGHNESHNS2008 do you have some data assigned to the location metafield of the specific device?Do you get some response at all? Or you get empty response?

yes assigned value.

empty response

@Dmitriy I’ve been doing a bit of testing, and ther seems to be an issue with coordinates…

Metadata setup:

Map Coordinates is populated as follows:

Test code…

BLYNK_CONNECTED()
{
  // Send requests for different metadata
  Blynk.sendInternal("meta", "get", "Board Type");
  Blynk.sendInternal("meta", "get", "Device Location");
  Blynk.sendInternal("meta", "get", "Map Coordinates");  
}

BLYNK_WRITE(InternalPinMETA) {
    String field = param[0].asStr();
    
    if (field == "Board Type")
    {
      String value = param[1].asStr();
      Serial.print("Board Type = ");
      Serial.println(value);
    }
    
    if (field == "Device Location")
    {
      String value = param[1].asStr();      
      Serial.print("Device Loaction = ");
      Serial.println(value);        
    }

    if (field == "Map Coordinates")
    {
      String value = param[1].asStr();      
      Serial.print("Map Coordinates = ");
      Serial.println(value);
    }
}

Serial Output…

[2652] Connecting to blynk.cloud:443
[3529] Certificate OK
[3540] Ready (ping: 10ms).

Board Type = ESP32 DevBoard
Device Loaction = The desk in my office
Map Coordinates = 

Note that Map Coordinates is blank (or 0.00 if I change to Float).

I also tried param[2].asStr() and param[3].asStr() in the hope that Latitude and Longitude were hidden in there, but no joy.

Also, when you view the Device metadata, the field names are capitalised…

image

which could get confusing.

Pete.

I tried writing values. Wks fine. but reading is a problem

Same Issue for Me

Yes. You’re right. Not all fields yet supported. I forgot about that. I’ll fix this.

1 Like

ok.
And… has that unexpeted error fixed?

@VIGHNESHNS2008 location meta reading should work now. Please check.

Yes. Do you still see any errors?