In this chapter we'll see how Cloud Variables make it easy to add cloud-based remote control and monitoring capabilities to your product.
A Cloud Variable is a piece of data that is stored in the cloud and is associated with a particular device.
Cloud Variables simplify the development of smart products by helping with:
In many ways, a Cloud Variable is like a traditional variable in a computer
program. Each Cloud Variable has a name, such as temperature
.
Each has a datatype, such as float32
. Each has a value, such
as 98.7
. Cloud Variables may be members of structures
(gps.latitude
), and the structures themselves are considered
Cloud Variables (gps
). You can create arrays of Cloud
Variables (cpu_level[3]
) as well as associative arrays
(weight['Johny']
).
In other ways, Cloud Variables are critically different from normal
programming variables. First of all, Cloud Variables are stored in a NoSQL
database and are accessed using RESTful web-based protocols. This makes
them several orders-of-magnitude slower than normal variables, but also
makes them persistent and accessible from anywhere in world (or at least
anywhere with an internet connection). A second difference is that the
historical values for each Cloud Variable are saved in the database and
kept for some time. This makes them well-suited for storing sensor data
and other time-series data. A third difference is that each Cloud Variable
has additional metadata associated with it that may include input
validation constraints (min-value : -50.0
), units
(units : "degrees_c"
) and hints about usage for
third-party applications (numeric-display-hint :
"scientific"
).
Canopy Cloud Variables are intended to be agnostic to programming language, IDE, and hardware platform. To achieve this, we embrace web technologies (such as HTTP, REST, WebSockets, and JSON) which are supported in nearly every programming language on practically every hardware platform.
The reality, however, is slightly murkier. Although you could use our HTTP REST API directly, doing so may involve a lot of code and may not have great performance. It is better to use a Native Client Library. The Native Client Libraries are easier to use and have better performance because they use WebSockets to communicate with the server.
At this time, we have official support for the following Native Client Libraries: