Mortimer wrote:Is the power rating of the resistor high enough? I don't think so.
Indeed. Especially as this was "solved" months back!
Needing a brain diversion this morning, so I'll do the calcs...
The data sheet for that opto isolator suggests 20mA at 1.2v for the LED side, so to drive that from 230v you need to drop 228.8v. R = V / I -> 228.8 / 0.020 = 11400Ω. Power dissipated: P = IV -> 0.020 * 228.8 = 4.58 watts.
So that ¼watt resistor will overheat and burn out (although it's 100K in your diagram, not the 12K actually needed to drive the LEDs) Using a 100K resistor reduces the current through the LEDs to ~2mA which may not be enough to actually light them up. (and will still dissipate over ½ watt)
So, with the 12K resistor to drive the LEDs properly, it's going to draw more power than a Pi draws - just to sense mains...
There is no easy solution though - as all the above messages testify to. Cheap and cheerfull (and arguably safest) is an old "wall wart" producing 5v which you can drop via a pair of resistors to 3.3v - however that's still going to idle away at 1-3 watts, depending on the design. (And may maintain output voltage with no load for many seconds, even minutes after power goes!) The next best solution is the R+C dropper but you need to get the soldering iron out then.
I don't think the original poster actually gave many more details of their setup or actual needs, but one thing I'm looking at shortly is using a Pi as a burglar alarm in a remote shed and also having it sense the mains and auto-switch to battery when it fails (rural location) - that makes it slightly easier for me as I can take a low-voltage output from the mains fed power supply which is feeding the Pi & charging the battery. (The Pi's doing a lot more than just an alarm, else an ATmega would be much more suitable, but since the Pi is there anyway...)