I want to detect 240Vac mains using the GPIO. Here is my plan (with questions below)...
Convert the 240Vac down to 5Vdc via a USB charger. This should give me Mains Power safely to both me and my home by just plugging in a standard cheap USB charger (5v DC, up to 1A output). Cut the USB cable and expose the wires, now I have 5v and GND lines.
Make a voltage divider to drop from 5v to 3.3v and into the GPIO pin. Something like this
Question 1: Should I put anything now in series (such as a resister and/or something else) to prevent too many Amps entering the GPIO. The USB outlet could supply up to 1A which is about 2000 times what the GPIO would tolerate I think. However I'm not sure that the RPi would draw that current? Excuse the electrical ignorance but could the plug "drive" a high current without me asking for it... Like a current source or something?
Question 2: Can anyone tell me if my plan is OK and if I could do it better, safer (for me or the RPi) or easier?