STREGA a company specialized in industrial communication with experience in the Automation, and SCADA which offer solutions tested in real industrial environments to provide the a reliable product on the market. 

In this guide we are going to cover how to connect a STREGA LoRa wireless smart valve & wireless time-controlled emitter to Ubidots through The Things Network

To get a detailed information about the STREGA products, refer their official website

Requirements

IMPORTANT NOTE: This guide assume that your STREGA device is already transmitting to TTN. If not, check the step-by-step guide provided in their official website.

Step-by-Step

1.Setting up TTN integration
2. Setting up Ubidots
2.1. Control variable creation
2.2. Setting up dashboard
2.3. Setting up events
3. Summary

1. Setting up TTN integration

1. Go and access to  the TTN console where the STREGA devices are already transmitting data. 

2. Select the application where the sensors are registered. Then, select "Integrations" from the options located at the right-upper side of website:

3. At this point, select "+ add integration". Then, scroll down and select Ubidots as integration option:

4. In the following window, leave the defaults keys in the "Access Key" field and assign the Ubidots TOKEN of your account. 

If you already don't know how to get the Ubidots TOKEN, check this guide

Once the token is assigned in the integration creation, it should look like the following one:

5. To finish press the "Add integration" button. Once the integration is created you will see how the status of the integration is "Running":

At this point, the integration will automatically use the DevEUI of the STREGA device as the "Device API Label," which is the unique identifier within Ubidots used to automatically create and identify different devices. 

Once the sense new values the data is going to update at Ubidots in the device created. 

2. Setting up Ubidots

2.1. Control variable creation

1. Go to the device section from the "Device" Tab located at the upper-central side o the website and check the new device created in your account. At this point, the data sent by the sensor is going to be reflected into the variables created in the device. 

The device should have assign the DevEUI as device name and device label.

NOTE: If you desire to change the device name to a friendly one and you don’t know how, please reference the following guide

2. In order to control the valve, a new variable have to be created. To create the variable press "Add variable > Raw". Then, assign the name desired. In my case, I decided to called the variable "command".

Once the variable the variable is created, you should be able to visualize an empty variable:

2.2. Setting up dashboard

1. Now with the variable created, we have to add some widgets into the a Dashboard in order to visualize and control the status of the valve. To do this, go to the the "Data > Dashboards" section.

2. To control the valve add a switch widget. To add it, just press the blue plus icon and select the switch option. 

Then, assign the variable previously created, in my case, the variable is called "command". At this point the default messages are "On" and "Off", feel free to change them if is desired. 

Once the widget is created the result should look like the one below:

3. To visualize the status of the valve, you can add a indicator widget. Repeat the same process of the step 3.1. to add the widget but select the indicator widget instead of the switch one. Having as result something like this:

 2.3. Setting up events

In order to be able control the valve through the switch widget, you have to configure a webhook event to send the status assigned to the switch the STREGA device. 

1. Go to the Events section by pressing "Data > Events". 

2. To create a new event press the plus blue icon (+) located at the right upper side of the platform.

3. Assign the condition desired to trigger the event. In this case the condition is going to be if the value of the variable command is equal to 1. Having as result:

To continue press the right arrow icon located at the left bottom part of the platform. 

4. Now in the following window is time to set the action. To assign the action, press the plus orange icon located at the right upper side of the platform and select  Webhook as action. 

To configure the webhook, assign the following parameters:

  • HTTP Method: POST 
  • URL: 
https://integrations.thethingsnetwork.org/ttn-eu/api/v2/down/my-app-id/my-process-id?key=ttn-account-v2.secret

Where: 

my-app-id have to be replaced with the ID of the application where the integration was created. 

key have to be assigned. This key can be simply found in the overview of the application:

Once the parameters are assigned the end URL should look similar to following one:

https://integrations.thethingsnetwork.org/ttn-eu/api/v2/down/strega-sensors/my-process-id?key=ttn-account-v2._VEdyVK_hE-CdoiwVWut2-uGg9aLcjRaGAjekQ3Qr0c
  • Headers: content-type:application/json 
  • Body: 

Activate trigger body:

{
  "dev_id":“yourTTNdeviceID",
  "port":1,
  "payload_raw":"AQ=="
}

Back to normal body:

{
  "dev_id":" yourTTNdeviceID ",
  "port":1,
  "payload_raw":"AA=="
}

Having as end result the following configurations:

To save the changes press the green check mark icon located at the left bottom side of the platform.

At this point, you are able to control the state of the valve through the dashboard

Now is your turn to include more widgets to start monitoring all the variables manage by your solution, until have a result like the one below:

3. Summary

Thanks to the products offered by STREGA you are able to build industrial applications to optimize the water management where is desired without matter the industry! Check the following video to learn more about them:

Now is your time to start creating an IoT Solution that keep you and those who need to know informed and on time!

Other readers have also found useful...

Did this answer your question?