Ad Widget

Collapse

ModbusTCP RTU over TCP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • piton4ik
    Junior Member
    • Nov 2024
    • 13

    #1

    ModbusTCP RTU over TCP

    hello,
    I read my energy meters TENSE EM-07K using a custom python script with a library (from pyModbusTCP.client import ModbusClient) that returns a json array to zabbix, is there a standard functionality in the system to poll these counters with standard solutions?
  • troffasky
    Senior Member
    • Jul 2008
    • 565

    #2
    I do something similar, ish. Python script connects to RS485 adaptor, fetches parameters [also sends to MQTT], this is then piped in to zabbix_sender -> Zabbix server.
    But I just googled this and it looks like this is already part of Zabbix agent2!

    Comment

    • piton4ik
      Junior Member
      • Nov 2024
      • 13

      #3
      Originally posted by troffasky
      I do something similar, ish. Python script connects to RS485 adaptor, fetches parameters [also sends to MQTT], this is then piped in to zabbix_sender -> Zabbix server.
      But I just googled this and it looks like this is already part of Zabbix agent2!
      https://www.zabbix.com/integrations/modbus
      I know about this feature
      here is a list of keys for Mudbus GET
      https://www.zabbix.com/documentation/current/en/manual/appendix/items/modbus
      but there is an RTU key only for SERIAL connection (rtu://COM1:9600:8n, rtu://ttyS0:9600, ascii://ttyS1)
      I need to read Modbus RTU over TCP(rtu://192.168.1.224:502) i use rs485->Ethernet convertors

      I now have a ready test bench with meter, rs485 convertors and zabbix test system,
      I can help with testing new feature functionality, it would be great to implement new functionality

      Comment

      • troffasky
        Senior Member
        • Jul 2008
        • 565

        #4
        It's a shame that the "example" items are not actually usable, they are just fragments of what you would put in an item.
        Anyway.
        I think one of us is confused here. I think that RTU and TCP are mutually exclusive - either one or the other is used, not both. Your post implies that you think you want to use RTU over TCP, but I don't think that's a thing.

        Comment

        • piton4ik
          Junior Member
          • Nov 2024
          • 13

          #5
          Originally posted by troffasky
          It's a shame that the "example" items are not actually usable, they are just fragments of what you would put in an item.
          Anyway.
          I think one of us is confused here. I think that RTU and TCP are mutually exclusive - either one or the other is used, not both. Your post implies that you think you want to use RTU over TCP, but I don't think that's a thing.
          ok,
          let's try to test, maybe I made a mistake somewhere in the configuration of the item key,


          item key: modbus.get[endpoint,<slave id>,<function>,<address>,<count>,<type>,<endiannes s>,<offset>]

          legend:​
          endpoint​ - tcp://192.168.1.145:511(fixed on router)
          slave id​ - 1
          function​ - 3
          address​ - 500
          count​ - 5
          type​ - uint16
          endianness​ - le
          offset​ - 0

          modbus.get[tcp://192.168.6.145:511​,1,3,500,5,uint16​,le,0]​
          modbus.get[tcp://192.168.6.145:511​,<1>,<3>,<500>,<5>,<uint16​>,<le>,<0>]​​

          when I try to save this key the system gives an error, explain where I am wrong
          Click image for larger version

Name:	zabb1.png
Views:	572
Size:	64.5 KB
ID:	494369

          Click image for larger version

Name:	zabb2.png
Views:	537
Size:	64.9 KB
ID:	494370

          Comment

          • cyber
            Senior Member
            Zabbix Certified SpecialistZabbix Certified Professional
            • Dec 2006
            • 4806

            #6
            definitely do not use <>-s there... those are just for marking keywords...

            But I tried to enter one item and I got errors in any way and combination I tried... leaving out most of them, relying on defaults etc. etc..
            Exact same as you on v7 and a bit longer text on v6...
            : incorrect syntax near "". [items.php:690 → CApiWrapper->__call() → CFrontendApiWrapper->callMethod() → CApiWrapper->callMethod() → CFrontendApiWrapper->callClientMethod() → CLocalApiClient->callMethod() → CItem->create() → CItemGeneral->checkInput() → CApiService::exception() in include/classes/api/services/CItemGeneral.php:492]

            Comment

            • troffasky
              Senior Member
              • Jul 2008
              • 565

              #7
              Two things you can try:
              - test with zabbix_get
              - Use "Named sessions", which are mentioned on Modbus integration page, but not mentioned on modbus.get page

              From here:

              Example item:
              modbus.get[tcp://10.6.4.51:502,1,4,13958,3,uint32,mle,0]
              I tried adding this item on my Zabbix, server accepts it [I do not have any Modbus TCP equipment].

              Comment

              • piton4ik
                Junior Member
                • Nov 2024
                • 13

                #8
                I inserted your key into a new Item and saved it, everything is fine,
                then I edited it to my real ip and other parameters, all it works, thank you

                Comment

                • cyber
                  Senior Member
                  Zabbix Certified SpecialistZabbix Certified Professional
                  • Dec 2006
                  • 4806

                  #9
                  I think it is somekind of encoding issue... When I pasted both now to notepad++ and let it show "all characters"... this is what is shown..The one provided by troffasky worked OK for me also...

                  Click image for larger version

Name:	image.png
Views:	533
Size:	6.9 KB
ID:	494438

                  Comment

                  Working...