Skip to content

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

@Philj6321

Description

@Philj6321

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions