From f9c42f792643317361f44a6683d8d09ab83328f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Fri, 13 May 2022 10:44:48 +0200 Subject: [PATCH 1/4] cloud color --- .../iot-cloud-tech-ref.md | 119 ++++++++++-------- 1 file changed, 65 insertions(+), 54 deletions(-) diff --git a/content/cloud/iot-cloud/tutorials/02.technical-reference/iot-cloud-tech-ref.md b/content/cloud/iot-cloud/tutorials/02.technical-reference/iot-cloud-tech-ref.md index 6de0ccce1f..8cb2c4ab33 100644 --- a/content/cloud/iot-cloud/tutorials/02.technical-reference/iot-cloud-tech-ref.md +++ b/content/cloud/iot-cloud/tutorials/02.technical-reference/iot-cloud-tech-ref.md @@ -192,44 +192,44 @@ For your convenience, IoT Cloud provides specialized types which are just wrappe You can use them just like a normal variable of the wrapped type, since they support assignment and comparison operators. | Type | Declaration | Wrapped data type | -| -------------------- | ---------------------------------------- | ------- | -| Acceleration | `CloudAcceleration variableName;` | `float` | -| Angle | `CloudAngle variableName;` | `float` | -| Area | `CloudArea variableName;` | `float` | -| Capacitance | `CloudCapacitance variableName;` | `float` | -| Color | `CloudColor variableName;` | `float` | -| Contact Sensor | `CloudContactSensor variableName;` | `bool` | -| Counter | `CloudCounter variableName;` | `int` | -| Data Rate | `CloudDataRate variableName;` | `float` | -| Electric Current | `CloudElectricCurrent variableName;` | `float` | -| Electric Potention | `CloudElectricPotention variableName;` | `float` | -| Electric Resistance | `CloudElectricResistance variableName;` | `float` | -| Energy | `CloudEnergy variableName;` | `float` | -| Flow Rate | `CloudFlowRate variableName;` | `float` | -| Force | `CloudForce variableName;` | `float` | -| Frequency | `CloudFrequency variableName;` | `float` | -| Heart Rate | `CloudHeartRate variableName;` | `float` | -| Information Content | `CloudInformationContent variableName;` | `int` | -| Length | `CloudLength variableName;` | `float` | -| Light | `CloudLight variableName;` | `bool` | -| Location | `CloudLocation variableName;` | `float` | -| Logarithmic Quantity | `CloudLogarithmicQuantity variableName;` | `float` | -| Luminance | `CloudLuminance variableName;` | `float` | -| Luminous Flux | `CloudLuminousFlux variableName;` | `float` | -| Luminous Intensity | `CloudLuminousIntensity variableName;` | `float` | -| Mass | `CloudMass variableName;` | `float` | -| Motion Sensor | `CloudMotionSensor variableName;` | `bool` | -| Percentage | `CloudPercentage variableName;` | `float` | -| Power | `CloudPower variableName;` | `float` | -| Pressure | `CloudPressure variableName;` | `float` | -| Relative Humidity | `CloudRelativeHumidity variableName;` | `float` | -| Smart Plug | `CloudSmartPlug variableName;` | `bool` | -| Switch | `CloudSwitch variableName;` | `bool` | -| CloudTemperature | `CloudTemperature variableName;` | `float` | -| Temperature Sensor | `CloudTemperatureSensor variableName;` | `float` | -| Time | `CloudTime variableName;` | `float` | -| Velocity | `CloudVelocity variableName;` | `float` | -| Volume | `CloudVolume variableName;` | `float` | +| -------------------- | ---------------------------------------- | ----------------- | +| Acceleration | `CloudAcceleration variableName;` | `float` | +| Angle | `CloudAngle variableName;` | `float` | +| Area | `CloudArea variableName;` | `float` | +| Capacitance | `CloudCapacitance variableName;` | `float` | +| Color | `CloudColor variableName;` | `float` | +| Contact Sensor | `CloudContactSensor variableName;` | `bool` | +| Counter | `CloudCounter variableName;` | `int` | +| Data Rate | `CloudDataRate variableName;` | `float` | +| Electric Current | `CloudElectricCurrent variableName;` | `float` | +| Electric Potention | `CloudElectricPotention variableName;` | `float` | +| Electric Resistance | `CloudElectricResistance variableName;` | `float` | +| Energy | `CloudEnergy variableName;` | `float` | +| Flow Rate | `CloudFlowRate variableName;` | `float` | +| Force | `CloudForce variableName;` | `float` | +| Frequency | `CloudFrequency variableName;` | `float` | +| Heart Rate | `CloudHeartRate variableName;` | `float` | +| Information Content | `CloudInformationContent variableName;` | `int` | +| Length | `CloudLength variableName;` | `float` | +| Light | `CloudLight variableName;` | `bool` | +| Location | `CloudLocation variableName;` | `float` | +| Logarithmic Quantity | `CloudLogarithmicQuantity variableName;` | `float` | +| Luminance | `CloudLuminance variableName;` | `float` | +| Luminous Flux | `CloudLuminousFlux variableName;` | `float` | +| Luminous Intensity | `CloudLuminousIntensity variableName;` | `float` | +| Mass | `CloudMass variableName;` | `float` | +| Motion Sensor | `CloudMotionSensor variableName;` | `bool` | +| Percentage | `CloudPercentage variableName;` | `float` | +| Power | `CloudPower variableName;` | `float` | +| Pressure | `CloudPressure variableName;` | `float` | +| Relative Humidity | `CloudRelativeHumidity variableName;` | `float` | +| Smart Plug | `CloudSmartPlug variableName;` | `bool` | +| Switch | `CloudSwitch variableName;` | `bool` | +| CloudTemperature | `CloudTemperature variableName;` | `float` | +| Temperature Sensor | `CloudTemperatureSensor variableName;` | `float` | +| Time | `CloudTime variableName;` | `float` | +| Velocity | `CloudVelocity variableName;` | `float` | +| Volume | `CloudVolume variableName;` | `float` | ### Complex Types @@ -249,18 +249,29 @@ Declared as `CloudDimmedLight x;` Declared as `CloudColoredLight x;` -| Property | Type | Read value | Set value | -| ----------| -------------------| -------------------------------| ------------------------------| -| Switch | `bool` | `x.getSwitch()` | `x.setSwitch()` | -| Hue | `float` (0-360) | `x.getHue()` | `x.setHue()` | -| Saturation| `float` (0-100) | `x.getSaturation()` | `x.setSaturation()` | -| Brightness| `float` (0-100) | `x.getBrightness()` | `x.setBrightness()` | +| Property | Type | Read value | Set value | +| ---------- | --------------- | ------------------- | ------------------- | +| Switch | `bool` | `x.getSwitch()` | `x.setSwitch()` | +| Hue | `float` (0-360) | `x.getHue()` | `x.setHue()` | +| Saturation | `float` (0-100) | `x.getSaturation()` | `x.setSaturation()` | +| Brightness | `float` (0-100) | `x.getBrightness()` | `x.setBrightness()` | #### CloudColor -Declared as `CloudColor x;` +Declared as `CloudColor x;`. + +To read the Color values, we can use the following method `Color colorValues = x.getValue();`. This will assign the hue, saturation, and brightness values to the `colorValues` variable. + +| Property | Type | Read value | Set value | +| ---------- | ---- | ----------------- | -------------------------------------- | +| Hue | | `colorValues.hue` | `x = Color(hue,saturation,brightness)` | +| Saturation | | `colorValues.sat` | `x = Color(hue,saturation,brightness)` | +| Brightness | | `colorValues.bri` | `x = Color(hue,saturation,brightness)` | + + + -To read the Color values, we can use the following method `Color colorValues = x.getValue();`. This will assign the hue, saturation, and brightness values to the colorValues variable. If we want too access the values individually we can use `Serial.println(colorValues.hue)`, `Serial.println(colorValues.sat)`, and `Serial.println(colorValues.bri)`. +To read the Color values, we can use the following method `Color colorValues = x.getValue();`. This will assign the hue, saturation, and brightness values to the `colorValues` variable. If we want too access the values individually we can use `Serial.println(colorValues.hue)`, `Serial.println(colorValues.sat)`, and `Serial.println(colorValues.bri)`. To set the color, we can assign the CloudColor variable directly to float variables `x = {hue,saturation,brightness}`, or using the method ` x = Color(hue,saturation,brightness)`. @@ -276,14 +287,14 @@ To set the coordinates, we can assign the CloudLocation variable directly to flo Declared as `CloudTelevision x;` -| Property | Type | Read Value | Set value | -| -----------------| ---------------------------------------------------------------------------------------| -------------------------| -------------------------| -| Switch | `bool` | `x.getSwitch()` | `x.setSwitch()` | -| Volume | `int`(0-100) | `x.getVolume()` | `x.setVolume()` | -| Mute | `bool` | `x.getMute()` | `x.setMute()` | -| PlaybackCommands | `PlaybackCommands` (FastForward, Next, Pause, Play, Previous, Rewind, StartOver, Stop) | `x.getPlaybackCommand()` | `x.setPlaybackCommand()` | -| Input | `InputValue` ([Up to 60 values](https://github.com/arduino-libraries/ArduinoIoTCloud/blob/master/src/property/types/automation/CloudTelevision.h) such as HDMI1, HDMI2, DVD, GAME...etc.) | `x.getInput()` | `x.setInput()` | -| Channel | `int` | `x.getChannel()` | `x.setChannel()` | +| Property | Type | Read Value | Set value | +| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------ | ------------------------ | +| Switch | `bool` | `x.getSwitch()` | `x.setSwitch()` | +| Volume | `int`(0-100) | `x.getVolume()` | `x.setVolume()` | +| Mute | `bool` | `x.getMute()` | `x.setMute()` | +| PlaybackCommands | `PlaybackCommands` (FastForward, Next, Pause, Play, Previous, Rewind, StartOver, Stop) | `x.getPlaybackCommand()` | `x.setPlaybackCommand()` | +| Input | `InputValue` ([Up to 60 values](https://github.com/arduino-libraries/ArduinoIoTCloud/blob/master/src/property/types/automation/CloudTelevision.h) such as HDMI1, HDMI2, DVD, GAME...etc.) | `x.getInput()` | `x.setInput()` | +| Channel | `int` | `x.getChannel()` | `x.setChannel()` | ### Examples From c2e52cb977da509acd858537412c309e80e967cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Fri, 13 May 2022 13:53:36 +0200 Subject: [PATCH 2/4] added utilities --- .../iot-cloud-tech-ref.md | 53 ++++++++++++++----- 1 file changed, 40 insertions(+), 13 deletions(-) diff --git a/content/cloud/iot-cloud/tutorials/02.technical-reference/iot-cloud-tech-ref.md b/content/cloud/iot-cloud/tutorials/02.technical-reference/iot-cloud-tech-ref.md index 8cb2c4ab33..e0648f311f 100644 --- a/content/cloud/iot-cloud/tutorials/02.technical-reference/iot-cloud-tech-ref.md +++ b/content/cloud/iot-cloud/tutorials/02.technical-reference/iot-cloud-tech-ref.md @@ -262,26 +262,24 @@ Declared as `CloudColor x;`. To read the Color values, we can use the following method `Color colorValues = x.getValue();`. This will assign the hue, saturation, and brightness values to the `colorValues` variable. -| Property | Type | Read value | Set value | -| ---------- | ---- | ----------------- | -------------------------------------- | -| Hue | | `colorValues.hue` | `x = Color(hue,saturation,brightness)` | -| Saturation | | `colorValues.sat` | `x = Color(hue,saturation,brightness)` | -| Brightness | | `colorValues.bri` | `x = Color(hue,saturation,brightness)` | - - - - -To read the Color values, we can use the following method `Color colorValues = x.getValue();`. This will assign the hue, saturation, and brightness values to the `colorValues` variable. If we want too access the values individually we can use `Serial.println(colorValues.hue)`, `Serial.println(colorValues.sat)`, and `Serial.println(colorValues.bri)`. +| Property | Type | Read value | Set value | +| ---------- | ------- | ----------------- | -------------------------------------- | +| Hue | `float` | `colorValues.hue` | `x = Color(hue,saturation,brightness)` | +| Saturation | `float` | `colorValues.sat` | `x = Color(hue,saturation,brightness)` | +| Brightness | `float` | `colorValues.bri` | `x = Color(hue,saturation,brightness)` | To set the color, we can assign the CloudColor variable directly to float variables `x = {hue,saturation,brightness}`, or using the method ` x = Color(hue,saturation,brightness)`. #### CloudLocation -Declared as `CloudLocation x;` +Declared as `CloudLocation x;`. -To read the location values, we can use the following method `Location coordinates = x.getValue();`. This will assign the longitude and latitude values to the coordinates variable. If we want too access the values individually we can use `Serial.println(coordinates.lat)` and `Serial.println(coordinates.lat)`. +To read the location values, we can use the following method `Location coordinates = x.getValue();`. This will assign the longitude and latitude values to the coordinates variable. If we want too access the values individually we can use `Serial.println(coordinates.lat)` and `Serial.println(coordinates.lot)`. -To set the coordinates, we can assign the CloudLocation variable directly to float variables `x = {latitude, longitude}`, or using the method ` x = Location(latitude, longitude)`. +| Property | Type | Read value | Set value | +| --------- | ------- | ----------------- | --------------------------- | +| Latitude | `float` | `coordinates.lat` | This variable is ready only | +| Longitude | `float` | `coordinates.lon` | This variable is ready only | #### Television @@ -297,6 +295,35 @@ Declared as `CloudTelevision x;` | Channel | `int` | `x.getChannel()` | `x.setChannel()` | +### Utilities + +The following utilities are available using any IoT Cloud sketch. + +#### Check Connection Status + +To check connection to the cloud, use: + +```arduino +ArduinoCloud.connected() +``` + +This will return in an `int` format: +- `0` (not connected) +- `1` (connected). + +#### Get Local Time (Unix) + +To check local time, use: + +```arduino +ArduinoCloud.getLocalTime() +``` + +This will return in a `long` format: +- Epoch Unix time stamp. Example: `1652442415`. + +***This utility can be used together with the `CloudTime` variable and the `Time Picker` widget.*** + ### Examples Here are some examples of how to use the variables in a sketch: From 5a3c7fd7c35cb6523fb6612bc5fa6db49af66acf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Fri, 13 May 2022 13:55:23 +0200 Subject: [PATCH 3/4] Update iot-cloud-tech-ref.md --- .../tutorials/02.technical-reference/iot-cloud-tech-ref.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/cloud/iot-cloud/tutorials/02.technical-reference/iot-cloud-tech-ref.md b/content/cloud/iot-cloud/tutorials/02.technical-reference/iot-cloud-tech-ref.md index e0648f311f..31fdf1d7de 100644 --- a/content/cloud/iot-cloud/tutorials/02.technical-reference/iot-cloud-tech-ref.md +++ b/content/cloud/iot-cloud/tutorials/02.technical-reference/iot-cloud-tech-ref.md @@ -274,7 +274,7 @@ To set the color, we can assign the CloudColor variable directly to float variab Declared as `CloudLocation x;`. -To read the location values, we can use the following method `Location coordinates = x.getValue();`. This will assign the longitude and latitude values to the coordinates variable. If we want too access the values individually we can use `Serial.println(coordinates.lat)` and `Serial.println(coordinates.lot)`. +To read the location values, we can use the following method `Location coordinates = x.getValue();`. This will assign the longitude and latitude values to the coordinates variable. If we want too access the values individually we can use `Serial.println(coordinates.lat)` and `Serial.println(coordinates.lon)`. | Property | Type | Read value | Set value | | --------- | ------- | ----------------- | --------------------------- | From 9f7823a45f15775f1507599c5eec675645ef4bd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Fri, 13 May 2022 17:00:56 +0200 Subject: [PATCH 4/4] Update iot-cloud-tech-ref.md --- .../tutorials/02.technical-reference/iot-cloud-tech-ref.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/content/cloud/iot-cloud/tutorials/02.technical-reference/iot-cloud-tech-ref.md b/content/cloud/iot-cloud/tutorials/02.technical-reference/iot-cloud-tech-ref.md index 31fdf1d7de..e9b2b1b88f 100644 --- a/content/cloud/iot-cloud/tutorials/02.technical-reference/iot-cloud-tech-ref.md +++ b/content/cloud/iot-cloud/tutorials/02.technical-reference/iot-cloud-tech-ref.md @@ -281,6 +281,8 @@ To read the location values, we can use the following method `Location coordinat | Latitude | `float` | `coordinates.lat` | This variable is ready only | | Longitude | `float` | `coordinates.lon` | This variable is ready only | +***The format of the `lat` and `lon` is in Decimal Degrees (DD), for example `41.40338`, `2.17403`.*** + #### Television Declared as `CloudTelevision x;`