Changes

Jump to: navigation, search
Ubidots
The second part describes how to visualize on the dashboard of Ubidots. That last shows how to set up events so as to get a notification.
The procedure here described was tested on a SBC Lynx running Debian distribution. For more details, please refer to [[XUELK-AN-002:_Running_Debian_distribution|this application note]].
====Connecting and uploading data to Ubidots====
As stated before, it is assumed that the board runs a Debian distribution:
Go to the [website of the Ubidots cloud https://ubidots.com/website of the Ubidots cloud] and click the sign up option on the right upper corner of the website and to create the account.I have created for my activity and here I put it in belowusername =zerihunpass = Zeri@204920
 To get the Api key API token for the just created account, go to the right upper corner of the home page of the ubidots and click on the user name then username. Then you will see four options which are ''My Profile'', ''API Credentials'', ''Docs '' and ''Log Out''.
Click the API Credentials
Click the ''API Credentials''. The API token (<code>fwSetosAgIG3d128YdzP5fi4hADzWU</code> in this example) is a string which will be used later to initialize the API client instance.
[[File:XUELK-AN-IIoT-3.png|thumb|center|600px|caption]]
Here in below I wrote mine API key To create and token as an example which will be needed when we generate initialize an instance to communicate with the target device (Sbc-lynx board) API KEY = 4435dd4dd5454114fc2e5425b3dd9361de0f2ffaToken = fwSetosAgIG3d128YdzP5fi4hADzWU  III) Now, after creating the user profile on the ubidots cloud side, we can be connected to it by creating an Api-Client instance from the Lynx board. To create an instance, use the following code is
<pre class="board-terminal">
from ubidots import ApiClient
api = ApiClient(token=' fwSetosAgIG3d128YdzP5fi4hADzWU ')
</pre>
After establishing the instance with On the cloudside, we will retrieve the variable.The variable it is where we want necessary to save create the value variables that we will send to store the values uploaded by theCloudSBC LynxBut before sending data to In the cloud sideexample, three variables are created: <code>Fall_sensor</code>, we first go to the device option <code>Flood_sensor</code> and define our own device and create the variables (equivalent to sensors)<code>Temp_sensor</code>. To create variables, there are three option options in the upper center of the home page of the ubidots Ubidots interface, as shown below .
[[File:XUELK-AN-IIoT-4.png|thumb|center|600px|caption]]
Click the device option, then we will get the following :
[[File:XUELK-AN-IIoT-5.png|thumb|center|600px|caption]]
Click the device and add a variable (equivalent to sensors)  :
[[File:XUELK-AN-IIoT-6.png|thumb|center|600px|caption]]
After adding the variables, we need their id therefore to find their id IDs. To get them, put the cursor on bottom side of each variable box then. Then, you will see “I”option then click "I" option. Click it you will to get the id of the variable that is used to establish an instance to this variable with the target device(sbc -lynx)ID.
In my case To create an instance of the variable on the SBC Lynx side, use the following format code:<pre class="board-terminal">my_variable = api.get_variable(for example'<variable ID>'), I have added to my device three different variables named as Fall_sensor, Temp_sensor and Flood_sensor</pre>
To create an instance, use the following formatmy_variable_lynx = api.get_variable('id _variable form upload a value to the ubidots') Having instantiating variableUbidots platform, we can save use a new value with thecode like this:following line:<pre class="board-terminal">
new_value = my_variable.save_value({'value': xxxxxxxxxxx})
Here is my simple python script to send random data to the ubidots  [[File:XUELK-AN-IIoT-7.png|thumb|center|600px|caption]]</pre>
Following is a code snippet that uploads random data to the platform:
<pre class="board-terminal">
from ubidots import ApiClient
test_value_3 = my_variable_3.save_value({'value':test_value_3})
</pre>
 
When we execute this python code from the SBC Lynx board, it will send random data to the ubidots (to each variable, in my case it is three variable)
====Visualizing data on the cloud dashboards====
4,650
edits

Navigation menu