Add a new Sensor to a Device

Prerequisite: At least one Device must be active. To add a new Device please see:‚Äč

Theory - Sensor Groups and Sensor Attributes

Adding a Sensor consists of two steps: Adding a Sensor Group first, then the Sensor Attribute.

The Sensor Group is a meta-category used to collect different Sensor (Attributes) that are on the same hardware. For example a SenseHAT add-on board may be considered a Sensor Group as it is a collection of eight different sensors on the same board.

A Sensor Attribute defines the sensor and the data type at the same time. For example, a temperature sensor on the SenseHAT can be considered a Sensor Attribute: we read the data in Celsius with a Python script locally and send the value and type to the cloud. However, if there is a need to read both Celsius and Fahrenheit at the same time, from the same temperature sensor, it is possible by creating two separate Sensor Attributes: one for Celsius and one for Fahrenheit measurements.

The combination of Sensor Groups and Sensor Attributes eliminates the limitation of using the same sensor (for example temperature sensor) for only one data type or data manipulation with a local script.

Step 1 - Sensor Group

To add a new Sensor Group to a device, please go to Device Management >> All Devices .

Click on the button "Manage Sensors" for the relevant Device.

Under "Add New Sensor Group", fill out the required fields.

The Sensor Group Name must be unique. The Sensor Type is rather descriptive and does not have to be unique.

Click the "Add" button.

Step 2 - Sensor Attribute

To add a Sensor Attribute, on the Device Management >> All Devices overview page, click the "Configure" button for the relevant Sensor Group.

In the Sensor Attributes Overview, the already configured Sensor Attributes are listed.

To add a new Sensor Attribute, click the button "Add Attribute".

A new row will appear in the list.

Fill out the fields as required.

Name - must be unique Direction - input: sending the data from the device to the cloud - output: receiving data on the device from the cloud (usually a command) Type - the data type that will be sent (double, boolean, integer, string, long or float) Interval - the time interval between each automated reading. limited to 1-59 seconds depending on the subscription plan. Note: The automated time and value averaging in the system allows time intervals such as minutes, hours and days to be used for event triggers, but the reading interval on devices is limited to a maximum of 59 seconds for enforced reading precision.

When the fields are filled out, click the "Save" button.

In this example, the Sensor Attribute "letter" was added for demonstration:

There are two further statuses after a new attribute is added: - Script State - the status of the script validation (Python) running locally on the device - Attribute State - general state of the sensor: the script may be valid, but no reading is carried out until the Sensor Attribute has the state "Active". Note: For the "State" to be "Active", the Script State must first be "Valid".

Step 3 - Script Validation

The script validation must be carried out on the Device in the Remote Client.

When refreshing the Remote Client overview, the new Sensor Attribute "letter" appears on the list.

To edit the script for the "letter" Sensor Attribute, click the "Script" button in the row.

Then, click "Edit" to enable editing the code.

Click "Load Template" and select the relevant template.

In this case, the showLetter (Sense HAT) was selected.

The Python code will be automatically added.

Modifications to the code are possible at any time. If an already saved code is modified via the editor, the code will need to be revalidated and saved to enable changes.

Since the attribute "letter" is an output parameter, the compiler will need a test parameter to check the code validity.

Enter a value such as "X" (without quotation marks) in the Field next to "Type:string".

Click the "Validate" button.

The script has now been validated.

Click "Save".

Then click "Back to Dashboard" .

The Script State has now been changed to "Valid".

The Attribute State is still "Deactivated" and needs to be activated in the Cloud Dashboard for security reasons. Any change in the Remote Client will need reapproval of the change in the Cloud Dashboard in a form of activation.

Step 4 - Attribute State activation

The Attribute State validation must be carried out in the Cloud Dashboard.

Moving back to the Cloud Dashboard, after refreshing, the Script State is now valid having carried out the previous step.

Click the "Activate" button.

The Sensor Attribute "letter" has now been activated.