Ok i have tried yesterday to switch the opto using 3.3 and it seems to work.
I have an other question about user interface.. I wanted to use the Teensy as modbus slave, but whit all the logic inside like industrial plc and the rpi as userinterface because of the display and the connectivity. But it is difficult to find some software wich is able to be modbus master and easy to program. I know some Industrial systems, they are verry similar (codesys, wincc...), but the open source things are more whit c/c++ implementation which makes me spend a lot of time learning this things. Somone can suggest me a open source scada system that runs on rpi and have maybee html5 support?