0

I am writing a PyModbus asynchronous updating server based on the example on the Pymodbus Asynchronous Server Example and I want to link the states of the coils to GPIO pin states, such as when coil 1 is True pin 21 is high and when coil 1 is False pin 21 is low without having a separate client check the coil status. Is it possible to link the coil directly to the pins? I am using a PI Zero for this project.

If you want to look at my code here the link to my git. I know the value are stored in a variable. I am not sure where I can pull them from to link them to the pins and have them regularly get updated.

2
  • As far as i can tell this is a general programming question.
    – joan
    Commented Jul 1, 2021 at 20:01
  • @joan I thought so too so posted in both places, but I thought maybe someone on here might of done something similar.
    – Michael H.
    Commented Jul 1, 2021 at 22:47

1 Answer 1

0

I was using the getValue command wrong before.

Within the updating_writer I used:

coils = context[slave_id].getValues(function,register,amount)

doing this I can now set a conditional statement to change the GPIO pins.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.