ATTINY85 & Batteries

I'm building a motion activated nightlight. I got it working on a breadboard with an arduino board, but will be programming an ATTINY85 chip to use with it instead of the Arduino (http://hlt.media.mit.edu/?p=1695)

My original post with schematics in case anyone is wanting to build something similar is at Motion & Light Activated Night-light (lights up if it's dark & there is motion) - #3 by system - Project Guidance - Arduino Forum

(I haven't yet decided on what kind of enclosure I will use yet.)

Anyway, I'm at the point of needing to figure out battery power. I am hoping to use something small like a CR2032 battery (http://search.digikey.com/us/en/products/CR2032/N189-ND/704858)

This is listed as 3v , I'm not sure if that will be good enough or even if it powers everything how long this battery will last.

These are parts I will be using:

Will a CR2032 battery be enough to power this (for at least a couple of months?) or should I consider a 9V battery?

If I use a 3v CR2032 battery, do I need a resistor of some kind (to the ATTINY85 chip)? The chip is rated as below so I believe I will be ok, and the PIR and Photosensor already have resistors (but this setup is currently working on 5v from the Arduino...)

The ATTINY85 is rated as:
Voltage - Supply (Vcc/Vdd): 2.7 V ~ 5.5 V

If I use a 9v battery I'm sure I will need something to bring down the voltage, I'm just trying to grasp OHMs law, based on my notes I have these forumulas:

Voltage: V = IR
Current: I = V/R
Resistance: R = V/I
PowerP = VI or P = V2/R or P = I2R

But I'm not sure if V = 9 (for 9v battery), or if V = 5 (say, if I wanted to replicate the 5v my Arduino is providing now)

Once I confirm what I should set "V" to in the formulas, I need to find resistance, but not sure what the current is on a 9V battery?

Any advice or guidance on this would be much appreciated.

Thanks

An LED will likely need at least 8-10mA. While the CR2032 has a capacity of 240mAh, it's not designed to supply that much current for very long. In fact, the rated 240mAh capacity is at a current of only 190µA. You don't say how long the LED will be on (all night?), but I think a CR2032 will be disappointing.

A 9V battery is too much voltage, so a regulator is needed, and they have lousy capacity besides. Best bet is 2xAA alkaline cells. Good capacity, and a good voltage for the job. 2xAAA will be smaller of course, but they only have roughly half the capacity of AA cells. Are you planning to use a sleep mode?

Thanks. To clarify, the LED will only come on when motion is detected AND when the room is dark.

2 x AA makes sense, and sounds like I won't need any resistor right?

Depends on the LED's specs, I find that 100? works well for most 5mm garden-variety types and a 3V supply.

Thanks, I bought some bright LED's since I want this to light up the room as much as possible when motion is detected (and it's dark)

These are the specs of what I bought:

I bought the BLUE ones, which are listed at 3.4 volts. I'm not clear on what the other columns are and so what number I would use as the amps in an OHM's law equation to figure out what Ohms resister I need?

Any ideas?

Thanks

Well then it may be difficult to use a 3V power supply and drive it to something close to full brightness. Or not; sometimes we don't know until we try it. If 3V is too little, then 3xAA could be used for a 4.5V supply and the ATtiny85 will be happy with that as well.

MCD is milli-candelas, a measure of brightness. Reverse current isn't of much interest since we don't plan to reverse-bias the diode. "Power" angle I assume is really "viewing" angle, i.e. how wide, in degrees, is the cone of light emitted. So these are fairly narrow-beam LEDs.

This is a compromise situation. We want the LED to be bright enough, but if it's brighter than it needs to be, then that just represents unnecessary power drain. The data sheet specs are given at a forward current (If) of 20mA. I find that I can usually run an LED at a lower current than the specs are given at. So what I usually do is grab an assortment of resistors, along with a meter, and determine what works for a given supply voltage and a given LED.

So given the specs, no resistor should be needed at 3V, although I might try something small first, maybe 10?, just to be safe. Calculate the current by measuring the voltage across the resistor and applying Ohm's law: I = V / R.

To run on a 4.5V supply, the resistor needs to drop 4.5 - 3.4 = 1.1 volts (using the "typical" value of 3.4V). For 10mA, we'd need R = V / I = 1.1 / 0.010 = 110?. 100? might be easier to find, and is close enough. For 15mA, 1.1/0.015 = 73?, I might use the common 68? value, which would give 1.1/68 = 16.2mA. Finally, a 56? resistor would give 19.6mA.

Maybe that seems complicated or excessive just to light an LED, but that's what it takes to do it properly, and keep everything within specs. I'd also keep to 20mA or less, so as not to overload the MCU. Hope that helps.

thanks so much! I really appreciate all the detail, it's difficult with no electronics background to figure all this out.

I'll be digesting all of that shortly :stuck_out_tongue: