🤖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

    Scheduled Pinned Locked Moved UIFlow
    6 Posts 3 Posters 5.9k Views
    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 Offline
      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 Online
        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 Offline
          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 Online
            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 Offline
              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 Offline
                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

                Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                With your input, this post could be even better 💗

                Register Login
                • First post
                  Last post