Here is the solution that I use for the extended I / O in output in order to control relays in 24V.

0_1639401298748_IMG_6746.JPG

The connection is almost identical except GND and VCC.
VCC must not be connected for use> 5V.

0_1639401896631_Image1.jpeg