5

Ok, so i am really keen to try replicate this project here

I'm still a noob and my knowledge of electronics stretch as far as making a light blink using an Arduino (Maybe a bit more).

I was thinking of using a ATmega328 instead of the ATtiny24A, because I can program it using my Arduino Uno like explained here

So this leads me to my question, how do I use coin cell batteries to power the ATmega328, maybe more specifically, what components will I need and why?

Anindo Ghosh
  • 50,188
  • 8
  • 103
  • 200
Donderbos
  • 53
  • 1
  • 3
  • 3
    It is possible to [program a ATtiny24A with an Arduino](http://code.google.com/p/arduino-tiny/). – Ignacio Vazquez-Abrams Nov 06 '13 at 09:49
  • @Ignacio: Am I right in thinking that the "core" is what allows the Arduino IDE to target the code for the specific AVR controller but that the ArduinoISP sketch allows you to use an Arduino as programmer to program any AVR controllers, even those for which you have no core, so long as you do your coding outside the Arduino IDE. [Ref](http://sdrmvrm.wordpress.com/2012/05/06/flashing-attiny85-via-arduino-isp-using-avrdude/) – RedGrittyBrick Nov 06 '13 at 09:56
  • @RedGrittyBrick: I am honestly not certain. I have a EvUSBasp (Baite USBasp clone) but no Arduino, so I've never actually used ArduinoISP myself. – Ignacio Vazquez-Abrams Nov 06 '13 at 09:59
  • 1
    An ATmega328 may be a bit power hungry for a coin cell, especially if you don't use sleep modes. – jippie Nov 06 '13 at 10:02
  • @RedGrittyBrick, your explanation is exactly correct. Ignacios link points to a core for ATtiny, and ArduinoISP works for any AVR controller. ATtinies are not much harder to program than ATmegas, and for smallish projects, it makes sense to pick a sensibly sized controller for the job, an ATmega328 is often a bit overkill. – microtherion Nov 06 '13 at 13:19

3 Answers3

6

You use coincells the same way you use any battery to power an AVR like the ATMega328p. You hook it up directly. That's it, nothing different. Positive to VCC & AVCC, Negative to VSS and AVSS.

Keep in mind, coincells have very little capacity, will drain quickly under 20+ milliamp load, so maximize the time you spend in power-save/sleep mode, and the low voltage will limit your clock speed to 4 or 8 or 10mhz at most.

enter image description here

enter image description here

Passerby
  • 72,580
  • 7
  • 90
  • 202
  • A decoupling capacitor, (I don't know exactly what it is, so if someone can explain to me in layman's terms that would be great) would I need to have this? – Donderbos Nov 06 '13 at 12:06
  • @HenkScheepers a decoupling cap is like a small energy bank. If the power line drops down a bit, the cap kicks in to keep the line up. A 0.1uf cap is typically recommended. – Passerby Nov 07 '13 at 05:28
6

Just to amplify some of the rather important points made in comments ...

Use an ATtiny24 not an ATmega328

The project you want to copy uses an ATtiny24 for good reasons.

[The] ATtiny24A microcontroller ... included all of the things the team were looking for – it was working with voltages as low as 1.8V, consumed small amounts of current and had enough i/o pins.

ATtiny24 vs ATMega328

  • lower cost
  • smaller package (DIP-14 vs DIP-28)

It has plenty of GPIO pins (~12) compared to a DIP-8 ATtiny45 for example (5-6).

If you are making a large constellation of interacting autonomous objects, you can get more for your money by using parts that are no bigger/expensive than they need be.

If money, size and power-consumption are no object, you might use a 144-pin AT32UC3C064C for maximum future flexibility. Personally I think half the fun of this sort of project is squeezing it into a small device.

Loading software

You can use an Arduino Uno to program (load software onto) an ATtiny24 on a breadboard.

To do this you first load an "ArduinoISP" program ("sketch") into your Arduino Uno. You can then use this to load programs onto an ATtiny24 or any AVR microcontrollers that allow loading software via an ISP interface (I think there may be one or two that don't).

If your Arduino IDE isn't set up for the ATtiny24 (see below) there are other free tools to compile programs and free programs to load those programs onto an ATtiny24 - for example avrdude

Compiling software for an ATtiny24

You can use the Arduino IDE to write and compile programs to run on an ATtiny24. To do so you add a suitable "core" to your Arduino IDE's "hardware" subdirectory (folder). You can obtain a suitable "core" from code.google.

Note that many online tutorials mention the "core" from High-Low-Tech at MIT but that "core" doesn't include the ATtiny24 so try the code.google "core" instead.

Using coin-cell batteries

See other answers - You should choose a microcontroller no more powerful than the minimum needed to do the job. Set the clock speed low. Shut down unused features and make maximum use of low-current sleep states. AVR has documentation that specifically covers low-power applications.

RedGrittyBrick
  • 14,602
  • 5
  • 37
  • 77
  • Thanks for the breakdown, can you maybe elaborate on the reasons why you think the ATiny24 is better suited for the project. Say for instance I want to switch the LED with a RGB LED, will the ATiny24 supply me with enough I/O pins? – Donderbos Nov 07 '13 at 07:30
  • @Henk: See revised answer - follow links to Data Sheets. – RedGrittyBrick Nov 07 '13 at 10:23
  • If you wish to use CR2032 batteries, have a look on this post: https://www.hackster.io/Talk2/temp-and-humidity-sensor-with-a-cr2032-for-over-1-year-580114 – Talk2 Dec 13 '16 at 05:12
1

Other than what you would need to run it on a breadboard, you will need a coin cell holder. That is, you will still have the same bypass, filter, and clock hardware as described in AVR042, "AVR Hardware Design Considerations". Also keep in mind that you should probably restrict your clock speed to 8MHz for safe operation down to about 2.5V.

Ignacio Vazquez-Abrams
  • 48,282
  • 4
  • 73
  • 102