Connect TRB 141 to Node-red via MQTT

Hello,

I need to connect to node-red with my teltonika trb141 via MQTT.
I have tried a lot of things, but nothing seems to work. Am I making it harder than it is?

All I need is to show the value of the analog current loop(7) in node-red.

Can anyone explain like I am 5 years old how to do it?


broker
publisher

Hello,

If you are looking to send data to Node-RED over MQTT, I would suggest looking at our configuration example here.

Kind Regards,

Hello AndzejJ,

Thank a lot for the help. I will try to follow the guide and make it work :slight_smile: :smile:

Hello again,
I have tried to follow the guide (Using Teltonika device as an MQTT broker), but can not make it work. I belive there is a problem with the text i am injecting in node-red. Is there a better explanation to this table? I need to know something more specific for the TRB141?

Hello,

Could you specify which aspects of the table you find unclear? You can check this forum post here, maybe it will help.

For troubleshooting, I would recommend using MQTT explorer. Specifically, connect to TRB via MQTT explorer and check if you can get data from it. This way, you will be able to see if the issue is related to your TRB or Node-RED configurations.

Also, try the following:

  • Disable firewall on your PC
  • Navigate to Services → MQTT → Broker → Miscellaneous (under broker settings) → enable allow anonymous access
  • Navigate to System → Administration → Access control → Security tab → ensure that there are no IP blocks for MQTT traffic (unblock all)

Kind Regards,

It works!! AndzejJ you are a legend in your own time! Thank you alot!!

I can now communicate between the TRB141 and node-red :slight_smile:

I have a question to the value i am getting.

I am sending this request: 0 65432 0 192.168.2.1 502 5 1 3 347 2

The ACL (analog input 4-20 mA) is 6 mA.

I am getting this reponse: “65432 OK 16572 52429”

When chancing the mA signal the first number and “OK” stays the same, but the to last numbers chance. How is 16572 52429 equal to 6 mA?

Hello again AndzejJ :slight_smile: I hope that you are doing well.

I think i made a mistake. I used the wrong Register Number. I should instead use 142 that read “Analog input (PIN 7) value”.

When I do that the same problem occors.

I am now sending this request: 0 65432 0 192.168.2.1 502 5 1 3 142 2

The analog input is 6 mA.

I am getting this reponse: “65432 OK 0 2118”

When chancing the mA signal the first number, “OK” and 0 stays the same, but the last number chance. How is 2118 equal to 6 mA?

Hello @jsk,

To understand the returned values, you need to convert the results. You can find information on how to convert different types of data returned via Modbus on our wiki here.

Please, let me know if you encounter any issues!

Kind Regards,

Hello @AndzejJ :slight_smile:

I have looked at the link that you gave me. It is the same problem I have. The value i get when reading the Analog input value is wrong. Atleast not the same as the value i send in the TRB141.

I have chosen the:

I am sending this request: 0 65432 0 192.168.2.1 502 5 1 3 142 2

And is getting this response when sending 7 mA into the TRB141:
nodered

And a bonus question for you @AndzejJ :slight_smile:

Is it possible to have the connection to Node-red with the 4G antenna on the TRB141? Do you have a guide for that?

Hello @jsk,

If you are reading Analog Current Loop (not analog input), try reading register 347.

Could you please clarify what do you mean by ‘Node-red with the 4G antenna’ ? Are you looking to reach your TRB over the internet (over mobile network)? If so, you should be able to do so. For TRB to be accessible over a public internet, you will need a public IP address or alternatively, use VPNs.

Kind Regards,

Hello @AndzejJ ,

When I read the 347 register I also get numbers that doesn’t makes sense acording to the mA signal sent in the TRB141.
You sent an anwser to this ealier. But I cant find a solution to the problem. No conversion makes sense and I cant find anything on the internet.

What is the difference between these to and how do I read the value i am reading from them?
TRB141 Modbus Registers


It is like I have to make a conversion that dont make sense. I have tried the conversions in this link but without luck. Conversions

Is there a phone number I can call a Teltonika? Technical support maybe?

Hello,

Could you please share what you get when you read register 347 over MQTT, and what the actual mA value is at that moment?

Once you check, since it’s a 4-20 sensor, can you try calculating it like this:

Convert the last two values (after “OK”) to binary. Convert binary using IEEE 754 floating point representation calculator. You will get a float X:

result = 4 + (20-4)X

What do you get?

Kind Regards,

Hello,
Here you have the results from a read in register 347 over MATT:
image

I tried the calculation but did not get anything useful. Maybe I am not doing it right. Maybe you could show it?

@AndzejJ I really appreciate all your help. Thank you!

@jsk Hi,

Try converting each separate decimal to HEX and use IEEE 754 converter. For example:

With 5 mA you got 16540 52429, which is 409C and CCCD in hexadecimal, respectively:

Kind Regards,

This topic was automatically closed after 20 days. New replies are no longer allowed.

This topic was automatically closed after 6 days. New replies are no longer allowed.