UART MAX485 Module



  • 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.



  • This post is deleted!


  • This post is deleted!


  • This post is deleted!


  • 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



  • @ledbelly2142
    Please send me a PM with details.



  • @danielm
    I am also interested in this.



  • @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.


  • Pybytes Beta

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



  • @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



  • 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 ?



  • @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.



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



  • 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.


Log in to reply
 

Looks like your connection to Pycom Forum was lost, please wait while we try to reconnect.