How to read a floating point

Hello,
I can’t find the function for read real numbers. :frowning:
I read integer:

CAYENNE_IN(1)
{
x=getValue.asInt();
}

I have no idea, how read the floating point number. Could you help me?

@shramik_salgaonkar or @tad.dvor might be able to help here :slight_smile:

Try this:

CAYENNE_IN(1)
{
  CAYENNE_LOG("CAYENNE_IN_DEFAULT(%u) - %s, %s", request.channel, getValue.getId(), getValue.asString());
  if (request.channel = 1)
  {
  
    String value0;
    value0 = (String)getValue.asString();

    Serial.println(value0);
  }
}
1 Like

Thank you very much! I add conversion string to float and work very well :slight_smile:

CAYENNE_IN(1)
{
CAYENNE_LOG(“CAYENNE_IN_DEFAULT(%u) - %s, %s”, request.channel, getValue.getId(), getValue.asString());
if (request.channel = 1)
{

String value0;
value0 = (String)getValue.asString();

x=value0.toFloat();
}
}

1 Like
CAYENNE_IN(1)
{
float x=getValue.asDouble();
}
4 Likes

CAYENNE_IN(1)
{
float x=getValue.asDouble();
}

Great!
@shramik_salgaonkar, thank you, it works well! :slight_smile:

2 Likes