Using a Atmega328 chip with 3.2 to 4.2 volts? (Battery powered)

Hi.

Im working on a headlamp project and I need some help.
I want to make a headlamp running on 4.2v lipo batteries. The battery voltage will vary between 3.2v and 4.2v (discharged and fully charged). The Atmega328 will be used to controll some LEDs (using DigitalWrite HIGH and LOW - this part is ok).

My "problem" is that I cant decide if I should run the Atmega at 5v or 3.3v? Can I connect the battery directly to the Atmega328 and use it as a 5v unit? In other words, can I program a 5v Arduino Nano using the USB port, then desolder the Atmega328 and solder it to my headlamp circuitboard with the lipo battery?

Use a unit set up for 3.3v operation (8MHz crystal/resonator) and power it directly off the battery, no regulator. This is usually what people do for battery powered applications off a single LiPo cell - you can keep the processor in deep sleep and have it use negligible current (if you had a regulator in there, it's quiescent current would be far more than that of a '328p in deep sleep.

Running at 16MHz and 3.2v is out of spec (though people generally report that it does, at least at room temperature).

If timing isn't critical, you can use the internal 8MHz oscillator.

Note that you need your sketch compiled for the clock speed that it's actually running at, and the fuses set for the clock source (internal or crystal) that you're using. I recommend using MiniCore rather than one of the default Arduino board defs for this.

Use an 8Mhz Pro Mini, normally sold as 3.3V units.

Remove the regulator, program with a USB to serial adapter.

Connect the LiPo direct to the VCC of the Pro Mini, through a fuse of course, you dont want to set fire to your head.

A headtorch that potentially stops working because the processor is used out of spec is not a good idea.

For battery powered Arduino boards, I recommend removing the power indicator LED in addition to the voltage regulator. Probably the board will be tucked away in an enclosure where you can't see that LED anyway so it's just wasting power for no good reason.

Thanks guys!

I have several 5v Arduino Nanos that I want to use (so that I dont have to buy new ones). To save components on my new circuitboard I want to power the Atmega328 directly from the lipo battery (3.2 to 4.2v), dropping the AMS1117 3.3. In this case the Atmega328 most work with 4.2v down to 3.2v. Is it still "best" to program it as a 3.3v board, or can I just use the 5v Arduinos Atmega328 processor as is, and resolder it to my own circuitboard? This would make it all much easyer for me.
Also in this case, can I drop the crystal and two capacitors?

Low power mode is not that imporant here cause I will be recharging the headlamp battery after use.

If you don't need precise timing, you can configure the 5 V Nano to use its internal 8 MHz oscillator in order to run within spec at the lower voltage. Here's the easiest way to do that:

  • Install MiniCore, following these instructions: GitHub - MCUdude/MiniCore: Arduino hardware package for ATmega8, ATmega48, ATmega88, ATmega168, ATmega328 and ATmega328PB
  • Tools > Board > ATmega328
  • Tools > Clock > 8 MHz Internal
  • Connect an ISP programmer to the target Nano. If you don't own an ISP programmer, you can use a spare Arduino board (such as your extra Nano) as an "Arduino as ISP".
  • Plug your ISP programmer in to your computer.
  • If you're using an "Arduino as ISP", select its port from the Tools > Port menu.
  • Tools > Programmer > select the appropriate programmer
  • Tools > Burn Bootloader - This will set the fuses to use the internal oscillator.
  • Wait for the Burn Bootloader process to finish.

After this, remember to use the Tools > Board > ATmega328 board selection, rather than Tools > Board > Arduino Nano.

HansiFansi:
can I drop the crystal and two capacitors?

When using the internal oscillator, they are not necessary. However, you don't need to remove them.

Thanks pert! Will try this