-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Serial problem on RPi Pico W #43
Comments
Hello @animalmutch
In the new versions works fine to me: >>> from umodbus.serial import Serial as ModbusRTUMaster
>>> rtu_pins = (17, 18)
>>> host = ModbusRTUMaster(baudrate=115200, data_bits=8, stop_bits=1, parity=None, pins=rtu_pins, ctrl_pin=15)
>>> |
Thanks for your swift reply @beyonlo . I am using version 2.1.1 of the lib (seems to be the latest release). I am not installing using upip, because upip doesn't seem to come bundled with micropython any more (they use mip instead now). I am using the latest UF2 from raspberrypi.com (https://micropython.org/download/rp2-pico-w/rp2-pico-w-latest.uf2):
Using the exact same code as you above, I get the following: Seems most likely there's an issue with using the lib without installation. Can you advise any further on installation on RPi pico? |
Relates to #17 |
@animalmutch according to the MicroPython v1.19.1 RP2 UART docs the RX and TX pins shall be specified as The following example should work for you on a RP2 >>> from umodbus.serial import Serial as ModbusRTUMaster
>>> rtu_pins = (Pin(4), Pin(5)) # TX, RX
>>> host = ModbusRTUMaster(baudrate=115200, data_bits=8, stop_bits=1, parity=None, pins=rtu_pins, ctrl_pin=15)
>>> Additionally the UART pins on RP2 can only be GPIO 4/5 or 8/9 for UART1 according to the docs
which explains your
But there is also a not yet implemented feature in this lib (never call it bug 🤦 ), see micropython-modbus/umodbus/serial.py Line 58 in 4699684
uart_id is always set to 1 without the possibility to change it on ModbusRTU class level. So I assume the UART0 can not be used with pins GPIO 0/1, 12/13 and 16/17
|
Thanks so much @brainelectronics ! I get it now, and it's working. It was just a mismatch between the pins I was using and the UART ID. For reference, the following works perfectly:
For some reason Pin(4) and Pin(5) with uart_id=1 doesn't work (well, it doesn't cause a problem with your lib, but it physically doesn't work still, so perhaps a hardware issue). Anyway, thanks again! |
Resolved by #45 |
Hi Friend, Could you please share connection diagram ? |
Issue:
When creating a modbus master on RPi Pico W, you get the following error:
If you create Pin objects and use these instead, you get the following error:
The text was updated successfully, but these errors were encountered: