In this section, we will go through most of Cervello features by creating a simple fleet management solution using a virtual device simulation.
We will be using MQTT protocol in this section and MQTTBox, which is a MQTT client that can mimic a real sensor.
Other than MQTT, Cervello supports other connectivity protocolsHTTP Protocol, CoAP Protocol
Step 1: Login to Cervello
Step 2: Create an organization
Step 3: Create and configuring the device
Step 4: Connect the device
Step 5: Sending data to Cervello
Step 6: Visualizing device data
Step 7: Creating rule engine and Alarms
Step 8: Displaying alarms
Use your username and password to login to your Cervello account.
To get a Cervello account, please contact us on support@cervello.io
Once you are logged in, you can create a new organization by clicking on the Create Organization
button.
Insert an organization name, and an optional description then click on OK button.
Choose the organization you have just created.
Devices are the core power of any IoT platform.
In a later chapter we will talk about devices with more information and how efficiently Cervello can handle vast amount of data from large and different types of devices.
You can create a new virtual device by clicking on Devices
-> Create Device
-> Without Template
button.
You will be redirected to the devices page where you can insert data for the device.
Insert data for the device then click
Save
to submit your virtual device.
There are other settings such as Communication Protocol
, Device Type
, Public
etc…., which are explaind in Device Management section.
The green check mark confirming that the device name is valid and never been used.
We have successfully created a virtual device, now we can connect a physical device or a device simulator (MQTTBox in our case).
In order to connect any device/sensor to Cervello, you must obtain 3 keys (Device ID, Access Key, Access Token).
Lets first create access credentials to our virtual device.
Open the device actions dropdown and click on Manage Credentials
.
Click Generate Credentials
to create access credentials for this virtual device.
A new form will appear containing the access key and access token that we need to connect to Cervello.
Note: Access credentials can only be used by one device at a time.
Copy the device ID and the other keys and save them securely, we will use them later.
Download and open MQTTBox
Click on Create MQTT Client
to add a new client.
Fill in the settings form to configure connecting to our virtual device
MQTT Client Id: is the virtual device Client ID.
Username: is the virtual device access key.
Password: is the virtual device access token.
Protocol: mqtt / tcp.
Host: broker.cervello.io
.
And finally make sure that Append timestamp to MQTT client id?
is unmarked.
Once you click Save
, if everything is configured correctly, the top status button should change to Connected
.
And the Connection Status
for the virtual device will also change to Connected
That means our device is connected and authorized to communicate with Cervello.
In this step we are going to explore how to send data from a device to Cervello using MQTT protocol.
Cervello offers huge flexibility in communications and doesn’t restrict publish topics or specific schema for the message payload.
Communication with Cervello through MQTT can be done in two ways:
This is useful for a plug & play scenario.
Devices must send MQTT messages to the following topic format:
Telemetry data: /devices/{clientId}/telemetry
Attribute data: /devices/{clientId}/attribute
There are other topic format such as RPC
, Alarm
, Event
etc…., which are explaind in Device Management section.
To find all device’s topics, go to the device page and click on Topics tab from the left-side items.
Additionally, the payload message must be in the following JSON object format:
{
"data": {
"key": value
}
}
Where key is the telemetry key, and value is the telemetry value.
This allows you to use customized topics and payload for communication through MQTT, this helpful in many cases, for instance, access to firmware is limited and changes will take a lot of time.
See VPI chapter for more details on how to use custom communication settings.
In this tutorial, we are going to use Cervello procedural topic, let’s publish some telemetry data using MQTTBox
To confirm that the message has been sent successfully, checkout the device’s telemetries page and you should see the following:
Cervello will store all telemetry data sent by the device, in the next step we are going to explore how to bring data to life with visualizations.
First we need to assign the device to an application.
create an application, Applications -> Create Application
You will be redirected to the application page where you can insert data for the application.
Insert data for the application then click OK to submit your application.
Go back to the Device Manager
tab.
From the device drop down actions click on Assign To Application
.
Click on the name of the application you created.
Go to the Applications
tab then click on the application you created above.
From the side menu click on Dashboards
, then click on Create Dashboard
.
Click on the name of the dashboard you created.
This will redirect you to the dashboard editor where you can visualize your data in different ways.
Click on the
icon to get started.
You will find tabs containing different types of components. We are simulating a sensor that’s sending a car speed, so we need a component that displays last value. KPI components are designed for that purpose, so let’s click on KPI tab and choose Angular Gauge component.
Click on the
You will be prompted to settings form where we can configure our component, Now we need to choose data source for the component to display.
Fill in the form items
Then click Save Component
Now for every message that the device sends and has the key SPEED
, this gauge component will update with it’s value.
We have managed to monitor our device in real time, but we need to be notified if something
unexpected happens, like if the SPEED
goes above a certain value.
Cervello allows us to achieve this through a very simple and highly customizable rule engine using VPI Editor (Visual Programming Interface).
Go back to the application page and choose VPI Editor from the left-side menu
Insert VPI name and click OK to create a new VPI
Click on the VPI name to be redirected to the VPI editor where you can create workflows.
You will find a list of different components on the left side menu (we will go through each one of them in
the VPI chapter)
.
For now lets use the components we need which are Device Telemetry
, Data Transformation
, Rules
, Debug
and Create Alarm
.
You can use the search field to quickly find components, then drag and drop them into the grid to be able to use them.
Most components in the VPI have an input to pass the data to it to process, and an output to pass the processed data to the next component.
To connect components, click on the output of one component, and draw a link with the mouse cursor to the input of another component and save the VPI. Now connected components in the workflow can send to each other data in order.
Click on the save button to save the VPI components.
Device Telemetry: This component will allow us to obtain any telemetry data the selected device sends to Cervello.T
Data Transformation: Which will help us transform the received data to be in JSON format.
Rules: Rules component is where all the conditional logic will be happening.
Debug: Debug component will help us debug our workflow by outputting data into the console tab.
Save Alarm: Creates an alarm for the device with given data.
Now let’s configure each component.
Double click on any component to open the settings form.
In Device Telemetry
settings choose our device and click save.
Next in Data Transformation:
component, we need to transform data from JSON string to JSON object.
Rules:
this is where we can set logical conditions, in our case we need to create a rule if SPEED
value is above 100.
Create Alarm:
this is where we can set logical conditions, in our case we need to create a rule if SPEED
value is above 100.
Let’s send another value and see how our workflow goes.
Click Publish and watch the VPI
Great! a speed alarm has been created in the device, in the next step we are going to explore how to display a device alarms in the dashboard.
Final step is to monitor the device alarms from the dashboard. Let’s go back to the dashboard manager and add another component.
From the Tables tab, choose Alarms Table.
Fill in the settings options and select our virtual device and save the component
Finally we have a dashboard to monitor a device speed and display any alarms for the device.