Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    UART MAX485 Module

    Scheduled Pinned Locked Moved WiPy 2&3
    wipy uart rs485
    14 Posts 6 Posters 5.9k Views 7 Watching
    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.
    • B Offline
      bnjroos
      last edited by

      Good evening,

      I am currently trying to communicate with a modbus slave in RS485. For that I am using a MAX485 UART TTL to RS485 module for Arduino (http://yourduino.com/sunshop//index.php?l=product_detail&p=323).

      I have wired as followed:
      WiPy -> MAX485 Module
      P3 -> DI
      P4 -> RO
      P7 -> DE/RE jumped
      5V -> VCC
      GND -> GND

      I use a library adapted from minimalmodbus for modbus, however when I try to communicate with my slave, the response is always a chain of b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ ...

      Any idea where that would be coming from ?

      from machine import UART
      import utime
      import ModBus
      uart = UART(1, baudrate=9600)
      uart.init(9600, bits=8, parity=None, stop=1,pins=('P3','P4','P7',None))
      instrument = ModBus.Instrument(uart,0x01,mode=ModBus.MODE_RTU)
      print(instrument)
      v = instrument.read_registers(2,2)
      print(v)
      

      I have tested the modbus library with a uart mockup with success, so i think it might be a hardware issue.

      Thank you in advance.

      1 Reply Last reply Reply Quote 0
      • Jurassic PorkJ Offline
        Jurassic Pork
        last edited by Jurassic Pork

        hello,
        be carefull :
        The GPIO pins of the pycom modules are NOT 5V tolerant, connecting them to voltages higher than 3.3V might cause irreparable damage to the board.

        your rs485 module uses a MAX485 which is a 5V chip.
        for the RO pin the specification voltage is :
        Receiver Output Voltage :
        RO -0.5 to (VCC+0.5) V
        may be you must use a module with a 3.3V chip as the MAX3485 and powers it with 3.3V .
        example : SparkFun Transceiver Breakout - RS-485
        alt text
        Fully equipped with SP3485 RS-485 transceiver and supporting components
        Operates from a single +3.3V supply
        May be i am wrong. If someone can confirm what i have said.

        B 1 Reply Last reply Reply Quote 0
        • D Offline
          danielm
          last edited by

          I successfully used MAX3485 with LoPy with my code acting as ModBus slave with range of input registers.

          U ledbelly2142L 2 Replies Last reply Reply Quote 0
          • B Offline
            bnjroos @Jurassic Pork
            last edited by

            @Jurassic-Pork said in UART MAX485 Module:

            hello,
            be carefull :
            The GPIO pins of the pycom modules are NOT 5V tolerant, connecting them to voltages higher than 3.3V might cause irreparable damage to the board.

            your rs485 module uses a MAX485 which is a 5V chip.
            for the RO pin the specification voltage is :
            Receiver Output Voltage :
            RO -0.5 to (VCC+0.5) V
            may be you must use a module with a 3.3V chip as the MAX3485 and powers it with 3.3V .
            example : SparkFun Transceiver Breakout - RS-485
            alt text
            Fully equipped with SP3485 RS-485 transceiver and supporting components
            Operates from a single +3.3V supply
            May be i am wrong. If someone can confirm what i have said.

            I just had a look at the datasheet and I think you're right, I am gonna order a SP3485 before going further.

            Jurassic PorkJ 1 Reply Last reply Reply Quote 0
            • Jurassic PorkJ Offline
              Jurassic Pork @bnjroos
              last edited by

              hello,
              @bnjroos
              are you using an expansion board with your WiPy module ?
              The expansion board connects P0=RX0, P1=TX0, P4=SD-CMD, P8=SD-DAT0, P9=LED, P10=button, P16=Vbat, P19=CTS, P20=RTS, P23=SD-CLK.
              If you use an expansion board, maybe you must use another pin than the P4 pin for RO.
              @danielm how have you connected your Lopy to your MAX3485 ?

              B 1 Reply Last reply Reply Quote 0
              • B Offline
                bnjroos @Jurassic Pork
                last edited by

                @danielm said in UART MAX485 Module:

                I successfully used MAX3485 with LoPy with my code acting as ModBus slave with range of input registers.
                Thank you or the info.
                Good to know, me I am trying to make it act as a master. I will continue my tries once I receive my SP3485.

                Yes I am using the expansion board and the wipy version 2.0. Actually it comes from the documentation quickref: # this uses the UART_1 default pins for TXD and RXD (P3 and P4)
                from pycom

                @danielm I am also interested on how you wired your setup, thank you in advance :p

                1 Reply Last reply Reply Quote 0
                • U Offline
                  urbanzz Pybytes Beta @danielm
                  last edited by

                  @danielm Hello! Could you share your modbus library?Can it acts as Modbus Master? (in oder to get data from another slaves)

                  1 Reply Last reply Reply Quote 0
                  • D Offline
                    danielm
                    last edited by

                    @urbanzz
                    There is no library, I only wrote simple ModBus client routine which waits for a specific type of command and sends back data from internal register including CRC. If you need ModBus master functionality for commercial purposes, I can help you with that.

                    1 Reply Last reply Reply Quote 0
                    • ledbelly2142L Offline
                      ledbelly2142 @danielm
                      last edited by

                      @danielm
                      I am also interested in this.

                      Friends don't let friends run with scissors

                      D 1 Reply Last reply Reply Quote 0
                      • D Offline
                        danielm @ledbelly2142
                        last edited by

                        @ledbelly2142
                        Please send me a PM with details.

                        1 Reply Last reply Reply Quote 0
                        • V Offline
                          vicu
                          last edited by

                          Hello,
                          any update on this?
                          I have some old modbus plc lying around and i'm trying to use my lopy to communicate as a modbus master with a SP3485 breakout board...but i cannot find a decent modbus library for micropython

                          B 1 Reply Last reply Reply Quote 0
                          • B Offline
                            bnjroos @vicu
                            last edited by bnjroos

                            This post is deleted!
                            B 1 Reply Last reply Reply Quote 0
                            • B Offline
                              bnjroos @bnjroos
                              last edited by bnjroos

                              This post is deleted!
                              B 1 Reply Last reply Reply Quote 0
                              • B Offline
                                bnjroos @bnjroos
                                last edited by bnjroos

                                This post is deleted!
                                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
                                • 1 / 1
                                • First post
                                  Last post

                                Pycom on Twitter

                                Pycom