For starters though your zero detection circuit will not be producingFor starters though your zero detection circuit will not be producing the signal you expect - the LED in the PC814 will be illuminated for virtually all of one half of a mains cycle, that means the photo-transistor will be conducting and thus pull the pin going to the Raspberry Pi to around VCE(sat) above 0 volts which will be around 0.4 or 0.5 volts I expect. For the rest of the time the input to the Pi will be pulled up via the 33K; to get a pulse around the time of both zero-crossings (i.e. at a 100hz rate) you'll need to feed the PC814 LED via a bridge-rectifier circuit - without a smoothing capacitor. Um, I looked at a datasheet for this device and found that both those diode devices are optical emitters i.e. LEDs, the signalone further from the transistor symbol is not a reverse polarity protection device as I at first thought! That being said the waveform you expectshow as Pic2 is inverted - the LED in the PC814transistor will be illuminatedturned on and saturated for virtually all of onethe cycle half(one of the LEDs is illuminated except for a mains cycle, that meansvery small time around the photozero-transistor will be conductingcrossing) and thus pull the pin going to the Raspberry Pi to around VCE(sat) above 0 volts which will be low except for a very small time around 0.4 or 0.5 volts I expectthe zero-crossing. ForAlso the rest of33KΩ and 3.3 volt supply mean the timepeak Ic for the input totransistor is 0.1mA which is off the Pi will be pulled up viarange that is characterised in the 33K; to get a pulse arounddatasheet I saw, given the timecapabilities of both zero-crossings (ithe Pi's 3.e3V supply I'd drop that resistor to, say 6. at a 100hz rate) you'll need8KΩ to feedraise the PC814 LED via a bridge-rectifier circuit - without a smoothing capacitorcurrent to nearly 0.5mA which just about gets it onto the ranges shown on the graphs in the datasheet.
Having done that, toTo get a controllable power output you must start a timer as soon as you detect a zero crossing with a minimum of around half the width of the pulse (so that ideally you start the timer at the peak of the pulse which neglecting the turn-off time of the photo-transistor in PC814 is the point when the current though the load is passing through zero) and a maximum of a bit less than the half-cycle time (10 mSec for 50Hz mains) less the time you allowed at the start and the time you need for the pulse to turn the output TRIAC on - then when the timer has ended THEN you send that pulse to turn the output on for the time to the end of THAT half-cycle. The longer the delay before sending that pulse the less the power that gets put into the load.