Sensors on Linux and Windows Player

Linux Player

Pre-requisites


In order to connect the sensor to CMService you need to have:

• CMPlayer (configured with the wanted channel from CMS)

• Node Server (connected with the CMS)

• MQTTbox (connected with the Node Server)/Sensor Board with MQTT or serial port

Note: The Node Server is installed from the installation of the CMPlayer. MQTT Box should be installed separately.


rIOT Configuration


As a first step to configure the rIOT, you need to open the Linux Configuration file. In General Settings under the Network Settings area, tick the option ‘Enable IOT’, run diagnostics and then start the CMPlayer.



Sending data through MQTTbox


Open MQTTbox and click on ‘Create MQTT Client’. New view ‘MQTT Client Settings’ will be shown, and here several settings need to be adjusted to connect successfully the MQTT Client:

• In ‘MQTT Client Name’ field you should enter the wanted Client Name.

• From ‘Protocol’ dropdown menu, ‘mqtt/tcp’ should be chosen always.

• In ‘Host’ field you should enter the IP address of the device where the CMPlayer and the Node Server are installed.

• Untick the option: ‘Append timestamp to MQTT client id?’



When all required fields for connection are filled click on ‘Save’ button. The new view will be shown. From this side you can send data to the sensor. Topic should be same in fields ‘Topic to publish’ and ‘Topic to subscribe’. After entering the topic click on ‘Subscribe’ button and in ‘Payload’ field enter the sensor data (for example: {“women”: 15, “men”: 26}) and click on ‘Publish’ button to send the data.



Now, the values will be sent to the NodeServer.

Additionally, the data can also be sent via Serial port besides MQTT. The port info need to be defined in the ‘COM Port’ text box. i.e. /dev/ttyUSB0/:115200 defines the port name as well as the baud rate 115200.


Windows Player



Pre-requisites


In order to connect the sensor to CMService you need to have:

• CMPlayer (configured with the wanted channel from CMS)

• Node Server (connected with the CMS)

• MQTTbox (connected with the Node Server)


Note: The Node Server should be installed together with the installation of the CMPlayer. MQTT Box should be installed separately.


Node Server Installation and Configuration


Run the CMPlayer Installer. In the ‘Select Features’ tab, select both ‘Ryarc CMPlayer’ and ‘Ryarc Node Server’.



Finish the installation with clicking on the ‘Next’ button. The Node Server and the CMPlayer are successfully installed after the installation is finished. The next step is to configure the Node Server to communicate with the CMService. From the search bar for windows open the Node Server.



In the ‘CM service address’ field we set the CMS address or the IP address. This is the only field that we are changing and after that click on ‘Apply’ button. The Node Server should start running again. To confirm, the message above the settings should be ‘Service is running currently’.



Click on ‘Ok’ button when everything is set and ready. Similarly, in CMPlayer Config, the player needs to enable using node server with its IP


Sending data through MQTTbox


Open MQTTbox and click on ‘Create MQTT Client’. New view ‘MQTT Client Settings’ will be shown, and here several settings need to be adjusted to connect successfully the MQTT Client:

• In ‘MQTT Client Name’ field you should enter the wanted Client Name.

• From ‘Protocol’ dropdown menu, ‘mqtt/tcp’ should be chosen always.

• In ‘Host’ field you should enter the IP address of the device where the CMPlayer and the Node Server are installed.

• Untick the option: ‘Append timestamp to MQTT client id?’



When all required fields for connection are filled click on ‘Save’ button. The new view will be shown. From this side you can send data to the sensor. Topic should be same in fields ‘Topic to publish’ and ‘Topic to subscribe’. After entering the topic click on ‘Subscribe’ button and in ‘Payload’ field enter the sensor data (for example: {“women”: 15, “men”: 26}) and click on ‘Publish’ button to send the data.



Now, the values will be send to the NodeServer. And the ‘MQTT Message’ tab displays the live data being received.



Additionally, the data can also be sent via Serial port instead of MQTT. The port info needs to be defined in the ‘COM Port’ text box. i.e. COM1/:115200;0;8;1 defines the port name as well as the baud rate 115200

COM1/HEX:115200 defines the port is outputting data in HEX format COM1/:115200;0;8;1 defines the port is with baud rate 115200, non parity, 8 data bits and 1 stop bit

Furthermore, multiple serial ports can be listened by using delimiter ‘|’

i.e. COM1/:115200|COM3/:9600

This setting listen both COM1 with 115200 rate and COM3 with 9600 baud rate.


CMService Web UI


Sensor Type Definition


Login to CMService as domain admin and from the domain navigation menu choose rIOT.



The node server will be shown in rIOT page as online and his name will be the name of the configured channel.



If the sensor is connected to your service, it will appear as a sub-row. The data being received is the same raw data sent. In order to define the sensor, we need to create or assign an existing sensor type to this sensor. Select existing sensor in the list and click Create Type for this Sensor. Write sensor Type name and click Create.



Status

In Status Tab you can enter Name and upload photo for the Sensor, set Sensor map location latitude and location longitude, select if you want to receive Email alert if the values of the sensor are outside of the defined range. In ‘Device data template’ the sensor for which this sensor type was created will be selected and the JSON template that you send previously through MQTTbox will be shown in the field. From navigation menu from the left side, click on ‘Auto-Generate from JSON’ and click on ‘Save’ button. Auto-generation creates the definitions from the properties of the JSON raw data automatically. Definitions can also be manually created from the list. In addition, if the raw data is JSON format, user can choose the sensor from the dropdown list to preview its latest data as the JSON tree. Clicking on the property name in the tree can automatically update the selected definition.



A list of definitions can be seen from the following screenshot. One sensor type can consist of multiple definitions. i.e. Temperature, humidity… These definitions help system convert raw data into multiple human friendly sensor info.



The UI shows how the selected definition is set. You may name the definition from the first textbox. The second setting is for the ‘Path’ which defines which part of the raw data is for this definition. For JSON data, it is defined as ‘Path.PropertyName’ For example ‘iot/sensors/(.*)/status.UB’ means the value is from property name ‘UB’ under path ‘iot/sensors/(.*)/status’. The path can be dynamic which can be marked as ‘(.*)’ by clicking on ‘Generic Select Text’ botton.

The third textbox allows data filtering by Regular Expression. So only the data matching the Regular expression will be recorded.

String format textbox allow the CMS UI shows the data with other text together i.e. 12 °C

The last important setting is ‘Data conversion by javascript eval() ({0} for the input variable) (optional):’. It does Javascript conversion from the data to the human friendly value. For instance,

1=={0}?'pressed':'not pressed'

This setup will record data as ‘Pressed’ when the raw data is equal to ‘1’

Other settings are setting the optimal or allowed range which can send email alert and color the UI accordingly.

We record senor data history every minute by default. Some sensor board can send more frequently and need every data recorded. ‘Record full history’ checkbox need be enabled in this case.


rIOT page

Go back to the rIOT page. Select the node server and select the sensor for which you send values. For the left menu click on the ‘Edit Sensor’ button and from the dropdown choose the Sensor Type which you created previously. The sensor values will be shown under the sensor.



Clicking on the individual definition for its recent history chart.



Double-clicking can open all the charts and histories from the sensor.



This history can be exported as CSV from the list.



Command


In Command tab of sensor type detail view, it defines the commands to send back to the sensor in order to let it behave differently. For example, one command can be defined to turn on/off an IOT smart bulb.



Fill the fields ‘Command Name’, ‘Command Topic’ and ‘Command Data’ and save the command.

Open rIOT page, select the Node Service and the sensor you want to send the command. Right clicking on the sensor and click on ‘Command Sensor’ button, in the modal window will be shown commands which are created under the Sensor Definition where that sensor is assigned. Choose the command and click on ‘Send’ button, and the predefined command will be sent to that sensor.





IOT Usage


Schedule IOT Command


The IOT command can also be scheduled and grouped to run on specified channels as regular command.

As seen in the following screenshot, the user defined sensor commands can be chosen and loaded into the regular command to schedule and run.



Conditional Play


First, we select the media from the Playlist and click on the Conditional button from Playlist Settings menu from the left navigation menu.



New modal window will be opened with two sections ‘Condition Summary’ and ‘Condition Configuration’. From the Condition Configuration click on Sensor Match. New modal window will be opened with drop-down for choosing Sensor Definition.



The drop-down contains all sensor types. After choosing one of the sensor types, its sensor definitions will display in the list. You can click ‘Add Sensor condition’ to go the condition setting steps. In this case, the condition will match whatever sensor available on the device with the same sensor type. Alternatively, you can even specify which sensor you want to match by clicking on ‘Match a Sensor’ button. From the new modal window you can choose the sensor under any channel and click on ‘Add Sensor’, and then on ‘Add Sensor Condition’.



Under the Sensor Match section, all the sensor conditions you selected previously will be displayed. For each sensor condition there will be drop-down field and field for entering conditional values. The drop-down field contains options: Equal( = ), Less than(<), Greater than(>) and Not Equal(<>). You can choose different options for each sensor condition. ‘Equal’ and ‘Not Equal’ also applies to the String values.



In each media that contains condition play, there will be an information icon about the condition.



Only the media files that match the condition will play on the player. Similarly you can also apply conditions for the entire campaign or command.

Media Templates

One of the features of the Media Templates is the possibility to do Sensor rIOT Integration. This means that the live values from the integrated sensor will be shown and update instantly on the Player using the Media Template. With click on ‘Sensor rIOT Integration’ button, new modal window will be opened from where wanted Sensor Definition can be chosen.



If you do not choose any sensor in the list, the template will display whatever sensor available with the same type on the device. You can also specify which sensor exactly from which channel to display. now click on ‘Add Sensor’ button. The media template is bound with the sensor type now. Clicking on the Text Zone in the Media Template, and under the ‘Insert Sensor Definition‘ drop-down, list of all sensors that belongs to the chosen Sensor Definition will be shown.



Add few sensors to the text zone and save the media template.



Go to campaigns and import the media template to the campaign, select the channel and publish the campaign. The values will be shown on the player.



Changes made in the sensor values through MQTTbox or Commands will be automatically applied on the Player.