user28387204
user28387204

Reputation: 11

minimalmodbus ErrorSlave reported illegal function

I'm having problem with minimalmodbus library. The slave does not recognise the functioncode and shows ErrorSlave reported illegal function, I want to request a read on an input register. I'm using the Raspberry Pi 4 Model B. I'm using the Geolux RSS-2-300WL Flow Rate Sensor as a slave.

What i did is mention the functioncode=4.

#!/usr/bin/env python3

# Import all library needed
import minimalmodbus
import serial
import time
import logging

# Configuration of the sensor
geolux = minimalmodbus.Instrument('/dev/ttySC0', 1) #(port number, slave ID)
geolux.serial.baudrate = 9600
geolux.serial.bytesize = 8
geolux.serial.parity = serial.PARITY_EVEN
geolux.serial.stopbits = 1
geolux.serial.timeout = 1 

# Main Loop
try:
    while True:
        try:
            # Read raw reading for water level
            water_level_raw = geolux.read_register(0x0012,2,functioncode=4) #(address register, byte read) 
            print(f"Raw water level: {water_level_raw}")

The error is: error message

The data sheet from the device manual is: register details from manual

Upvotes: 1

Views: 48

Answers (0)

Related Questions