Modbus connection toolhead

Hello!
I am designing an open source toolhead for my Ur3e.
On the electronic side I am a bit struggling with the modbus connection, which is needed to communicate with my urcap for controlling the gripper.
For the MCU I want to use a ESP module with attached camera. The tx rx lines would be converted to rs485 to use modbus mcu.

The problem:
Is the rs485 inside the robot arm line working with 5v or 3v3?

Thanks!

The Digital Inputs and outputs of the Tool I/O need at least 5.5V to trigger:

Sending to send data to a receiving unit attached to the toolhead via RS485 could be as easy as pulsing the I/Os of the toolhead to high and low.

Here is an example URscript to send a 16bit (unsigned) integer value via Digital out 9:
DO-8 and DI-8 are used to sync the communication and

def bit(input):
      msb=65536
      local i=0
      local output=0
      while i<17:
        set_digital_out(8,True)
        if input>=msb:
          input=input-msb
          set_digital_out(9,False)
        else:
          set_digital_out(9,True)
        end
        if get_digital_in(8):
          out=1
        end
        sync()
        set_digital_out(8,False)
        sync()
        input=input*2
        output=output*2
        i=i+1
      end
      return output
    end

to send the number 10 with this method you will have to call the bit() function like this:

data = 10 
data = data + 32768 
# to indicate that the number is positive: 32768 = 0 
bit(data) 

I am not sure if this is a workaround and wether there are better methods of using a Modbus or other communication protocols with the tool I/Os but this method should work even without a URcap that creates the Modbus server.

I am new to Modbus functions with UR though so take this information with a grain of salt if I misunderstood anything I would be glad if someone would correct me