How to make a float variable for DHT11

Hello friends,

I am making a code for the DHT11. I have a problem with the code.

Every, I mean every, example is allways like this:

Serial.print((float)DHT11.temperature, 0);

What I am looking for, is to use it as a variable, like this:

float AnyVariable=(float)DHT11.temperature, 0;

Is this right, what I have just written ? And secondly: what is the numeric zero stands for ?

In a print statement, the 0 means "print zero digits after the decimal place". See the Arduino Serial.print reference page for more information.

In other contexts, it has other meanings.

float AnyVariable = DHT11.temperature;

is all you need.

2 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.