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_coilfails withValue Erroras 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_registerwork 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)
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login