Difference between revisions of "OpenRemote"

From Teltonika Networks Wiki
Line 94: Line 94:
 
'''"Port"''' : 502
 
'''"Port"''' : 502
  
'''"Period"''' : 20
+
'''"Period"''' : 10
  
 
'''"Timeout"''' : 5
 
'''"Timeout"''' : 5
Line 102: Line 102:
 
[[File:Networking_rutos_configuration_examples_openremote_012.png|border|class=tlt-border]]
 
[[File:Networking_rutos_configuration_examples_openremote_012.png|border|class=tlt-border]]
  
'''"Data type"''' : Data type of the data you are going to receive, in this case, the router reports its device name using ASCII
+
'''"Data type"''' : Data type of the data you are going to receive, in this case, the router reports its device system uptime
  
 
'''"Function"''' : MODBUS Protocol function, in this case, we are going to Read holding registers
 
'''"Function"''' : MODBUS Protocol function, in this case, we are going to Read holding registers
Line 115: Line 115:
 
Go to the router configuration page→Services→[https://wiki.teltonika-networks.com/view/Data_to_Server Data to server]. Click on the "Add" button, and the configuration is basically the same as described on the "Publishing Bluetooth/Wifi scanner/Modbus data" section of this article, just change the data source to "MODBUS data" and format the data as you wish. You should have something similar to this.
 
Go to the router configuration page→Services→[https://wiki.teltonika-networks.com/view/Data_to_Server Data to server]. Click on the "Add" button, and the configuration is basically the same as described on the "Publishing Bluetooth/Wifi scanner/Modbus data" section of this article, just change the data source to "MODBUS data" and format the data as you wish. You should have something similar to this.
  
[[File:Networking rutos configuration examples AWS 017.png|border|class=tlt-border]]
+
[[File:Networking_rutos_configuration_examples_openremote_013.png|border|class=tlt-border]]
  
 
===Checking if it works===
 
===Checking if it works===
 
Then, you can use the AWS MQTT test client to check if your setup works, if everything was setup correctly, you should see something like this.
 
Then, you can use the AWS MQTT test client to check if your setup works, if everything was setup correctly, you should see something like this.
  
[[File:Networking rutos configuration examples AWS 018.png|border|class=tlt-border]]
+
[[File:Networking_rutos_configuration_examples_openremote_0.png|border|class=tlt-border]]

Revision as of 16:42, 16 March 2023

Main Page > General Information > Configuration Examples > Third party services > OpenRemote

Introduction

In this article you will find instructions on how to setup OpenRemote Manager as a MQTT Broker and how to setup a RUT router as a MQTT Publisher and send data over to this OpenRemote Broker.

With that, you will be able to configure any other device as a MQTT Subscriber, and listen to any published info by the router or other devices on this same broker.

Prerequisites

You will need:

  • OpenRemote system
  • A router from RUTx, TCRx or TRBx series

Hardware Description

Hardware descriptions can be found in different Quick Start Guides (QSG). There you will find an overview of the various components on the front and back of a device, hardware installation instructions, first login information, device specifications, and general safety information. Link: Quick Start Guides

Set up your Development Environment

Teltonika Networks devices comes with our created firmware, therefore no additional development or scripting is required for this unit to support OpenRemote.

Setting up OpenRemote manager

Refer to the online OpenRemote documentation at Quckstart. Follow the steps in the section Quickstart to create your own environment with full access.


NOTE: In examples, port 1883 was used for MQTT protocol. To use this port you need to add it to your docker-compose file.
Networking rutos configuration examples openremote 001.png

OpenRemote as MQTT broker and subscriber

Create a service user

The service user will give programmatic access to the MQTT client.

  1. Go to the users page and create a new service user (second panel on the page).
    Networking rutos configuration examples openremote 002.png
    Networking rutos configuration examples openremote 003.png
  2. Name the service user 'mqtt_user' and give the user the read and write role for the sake of convenience. It is advised to configure a more restricted role for your service users.
    Networking rutos configuration examples openremote 004.png
  3. Click 'Create', a secret will be generated automatically.
  4. Open the 'mqtt_user' user to see and copy the secret.
    Networking rutos configuration examples openremote 005.png

Create an asset with attributes

We will create a Thing asset (MQTT subscriber), but feel free to use an AssetType that matches your physical device.

  1. On the assets page, click the + in the asset tree on the left.
    Networking rutos configuration examples openremote 006.png
  2. Select the Thing asset type, give it a friendly name and click 'Add'.
    Networking rutos configuration examples openremote 007.png
  3. Add new attribute in the Edit asset mode and save configuration:
    • type: Custom Attribute
    • name: writeAttribute
    • Valuetype: JSON
    Networking rutos configuration examples openremote 008.png
    Networking rutos configuration examples openremote 009.png

RUT as MQTT Publisher

What data do you want to publish?

Depending on your RUT model, you can have the following options of data sources to send over MQTT:

  • Bluetooth
  • Wifi scanner
  • MODBUS

Publishing Bluetooth/Wifi scanner/Modbus data

Before sending data from those sources to the MQTT Broker, the router needs to know what data from each source to send:

  • For Bluetooth, first you have to pair the device you want to get data from
  • For WiFi scanner data, you have to enable the wifi scanner functionality first
  • For MODBUS data, you need to set what data from what MODBUS slave the router has to get

If you need any help on setting up each functionality, the Teltonika Wiki has topics for each one of them: Bluetooth, WiFi Scanner, MODBUS

Example: Publishing RUT MODBUS to OpenRemote manager using MQTT

In this example the RUT device will act as MODBUS TCP Master and MODBUS TCP Slave, so the device will make requests (Master) and answer to himself (Slave). The received reply, will be sent over MQTT. You can also send data from another MODBUS Slave devices connected to the router.

Enabling MODBUS TCP Slave

Enabling the MODBUS Slave option on the router allows it to answer any requests coming from a MODBUS Master. To do that, go to the router configuration page→Services→MODBUS→MODBUS TCP Slave. Then clock the "Enable" slider and save.

Networking rutos configuration examples openremote 010.png

Enabling MODBUS TCP Master

Enabling the MODBUS Master option on the router allows it to make specific requests to any slave in the MODBUS network. To do that, go to the router configuration page→Services→MODBUS→MODBUS TCP Master. Click on the "Add" button, and do the following configuration on the page:

Networking rutos configuration examples openremote 011.png

"Name" : Any name

"Slave ID" : The slave ID you've set on the slave configuration, by default its 1

"IP address" : The LAN IP address of the router, by default its 192.168.1.1

"Port" : 502

"Period" : 10

"Timeout" : 5

Then scroll down the page a bit, on the "Add new request" section, give any name to your request and click on the "Add" button. Then do the following configuration

Networking rutos configuration examples openremote 012.png

"Data type" : Data type of the data you are going to receive, in this case, the router reports its device system uptime

"Function" : MODBUS Protocol function, in this case, we are going to Read holding registers

"First register number" : Depends on your MODBUS device, in this case, its 2

"Register count / Values" : Depends on your MODBUS device, in this case, its 2

Save and apply settings.

Configuring Data to Server

Go to the router configuration page→Services→Data to server. Click on the "Add" button, and the configuration is basically the same as described on the "Publishing Bluetooth/Wifi scanner/Modbus data" section of this article, just change the data source to "MODBUS data" and format the data as you wish. You should have something similar to this.

Networking rutos configuration examples openremote 013.png

Checking if it works

Then, you can use the AWS MQTT test client to check if your setup works, if everything was setup correctly, you should see something like this.

File:Networking rutos configuration examples openremote 0.png