Using a diode to ensure current flows in only one direction, without causing a voltage drop
An actual diode is limited by the laws of Physics [tm]. Actual voltage will depend on current and voltage and device used but, as a guide, under very light loading a Schottky diode may manage somewhat under 0.3V but this typically rises to 0.6V + as loading approaches maximum allowed. High current devices may have forward voltage drops of well over 1V. Silicon diodes are worse by a factor of two to three.
Using a MOSFET in place of a diode provides a resistive channel so that voltage drop is proportional to current and can be much lower than for a diode.
Using a P Channel MOSFET as shown below causes the MOSFET to be turned on when the battery polarity is correct and turned off when the battery is reversed. Circuit and others from here I have used this arrangement commercially (using the mirror image arrangement with an N Channel MOSFET in the ground lead) for a number of years with good success.
When the battery polarity is NOT correct the MOSFET gate is positive relative to the source and the MOSFET gate source 'junction' is reverse biased, so the MOSFET is turned off.
When the battery polarity is correct the MOSFET gate is negative relative to the source and the MOSFET is correctly biased on and load current "sees" on the FET Rdson = on tresistance. How much this is depends on the FET chosen but 10 milliohms FETs are relatibely common. At 10 mOhm and 1A you get only 10 milli-Volt drop. Even a MOSFET with Rdson of 100 milliohm will only drop 0.1 Volt per amp carried - far less than even a Schottky diode.
TI application note Reverse current / battery protection circuits
Same concept as above. N & P channel versions. MOSFETs cited are examples only. Note that the gate voltage Vgsth needs to be well below the minimum battery voltage.
You do not want an as low as possible voltage drop. The ATmega8 is specified for 2.7 V to 5.5 V operation, and that 5.5 V is actually 5.0 V with some margin. In the datasheet you'll see many parameters specified at 5 V.
Your supply voltage is ~5.4 V. What does the "~" mean? That it may vary by a few percent? 3 % higher gives you 5.56 V, which is out of spec. It won't cause the AVR to go up in flames, but it's a good habit to stick to the specs.
So let the voltage drop. Allow a 500 mV drop. The ATmega will consume only a couple tens of mA. A 1N4148 will drop typically 900 mV at 50 mA, which I would accept gladly, but which you may find too high. In that case go for the Schottky, like also suggested in other answers. You don't want a Schottky diode with a 100 mV drop, go purposely for one with worse specs. This one will drop 450 mV at 100 mA.
Two ideas:
- Use a Schottky diode instead of the normal PN junction diode. Schottky diodes have less voltage drop than PN diodes.
- Connect the diode across the supply so that it is normally reverse biased. When the power is connected backwards the diode will conduct and prevent the reverse voltage from exceeding the diode's forward voltage drop. You will need a current-limited supply or a fuse upstream of the diode so that it isn't asked to carry unlimited current.