Luca_Gibin
(Luca Gibin)
December 24, 2018, 10:29am
1
Greetings to the community.
I opened this topic to ask you for help configuring the relay board R421A08
My configuration:
raspberry pi2,
and this USB to RS485 adapter
(This adapter works well with raspberry + hassio because I use it to read energy consumption data from an EASTRON SDM220-MODBUS.
)
I did some tests and I could not make the R421A08 relay card work.
I used “Modbus Switch” but I did not succeed.
On the web I found this that could help us:
https://forum.logicmachine.net/showthread.php?tid=1403
opened 02:07PM - 07 Nov 17 UTC
closed 06:17AM - 16 Nov 17 UTC
Make sure you are running the latest version of Home Assistant before reporting an issue.
You should only file an issue if...
Some of you much more expert than me could help me, with the code to be written?
Thank you very much.
Luca_Gibin
(Luca Gibin)
December 25, 2018, 8:55am
3
Thanks for the reply but I still can not understand what I have to do. Could you help me?
I tried to do a lot of tests.
I changed the register, but I’ve never been successful.
For the register I followed these links:
#!/usr/bin/python
import minimalmodbus
rs485 = minimalmodbus.Instrument('/dev/ttyUSB0', 1)
rs485.serial.baudrate = 9600
rs485.serial.bytesize = 8
rs485.serial.parity = minimalmodbus.serial.PARITY_NONE
rs485.serial.stopbits = 1
rs485.serial.timeout = 1
rs485.debug = False
rs485.mode = minimalmodbus.MODE_RTU
print rs485
Volts = rs485.read_float(0, functioncode=4, numberOfRegisters=2)
Current = rs485.read_float(6, functioncode=4, numberOfRegisters=2)
Active_Power = rs485.read_float(12, functioncode=4, numberOfRegisters=2)
Apparent_Power = rs485.read_float(18, functioncode=4, numberOfRegisters=2)
Reactive_Power = rs485.read_float(24, functioncode=4, numberOfRegisters=2)
Power_Factor = rs485.read_float(30, functioncode=4, numberOfRegisters=2)
This file has been truncated. show original
https://forum.logicmachine.net/showthread.php?tid=1403
opened 02:07PM - 07 Nov 17 UTC
closed 06:17AM - 16 Nov 17 UTC
Make sure you are running the latest version of Home Assistant before reporting an issue.
You should only file an issue if...
Some registers are in the comments.
What am I doing wrong?
I saw that the communication LED sometimes flashes.
This is the last code loaded:
modbus:
type: serial
method: rtu
port: /dev/ttyUSB0
baudrate: 9600
stopbits: 1
bytesize: 8
parity: N
switch:
platform: modbus
slave: 1
coils:
- name: R1
slave: 1
coil: 40101
- name: R2
slave: 1
coil: 40002
registers:
- name: R3
slave: 1
register: 40002
command_on: 1
command_off: 0
- name: R4
slave: 1
register: 40003
command_on: 1280
command_off: 0
- name: R5
slave: 1
register: 40104
command_on: 01
command_off: 00
- name: R6
slave: 1
register: 01
command_on: 1
command_off: 0
Please can someone help me?
Thank you very much.
ruiazevedo
(Rui Azevedo)
February 5, 2019, 10:29am
6
I have the same problem.
Has anyone got the solution?
This equipment accect function Preset Multiple Registers (FC=16) , but the HA write registers whith de function Preset Single Register (FC=06) .
Has anyone know implement this function in HA?
ruiazevedo
(Rui Azevedo)
February 19, 2019, 2:51pm
7
I found a solution that works but I do not get feedback from the relay module.
I wrote a script in python, which uses the mobuspy and is called by a button in the homeassistantt with command line.
My file calls 8O.py, and the id RS485 is 7.
My scripy in python:
#!/usr/bin/python
#---------------------------------------------------------------------------#
# import the various server implementations
#---------------------------------------------------------------------------#
from pymodbus.client.sync import ModbusTcpClient as ModbusClient
# from pymodbus.client.sync import ModbusSerialClient as ModbusClient
from pymodbus.transaction import ModbusRtuFramer as ModbusFramer
#---------------------------------------------------------------------------#
# configure the client logging
#---------------------------------------------------------------------------#
import logging
import sys
# parametros de entrada
relay = int(sys.argv[1])
value = int(sys.argv[2])
logging.basicConfig()
log = logging.getLogger()
log.setLevel(logging.DEBUG)
#Define Modbus Target Device
client = ModbusClient(host='192.168.1.10',port=502)
connection = client.connect()
print (connection)
# send write command to modbus server
#600= off 300 = on
register_value = client.write_register(relay, value, unit= 7)
client.close()
#---------------------------------------------------------------------------#
In configuration.yaml:
platform: command_line
switches:
switch_1:
command_on: ‘python3 /config/8O.py 1 300’
command_off: ‘python3 /config/8O.py 1 600’
nickrout
(Nick Rout)
February 19, 2019, 9:14pm
8
Please please follow the instructions at he top of the page and format your code properly.
vornez
(Tim Pearson)
September 7, 2019, 2:04am
9
Windows application for STM8S103 & R421A085 module
Use this utility to toggle the relay settings. Ideal for Windows 7.
Written in MS Visual Studio WIN32 C++.
https://sourceforge.net/projects/rs485modbus/
nickrout
(Nick Rout)
September 7, 2019, 2:07am
10
What has this to do with home assistant?
alleonname
(Alleonname)
January 25, 2020, 10:01am
11
For 4 channel 4CH Modbus RTU relay module 4 ch relay module rs485
In configuration.yaml:
modbus:
- type: serial
name: hubrelay
method: rtu
port: /dev/ttyUSB1
baudrate: 9600
stopbits: 1
bytesize: 8
parity: N
timeout: 1
switch:
- platform: modbus
registers:
- name: Relay1
hub: hubrelay
slave: 1
register: 1
command_on: 256
command_off: 512
state_on: 1
state_off: 0
- name: Relay2
hub: hubrelay
slave: 1
register: 2
command_on: 256
command_off: 512
state_on: 1
state_off: 0
- name: Relay3
hub: hubrelay
slave: 1
register: 3
command_on: 256
command_off: 512
state_on: 1
state_off: 0
- name: Relay4
hub: hubrelay
slave: 1
register: 4
command_on: 256
command_off: 512
state_on: 1
state_off: 0
Wupsman
(Wupsman)
December 12, 2020, 8:07pm
12
Thanks alleonname for sharing your configuration with us, it worked right away for me with the R4D3B16:
modbus:
- type: serial
name: hubrelay
method: rtu
port: /dev/ttyUSB0
baudrate: 9600
stopbits: 1
bytesize: 8
parity: N
timeout: 1
switch:
- platform: modbus
registers:
- name: Relay1
hub: hubrelay
slave: 1
register: 1
command_on: 256
command_off: 512
state_on: 1
state_off: 0
- name: Relay2
hub: hubrelay
slave: 1
register: 2
command_on: 256
command_off: 512
state_on: 1
state_off: 0
- name: Relay3
hub: hubrelay
slave: 1
register: 3
command_on: 256
command_off: 512
state_on: 1
state_off: 0
- name: Relay4
hub: hubrelay
slave: 1
register: 4
command_on: 256
command_off: 512
state_on: 1
state_off: 0
- name: Relay5
hub: hubrelay
slave: 1
register: 5
command_on: 256
command_off: 512
state_on: 1
state_off: 0
- name: Relay6
hub: hubrelay
slave: 1
register: 6
command_on: 256
command_off: 512
state_on: 1
state_off: 0
- name: Relay7
hub: hubrelay
slave: 1
register: 7
command_on: 256
command_off: 512
state_on: 1
state_off: 0
- name: Relay8
hub: hubrelay
slave: 1
register: 8
command_on: 256
command_off: 512
state_on: 1
state_off: 0
- name: Relay9
hub: hubrelay
slave: 1
register: 9
command_on: 256
command_off: 512
state_on: 1
state_off: 0
- name: Relay10
hub: hubrelay
slave: 1
register: 10
command_on: 256
command_off: 512
state_on: 1
state_off: 0
- name: Relay11
hub: hubrelay
slave: 1
register: 11
command_on: 256
command_off: 512
state_on: 1
state_off: 0
- name: Relay12
hub: hubrelay
slave: 1
register: 12
command_on: 256
command_off: 512
state_on: 1
state_off: 0
- name: Relay13
hub: hubrelay
slave: 1
register: 13
command_on: 256
command_off: 512
state_on: 1
state_off: 0
- name: Relay14
hub: hubrelay
slave: 1
register: 14
command_on: 256
command_off: 512
state_on: 1
state_off: 0
- name: Relay15
hub: hubrelay
slave: 1
register: 15
command_on: 256
command_off: 512
state_on: 1
state_off: 0
- name: Relay16
hub: hubrelay
slave: 1
register: 16
command_on: 256
command_off: 512
state_on: 1
state_off: 0
galle
December 18, 2020, 5:48pm
13
hi i bought a modbus RTU relay (WAVESHARE).
i installed usb adapter in a raspb (it should be recognized directly as i read in posts.
to activate realay 1 I have to send a hex: 01 05 00 06 FF 00 6C 3B.
How can I do?
thanks
galle
December 18, 2020, 8:42pm
15
I tried to read.
But how i send a hex 01 05 00 06 FF 00 6c 3b to activate the relay?
nickrout
(Nick Rout)
December 18, 2020, 8:51pm
16
Are you sure this is modbus?
galle
December 18, 2020, 9:09pm
17
Yes.
I use “register” and “command on” but don’t work with 01 05 00 ecc.
galle
December 20, 2020, 3:14pm
18
I managed to activate the relays using the -call service- function:
modbus.write_coil
unit: 1
hub: hubrelay
address: 2
state: 1
but in my case -switch- and -binary sensor- of -modbus- don’t work
so I can’t read the status of the relays
nickrout
(Nick Rout)
December 20, 2020, 6:49pm
19
What is your binary_sensor:
yaml?
galle
December 20, 2020, 7:05pm
20
In configuratio.yalm…
binary_sensor:
platform: modbus
inputs:
name: Sensor1
hub: hubrelay
slave: 1
address: 3
a function as well as read coil?