I have a SHT30 sensor for Wemos and I am learning to use Arduino IOT Cloud.

I use float data type for my temperature variable but I see two more data types:



What are the differences? Shouldn't use float?

enter image description here

1 Answer 1


From the technical reference for the Arduino Cloud on arduino.cc:

For your convenience, IoT Cloud provides specialized types which are just wrappers around basic types but declare the variable semantics more explicitly. This enables smarter integrations with third-party services (such as Alexa) and better visualization of widgets in dashboards.

You can use them just like a normal variable of the wrapped type, since they support assignment and comparison operators.

These types are actually wrapper classes, which add some functionality to better integrate in cloud services. You can use these just as the normal data types.

You can even look at how they are defined. Let's look at CloudTemperature for example. All the files can be found in the ArduinoIoTCloud repo on github.

The types are defined in the PropertyContainer.h file:

#include "types/CloudFloat.h"
typedef CloudFloat CloudTemperature;

So CloudTemperature is actually just CloudFloat, which is included from the corresponding header file. When we look at the CloudFloat.h file we find:

class CloudFloat : public Property {
    float _value,

So internally CloudFloat is just a float value with added functionality. And you can use it like any other float, since below that part that I've shown here all the operators (like /, *, +, ...) are overwritten (so the class knows what to do with these operators).

CloudTemperatureSensor is found at CloudTemperatureSensor.h and inherits from CloudFloat so works basically the same way (it only overwrites the assignment operator; the rest is the same as CloudFloat).

Shouldn't use float?

I haven't tried that myself. But from the documentation it sounds like there is no reason to not use the specialized types, since they provide the same functionality and more.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.