How to read a floating point


#1

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?


#2

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


#3

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);
  }
}

#4

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();
}
}


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

#6

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

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