How the App works

How it works

    • As the counterpart to this App an IoT-Device must be used at your place. This IoT-Device collects the sensor data an sends them to the Azure Cloud in exactly the format expected by this App. This App graphically displays sensor data which are stored in the Cloud in Azure Storage Tables on iPhone and iPad. There may be hundreds of different types of data and hundreds of different ways how these data can be graphically displayed on a screen.
    Apparently there can be no: ‘One size fits all’. So this App has constraints in relation to ‘what can be displayed’ and ‘how it can be displayed’.

What is displayed and how:

      • One Page displays the values of one day in the form of:

      • Up to 4 line graphs for analog values of 4 different sensors with values in a range of -40.0 to 140.0 (e.g. for temperature measurements).
      • Up to 4 On/Off graphs to display values which can only have two different states (e.g. heater is on or off).
      • The day to be shown can be selected.
      • Concerning the On/Off graphs, data can additionally be shown numerically, thus showing the over all On-Time, optionally multiplied with factors for Units/time and Price/Unit.
      • There can be several profiles in which values of different sensor can be selected.

Why Azure Storage Table service:

      • Because I tried it and it proved to be good.
      • Because it’s cheap (For e.g. one set of data every ten minutes and with actual price I rarely had to pay more than 10 Cents per month)
      • Because you can either use http or https to transport the data.
      • Because the protocol provides measures to ensure data integrity.
      • Because Microsoft provides libraries for different languages and platforms.

Some words about Azure Storage Table Service:

      • To use Azure you must have an Azure Account (free trial Account available).
      • On the Azure Portal, you must create an Azure Storage Account to hold your Data.
      • In your Storage Table Account you can create Tables.
      • In these Tables you put Rows (Entities) of Data.
      • An Entity consists of a PartitionKey and a RowKey (combination of both must be unique in a table) and the payload which contains some Key/Value pairs of Column-Names (properties) and their associated Data value.
      • To view and manipulate your tables you can use the free Microsoft Tool: ‘Azure Storage Explorer’ or on iOS mobile devices my App ‘AzureTabStorClient’.

Produce populated Sample Tables with the ‘Charts4Azure’ App:

      • It sounds comlicated to obey all the rules which are needed to create correctly formatted Cloud Tables.
      • So the easiest way to get some proper example tables is creating them automatically with this ‘Charts4Azure’ App:
      • ….Open the App and before pressing the Button ‘Start’ go to the ‘Settings’ Page.
      • ….Press the ‘Select Account’ Button.
      • ….Enter the name of your Azure Storage Account and the Storage Key, which you got from the Azure Portal when you created the Storage Account.
      • ….Press the ‘Add Credentials’ Button. (Now your App will automatically use the correct Credentials to access your Storage Account)
      • ….Press the ‘Change Setting’ Button on the ‘Settings’ Page.
      • ….Press the ‘Create Sample Tables’ Button, confirm with OK and wait until the Tables are created.
      • ….Navigate to the ‘Graphs’ Page, click ‘Start’ and see the created Charts with Sinus curves and On/Off Tables.
      • ….Now use the free Tool ‘Microsoft Azure Storage Explorer’ to inspect the created Tables in the Azure Cloud.

Which Tables have to be created:
The Tables will be automatically created by your IoT-Devices which will send the data to the Cloud. However, you should know:

      • Tablenames may only contain alphanumeric characters (A-Z, a-z, 0-9)
      • You need one Table for the analog data of 4 Sensors (e.g. Tablename: ‘House’) Note: avoid the name ‘AnalogTable’ which is used for Samples.
      • You need up to 4 Tables for On/Off values (e.g. Tablenames: ‘Burner’, ‘Boiler’, ‘Light’, ‘Solar’
      • It is recommended to add the actual year as a suffix to each tablename. So e.g. in 2018 you will have the tables: House2018, Heater2018, Boiler2018, Light2018, Solar2018.

What must be be obeyed concerning PartitionKey and RowKey:
If you view Azure Storage Tables with ‘Azure Storage Explorer’ or ‘AzureTabStorClient’, usually you want to see the last added row upmost and the older rows in declining order sorted by date below.
Azure orders the rows according to the content of PartitionKey and RowKey.
To have the rows ordered as outlined above, you can assign the PartitionKey and RowKey like this:
(Note: Look for character restrictions for Partition- and RowKey in the Internet)
PartitionKey:

      • Compose the PartitionKey of:
      • Arbitrary string Prefix (e.g. ‘Y2_’)
      • A string with the actual year (e.g. ‘2018’)</li
      • A minus character (‘-‘)
      • A two charcter string of (12 – actual month).ToString(“D2”) (e.g. ’11’ if the act. month is November)
      • In C# language the PartitionKey would be coded as: string partitionKey = “Y2_” + DateTime.Today.Year + “-” + (12 – DateTime.Now.Month).ToString(“D2”);
        With the example values it would be: ‘Y2_2018-11’

RowKey:

      • As the used format is rather complicated I express how to create the RowKey in C# Programming language:

      • string rowKey = (10000 – actDate.Year).ToString(“D4”)
        +  (12 – actDate.Month).ToString(“D2”)
        + (31 – actDate.Day).ToString(“D2”)
        + (23 – actDate.Hour).ToString(“D2”)
        + (59 – actDate.Minute).ToString(“D2”)
        + (59 – actDate.Second).ToString(“D2”);

What kind of properties must be used for analog values Tables:
(Note: Look for character restrictions for Azure Storage Tables properties in the Internet)

      • Mandatory Property: ‘SampleTime’ .. Value: string, representing a DateTime (eg. 10/30/2018 14:48:59) or (eg. 10/30/2018 14:48:59 +060)
        (+060 means timeOffset to UTC)
      • in C#: string sampleTime = actDate.ToString(“MM/dd/yyyy HH:mm:ss”, CultureInfo.InvariantCulture);
      • 4 Key/value pairs for the names as string and the values as string in the range ‘-40.0’ to ‘140.0’
      • Example:
      • Property: ‘T_1’ .. Value: 17.4
      • Property: ‘T_2’ .. Value: 20.1
      • Property: ‘T_3’ .. Value: -17.4
      • Property: ‘T_4’ .. Value: 4.4

What kind of properties must be used for On/Off values Table:

      • Mandatory Property: ‘SampleTime’ .. Value: string, representing a DateTime (e.g. ’10/30/2018 14:48:59′) or (e.g. ’10/30/2018 14:48:59 +060′)
        (+060 means timeOffset to UTC)
      • Mandatory Property: ‘TimeFromLast’ Value: string, representing a TimeSpan (e.g. ‘000-01:35:59’ for 1 hour, 35 min, 59 sec)
      • Mandatory Property: ‘ActState’ Value: string, can be either ‘Off’ or ‘On’
      • Mandatory Property: ‘LastState’ Value: string, can be either ‘Off’ or ‘On’

If you already have populated tables in the Cloud go to the ‘Settings’ Page of this App and adjust the Analog- and On/Off-Table names and the PartitionKey Prefixes to match the values used in your tables.

If you have problems or need help, please give a feedback on this Web Page