To make sure the photodiode can turn ON/OFF the phototransistor, replace 5V with 3.3V.
As you said, H1G will be connected to I/O pin of the microcontroller, so it is not exactly 0v or 3.3V. Based on the datasheet page 27, low logic can be 0.4v, and high logic can be 2.9v. Connecting with 5V and photodiode in series will make it more difficult for calculating.
If you connect H1G in series with R5=150 Ohm, photodioda, and 3.3v, at worst scenario:
- High logic = 2.9v, If=0, because 3.3-2.9=0.4v is not enough to give the photodioda forward bias. The phototransistor OFF with If=0.
- Low logic = 0.4v, If=(3.3-0.4-1.3)/150=10.7mA (minimum value for this circuit)
With R5=150 Ohm, typical If=(3.3-1.15)/150=14.3mA (typical value for this circuit)
Maximum value of If=(3.3-1.0)/150=15.3mA (maximum value for this circuit)
It is a bit lower then typical value of If=16mA, so it is safe for the optocoupler.
How about for the microcontroller?
15.3mA is safe too, because the microcontroller has the maximum sink capacity 20mA
Can If=10.7mA turn on the MOSFET?
Let us see the datasheet at page 13.
From this picture, Ic < 6mA can make the phototransistor inside the optocoupler saturated with Vce < 0.2v. For Ic, lower is better (gives lower Vce). With R6 shorted, Ic = 12v-0.2/R10 = 1.2mA. With Vce ~ 0.2v, Vgs = 11.8v and the MOSFET ON.
Actually based on F1010N datasheet, Vgs threeshold is maximum 4V. So 5.9V or 6V is enough to make MOSFET saturated. You could short R6 or not.