0

Followed this thread on enabling the serial console on the Raspberry Pi 3B.

Checked the functionality using this code:

dmesg | grep tty

Which produced these results:

...
console [tty1] enabled
...
console [ttyAMA0] enabled

However, when I tried to use pymodbus, I couldn't even connect to the client. Used this code:

import pymodbus
from pymodbus.client.sync import ModbusSerialClient as ModbusSerialClient
from pymodbus.register_read_message import ReadInputRegistersResponse

client = ModbusSerialClient(method='rtu', port='/dev/ttyAMA0', stopbits=1, bytesize=8, parity='N', baudrate='9600', timeout=0.3)

connection = client.connect()

My Raspberry Pi 3B is not communicating with the energy meter (53U-1211-AD4/H), used the energy meter's T1, T2, T4 (GND) for the modbus connection. Used the RPI's UART pins 8 & 10 (GPIO14 & GPIO15).

Error:

...
self socket interCharTimeout = self.inter_char_timeout
...
AttributeError: 'NoneTyoe' object has no attribute 'interCharTimeout'

Anyone used pymodbus before? I've been on this for days, followed several threads on enabling the serial port to no avail.

1
  • I realise this is an old question but since it has been bumped... if you want to use the built-in UART for Modbus then surely you need to disable the serial console?
    – nekomatic
    Oct 7, 2019 at 15:08

1 Answer 1

0

You appear to be using an older OS - unspecified. TtyAMA0 is connected to Bluetooth - a current OS would use serial0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.