🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Modbus Master crashes and missing documentation

    UIFlow
    3
    6
    3.7k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • I
      insaneLX
      last edited by

      Hi,
      I am trying to create a modbus master application in micropython. I cannot figure out how to use the write_single_coil register as I get a ValueError: Illegal coil value when using following line:
      modbus.write_single_coil(1,0, 1, timeout=500)

      Also, the documentation on Modbus is really flaky - can you point to some examples or maybe the source code of the implementation so I can look it up?

      1 Reply Last reply Reply Quote 0
      • felmueF
        felmue
        last edited by

        Hello @insaneLX

        from earlier posts I assume you're trying with an M5Tough, correct?

        Well, I can confirm that write_single_coil fails with Value Error as soon as the value is different from 0.

        So, yes, I'd say it is broken. @m5stack could you please look into that. Thanks.

        BTW: other Modbus blocks like write_single_register work for me.

        Thanks
        Felix

        GPIO translation table M5Stack / M5Core2
        Information about various M5Stack products.
        Code examples

        1 Reply Last reply Reply Quote 1
        • I
          insaneLX
          last edited by insaneLX

          Felix, thanks for the reply.
          I was trying to use the write_single_coil as workaround. I wanted to use the write multiple coils function. But it does not have a parameter to set the number of coils to be written and the documentation is less than complete. Any ideas? How does the system know what to write?

          1 Reply Last reply Reply Quote 0
          • felmueF
            felmue
            last edited by

            Hello @insaneLX

            I think the multiple coils function takes a list, but it didn't work for me either.

            Thanks
            Felix

            GPIO translation table M5Stack / M5Core2
            Information about various M5Stack products.
            Code examples

            1 Reply Last reply Reply Quote 0
            • I
              insaneLX
              last edited by

              A list it is!

              try:
              ret = modbus.write_multiple_coils(comms.DEVICE_ADDRESS, 0,(
              sig.smoke_flap,
              sig.transport,
              sig.ignition,
              sig.smoke_fan,
              sig.extinguish,
              sig.flood,
              sig.ember_air,
              sig.alarm
              ), timeout=200)

              works nicely.

              1 Reply Last reply Reply Quote 2
              • P
                pandian.nano
                last edited by pandian.nano

                Hi, @insaneLX 0_1688369025206_5545b634-1765-460d-a5c1-c3d1ae46fd74-image.png
                0xff00(ON or 1) and 0x00(OFF or 0)

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post