Skip to content
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

Does this require a specific micropython firmware version ? APPARENTLY NOT #92

Open
Philj6321 opened this issue May 30, 2024 · 1 comment

Comments

@Philj6321
Copy link

Philj6321 commented May 30, 2024

Description

UPDATE - I've just tested it with firmware release v1.23 -0 and it works, at least the provided samples seem to.

I've tried for most of the day yesterday to get this to work with a Pico W - any examples I can find seem to use an earlier version of Micropython (Micropython v1.19.1-1008-gc046b23ea)

No matter what I do I always get this error returned. (See log output)

Reproduction steps

...

MicroPython version

v1.22.2

MicroPython board

Raspberry Pico

MicroPython Modbus version

2.3.7

Relevant log output

MPY: soft reboot
waiting for wifi connection...
waiting for wifi connection...
waiting for wifi connection...
Connected to WiFi, Pico W IP : 192.168.10.171
Traceback (most recent call last):
  File "<stdin>", line 64, in <module>
  File "/lib/umodbus/tcp.py", line 86, in __init__
OSError: [Errno 103] ECONNABORTED

User code

import time
from umodbus.tcp import TCP as ModbusTCPMaster
import network


# =============================================
# connect to a wifi network

station = network.WLAN(network.STA_IF)
if station.active() and station.isconnected():
    station.disconnect()
    time.sleep(1)
station.active(False)
time.sleep(1)
station.active(True)

station.connect("MY_SSID", "PASSWORD")
time.sleep(1)

while True:
    print('waiting for wifi connection...')
    if station.isconnected():
        print(f'Connected to WiFi, Pico W IP : {station.ifconfig()[0]}')
        break
    time.sleep(1)

# TCP Slave setup
port = 502
slave_addr = 1
ireg_address = 0
register_qty = 2

# IP Address of Modbus TCP Server
ip = '192.168.10.171'

# Setup Modbus TCP Client
modbus_client = ModbusTCPMaster(slave_ip=ip,slave_port=port,timeout=5)
print(f'Resquesting data from modbus TCP Server at {ip}:{port}')

register_value = modbus_client.read_input_registers(slave_addr, starting_addr=ireg_address, register_qty= register_qty)
print('Status of IREG from {} to {}'.format(ireg_address+register_qty, register_value))

Additional informations

No response

@Philj6321 Philj6321 changed the title Does this require a specific micropython firmware version ? Does this require a specific micropython firmware version ? APPARENTLY NOT Jun 3, 2024
@algorni
Copy link

algorni commented Nov 7, 2024

+1 using a raspi pico 2 for the RTU and getting:

MPY: soft reboot
Traceback (most recent call last):
File "", line 5, in
File "/lib/umodbus/serial.py", line 19, in
ImportError: no module named 'umodbus.functions'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants