I'm wondering what the reason for doing it that way is?Pepepaco_82 wrote: I'm won't connect the output directly to the RPI, I'll use an I2C I/O expander that works at 5v, this is the reason to I'm looking for a 5v output.
I explain my reason to use an i2c I/O expander:I don't think it will add in any more protection - if mains get through the opto isolator then it's going to fry anything in its path - unless there's another opto isolator in the I2C...
So I think it's just adding complexity. I'd be really tempted to simply wire the GPIO pin to the collector of that opto transistor, enable the internal pul-up and wire the emitter to ground. you could put a little RC network there to smooth the signal, but it's probably not needed - just poll the pin for a second or so until it changes state and you'll soon see if it changes - change means power, no change means no power...
Yes, probably the title should be only "How to sense a 220v input". But if I had known how to do it I don't have to open this thread...I don't like the title of this thread.
In my opinion, anybody who wants to work with mains and calls it 'playing' is obviously no suited to do so.
As failure of your capacitor wouldn't pose a direct risk of electric shock then I'm suggesting a class X2 capacitor as X1 is really for industrial applications (although it wouldn't do any harm to use the heavier spec item). I'd be very happy if "proper" experts chime in here though btw!Class X is for applications where failure could not lead to electric shock (hot to neutral). Class X1 capacitors are intended to operate safely even in the presence of spikes on the mains supply of up to 4 kV (installation category 3 or overvoltage category 3 according to IEC60664), which are normally industrial supplies, but some standards call up class X1 capacitors if they are connected directly to the mains supply upstream of the equipment fuse, irrespective of the type of mains supply. Class X2 capacitors are intended to operate safely even in the presence of spikes on the mains supply of up to 2.5 kV (installation category 2 or overvoltage category 2 according to IEC60060), which are normally residential, commercial and light industrial supplies. X capacitors can be found from 0.001 uF to at least 10 uF and are only made in film.
Class Y capacitors are for applications where failure could lead to electric shock if the ground connection were lost. This includes hot/neutral to ground, and antenna isolation capacitors. Because Y capacitors shunt current to ground, leakage-current limitations limit their size to a maximum of about 4700 pF in many commercial and industrial applications (but refer to the relevant standard for definite information) and about 470 pF in medical applications. Larger ones are available however. Y caps are available from 1000 pF to 0.1 uF and are made in both film and ceramic.
Given how cheap plug in power adapters are nowadays, that is probably quite a sensible solution. I'm sure 3.3V ones are available too, which perhaps be better in this case.felix123 wrote:How about you plug in another 5v power adaptor into the mains and sense when that goes off?
That way no dangerous playing with the mains required.
Fixed that for you..Pepepaco_82 wrote: Yes, probably the title should be only "How to sense a 220v input".
That's got to be the simplest and cheapest alternative, and it keeps the "don't play with mains" people quiet.aTao wrote:Although my way would be to connect the output of a low voltage transformer to the mid point of a voltage divider between the PI power rails diode clamp the other terminal to the rails and feed straight into a GPIO (if Vdd+0.7 or Vss-0.7 will kill the input even with a high resistance voltage divider then use another divider to keep the input in range)
Users browsing this forum: the_ewan and 4 guests