Modbus Master crashes and missing documentation
-
Hi,
I am trying to create a modbus master application in micropython. I cannot figure out how to use the write_single_coil register as I get a ValueError: Illegal coil value when using following line:
modbus.write_single_coil(1,0, 1, timeout=500)Also, the documentation on Modbus is really flaky - can you point to some examples or maybe the source code of the implementation so I can look it up?
-
Hello @insaneLX
from earlier posts I assume you're trying with an M5Tough, correct?
Well, I can confirm that
write_single_coil
fails withValue Error
as soon as the value is different from 0.So, yes, I'd say it is broken. @m5stack could you please look into that. Thanks.
BTW: other Modbus blocks like
write_single_register
work for me.Thanks
Felix -
Felix, thanks for the reply.
I was trying to use the write_single_coil as workaround. I wanted to use the write multiple coils function. But it does not have a parameter to set the number of coils to be written and the documentation is less than complete. Any ideas? How does the system know what to write? -
Hello @insaneLX
I think the multiple coils function takes a list, but it didn't work for me either.
Thanks
Felix -
A list it is!
try:
ret = modbus.write_multiple_coils(comms.DEVICE_ADDRESS, 0,(
sig.smoke_flap,
sig.transport,
sig.ignition,
sig.smoke_fan,
sig.extinguish,
sig.flood,
sig.ember_air,
sig.alarm
), timeout=200)works nicely.
-
Hi, @insaneLX
0xff00(ON or 1) and 0x00(OFF or 0)