This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Voltage sensor for an 8051

I am working on a home project in which I need a cheap voltage sensor. I need an 8051 to monitor the voltage that I am getting from the wall. All I want to do is monitor whether the voltage is on or off. If it is on then I need to switch to a back up power source. I guess I could use a current sensor if need be.

Thanks

  • If it is an DC Voltage, I would take an voltage divider by resistors. It should flow a current of a few mA. Then the divider isn't too sensitiv. You can protect the Port by an Shottkey Diod, if there could by spikes on the monitored voltage.

  • What voltage are you getting from the wall, 110VAC or 220VAC?
    There are a few ways you could do this:
    1) an opto-coupler in series with a resistor and high-voltage capacitor could be used to pull a pin to ground (with a pullup resistor to 5V)
    2) a relay with a coil rated for 220/110V operation (as appropriate), with one pair of contacts used to pull a pin to ground (with a pullup resistor to 5V)

    These solutions assume nothing about what is connected to the wall socket. If this is in fact generating the primary power for your circuit, then there might be a low voltage point you could monitor.
    Are you using a linear power supply (transformer->rectifier->filter caps->voltage-regulator), or a switch-mode supply?
    If it is a linear supply, then you could probably tap into the low voltage side of the transformer with a resistor divider network, to generate a pulsing waveform when AC is present. This would halt the moment power is lost, before the filter caps are discharged.