• Stars
    star
    294
  • Rank 141,303 (Top 3 %)
  • Language
    Python
  • License
    MIT License
  • Created over 10 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A simple Modbus/TCP library for Python

pyModbusTCP badge_tests badge_docs

A simple Modbus/TCP client library for Python. pyModbusTCP is pure Python code without any extension or external module dependency.

Since version 0.1.0, a server is also available for test purpose only (don't use in project).

Tests

The module is currently test on Python 3.7, 3.8, 3.9, 3.10 and 3.11.

For Linux, Mac OS and Windows.

Documentation

Documentation of the last release is available online at https://pymodbustcp.readthedocs.io/.

Setup

You can install this package from:

PyPI, the easy way:

# install the last available release (stable)
sudo pip install pyModbusTCP
# install a specific version (here release v0.1.10)
sudo pip install pyModbusTCP==v0.1.10

From GitHub:

# install a specific version (here release v0.1.10) directly from github servers
sudo pip install git+https://github.com/sourceperl/[email protected]

Note on the use of versions:

Over time, some things can change. So, it's a good practice that you always use a specific version of a package for your project, instead of just relying on the default behavior. Without precision, the installation tools will always install the latest version available for a package, this may have some drawbacks. For example, in pyModbusTCP, the TCP automatic open mode will be active by default from version 0.2.0. It is not the case with previous versions and it just doesn't exist before the 0.0.12. This can lead to some strange behaviour of your application if you are not aware of the change. Look at CHANGES for details on versions available.

Usage example

See examples/ for full scripts.

include (for all samples)

from pyModbusTCP.client import ModbusClient

module init (TCP always open)

# TCP auto connect on first modbus request
c = ModbusClient(host="localhost", port=502, unit_id=1, auto_open=True)

module init (TCP open/close for each request)

# TCP auto connect on modbus request, close after it
c = ModbusClient(host="127.0.0.1", auto_open=True, auto_close=True)

Read 2x 16 bits registers at modbus address 0 :

regs = c.read_holding_registers(0, 2)

if regs:
    print(regs)
else:
    print("read error")

Write value 44 and 55 to registers at modbus address 10 :

if c.write_multiple_registers(10, [44,55]):
    print("write ok")
else:
    print("write error")

More Repositories

1

mbtget

A simple Modbus/TCP client write in pure Perl.
Perl
113
star
2

rpi.rtc

A Python module to deal with DS1302 RTC chip on Raspberry Pi
Python
28
star
3

smartplugctl

Little utility for control Awox BLE smartPlug SMP-B16-FR
Python
19
star
4

tiny.serial

Software UART for ATTiny85
C
17
star
5

millis

Implementation of millis() (like in Arduino IDE) on AVR microcontrollers ATTiny85
C
10
star
6

modbus-serial-monitor

Python script to check traffic between serial modbus RTU devices
Python
10
star
7

mbserverd

A simple modbus/TCP server write in pure Perl.
Perl
9
star
8

MBclient

Modbus/TCP client Perl module (pure Perl code)
Perl
9
star
9

arduino.yun.ikea-fado

Hack of an Ikea Fado lamp with Arduino Yun and RGB Neopixel. Use MQTT protocol to set the color.
Arduino
5
star
10

pymbserver

A python multithreaded modbus/TCP server (support function 1, 2, 3, 4, 5, 6, 15 and 16)
Python
5
star
11

docker.thingspeak

Docker container for thingspeak IoT platform (use compose for multi-container purpose)
4
star
12

rpi.backup

A useful set for backup or restore a Raspberry.
Shell
4
star
13

docker.mosquitto

Docker image for mosquitto MQTT broker.
4
star
14

py.sensor

Python tool for interface with Telecom Design Sensor platform
Python
3
star
15

sig2mqtt

Simple node.js gateway between Sigfox-backend HTTP callback and local MQTT broker
JavaScript
3
star
16

tiny.spi

Spi test with nRF24L01+ on an ATTiny84
C
3
star
17

msp430.nrf-scan

MSP430 with nRF24L01+ for scan ISM band
C
3
star
18

rpi.lcd-i2c

Raspberry Pi I2C LCD Python driver
Python
2
star
19

arduino.sendswitch

Tiny code for Arduino GSM shield (base on SM5100b chip) use to manage relay with SMS command.
Arduino
2
star
20

arduino.spybox

A tool to spy modbus RTU protocol on RS-485 differential line (arduino MKR Zero + MKR 485 shield)
C++
2
star
21

iot.server

Simple key/value storage server with embeded freeboard dashboard
JavaScript
1
star
22

msp430.uart

Still in dev. Don't use it !
C
1
star
23

arduino.serial-spy

A tool for spy serial line from an Arduino Mega 2560 and DUE
C++
1
star
24

docker.cookbook

Some useful docker images
Python
1
star
25

arduino.gsm_sms

Tiny code for manage SMS and RSSI on Arduino official GSM shield (base on Quectel M10 chip).
Arduino
1
star
26

rpi.servers

A list of pre-configured servers for Raspberry Pi platform
Shell
1
star
27

pyRedisMailGateway

A Gateway between Redis (pub/sub) and IMAP/SMTP mail protocols
Python
1
star
28

arduino.akeru

Arduino scripts for Snootlab Akeru Sigfox board
C++
1
star
29

utils

Shell
1
star
30

sigduino.solar

Solar station reporting with Arduino (ATMega328P 3V powered with 8 MHz XTAL, BOD set at 1.8V) and Sigfox UNB modem
C++
1
star
31

msp430.nrf-sender

Experimental (don't use it now)
C
1
star
32

ecotools

Python scripts to deal with energy consumption alert signals (ecogaz, ecowatt) of French grid operators
Python
1
star
33

rpi.webcam.pi3

A Raspberry Pi3 webcam project (Rpi camera + WPA WiFi access point with internal chip) β€”
Python
1
star
34

micropython.cookbook

Python
1
star