Here is the solution that I use for the extended I / O in output in order to control relays in 24V.
[image: 1639401300762-img_6746-resized.jpg]
The connection is almost identical except GND and VCC.
VCC must not be connected for use> 5V.
[image: 1639401897823-image1-resized.jpeg]