Hi,
this is not clear in your schematic, that the optocoupler drives the PNP.
Why do you use a optocoupler? It is not necessary as long as you don´t need isolation.
******
Solution for optocoupler and PNP:
Use schematic of post#3
* correct PNP connection (upside down)
* Use 470R as R1
* use 470R as "220R"
finsihed.
*********
Simple and working solution without optocoupler:
Needed: Relay, free wheeling diode, NPN, 470R, uC
* NPN E to GND
* NPN B to 470R
* 470R to uC port pin
* Relay + to 12V
* free wheeling parallel to relay
* NPN C to Relay- (and diode anode)
finished.
Klaus