element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum How to run my atmega 328 chip from 4 AAA batteries?
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 23 replies
  • Subscribers 405 subscribers
  • Views 3221 views
  • Users 0 members are here
  • embed
  • atmega328
  • power
  • arduino
  • aaa
Related

How to run my atmega 328 chip from 4 AAA batteries?

Former Member
Former Member over 11 years ago

Hello,

 

Im currently working on my first real noobish project, its a temp/moisture sensor for my brother for his organic garden,

i have all my leds and 330 resitors soldered on, but i need to know waht componets i need to take 4 AAA batteries and power my chip without the Arduino,

everything can fit into the container i want it in (an altoid can) but i need to know what resistors/capactors or regukaters i need ino order to safely run my hardware.

 

also what ways can i use my multimeter so i can measure the volts and amps, so i can calculate how long the batteries would power the device.

I hear alot of great things about the element 14 community and i cant wait to hear what you guys have to say image

  • Sign in to reply
  • Cancel
  • Robert Peter Oakes
    0 Robert Peter Oakes over 11 years ago

    Hi there, nice to have you aboard

     

    first things first

     

    Can you draw up a sketch of what you envision , on paper then a cell phone picture if necessary but layout what your trying to do showing all the various components, battery, sensors, led outputs, displays, micro-controller etc

     

    You say without an Arduino, what do you mean by that, are you going old school analogue or digital or still keeping a microcontroller in the system

     

    is that a count of 330 resistors or a resistor of 330 Ohms ?, how many LEDs, how are you sensing or planning to sense temp and humidity, see if you can show this in your diagram

     

    Then we can be better prepared to help

     

    Thanks and look forward to your response

     

    Peter

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • jadew
    0 jadew over 11 years ago

    He's probably trying to run the chip by itself, with out the arduino board.

     

    Thing is that you'll have 6V and you only need 5V or less. To get 5V from 4 batteries you will need a LDO (voltage regulator with low voltage drop), however that's wasteful. A better approach would be to just use 3 batteries, which will give you 4.5V tops and run your chip from that - no regulator required.

     

    That aside, you will need decoupling caps on each VCC input (100nF ceramic caps), maybe an electrolytic cap too (of a few uF) across the rails and that's about it. Make sure you enable brown out detect, so the chip shuts down on under voltage - that way you'll know for sure that it won't start malfunctioning when the batteries run out.

     

    Another thing you might want to do is to increase the value of those resistors a bit. The less current you draw, the more your batteries will last.

     

    To get an idea about how long the batteries will last, you can measure the current consumption of your circuit and divide the mAh rating of the battery by that number. The real number will be smaller, since the voltage also drops as the battery is discharging and it will reach a point where you can't use it anymore, way before the battery is fully discharged. To get a better idea of how long the battery will last with your load, you can check the datasheet of your batteries, where you should find some discharge curves.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Robert Peter Oakes
    0 Robert Peter Oakes over 11 years ago in reply to jadew

    As an option he could also use the TI Battery Booster pack. Even though it is not plug compatible, it will easily work with an Arduino using jumpers and has nothing specific to an MSP/Launch Pad system. In my review I even had an Arduino talking to it to prove the fact.

    Using a single battery (LIPO) and two buck/boost regulators providing 3v3 and 5v

     

    a neat little package see here http://www.element14.com/community/roadTestReviews/1712

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago in reply to Robert Peter Oakes

    hey ive been busy ill give you all info and pics in a few days so you can help me out, just had a long 50 hour work week and it ate all of my free time up.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Robert Peter Oakes
    0 Robert Peter Oakes over 11 years ago in reply to Former Member

    I know the feeling, Look forward to the additional info

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago in reply to Robert Peter Oakes

    ,here is my setup, and i want to power the chip with just 3- 4 AAA batterys

    imageimageimage

     

    Here is my code :

     

    int soundPin  = 2;

    int ledPwerPin  = 6;

    int ledAlrm1Pin  = 12;

    int ledAlrm2Pin  = 13;

    int ledTempPin [] = {7,8,9,10,11};

    const int tempPin  = 0;

     

     

    void setup() {

      // put your setup code here, to run once:

      pinMode(soundPin, OUTPUT);

      pinMode(ledAlrm1Pin, OUTPUT);

     

      pinMode(ledAlrm2Pin, OUTPUT);

       pinMode(ledPwerPin, OUTPUT);

      pinMode(ledTempPin[0], OUTPUT);

      pinMode(ledTempPin[1], OUTPUT);

      pinMode(ledTempPin[2], OUTPUT);

      pinMode(ledTempPin[3], OUTPUT);

      pinMode(ledTempPin[4], OUTPUT);

     

      Serial.begin(9600);

    }

     

     

    int alarmSpeed = 9;

    int waitPerphMode = false;

     

     

    //////main process

     

     

    void loop() {

     

     

    float voltage, degreesC, degreesF;

     

     

    digitalWrite(ledPwerPin, HIGH  ) ;

     

     

    voltage = getVoltage(tempPin);

    degreesC = (voltage - 0.604) * 100.0;

    degreesF = degreesC * (9.0/5.0) + 32.0;

     

     

     

     

    if (degreesF > 100 && degreesF <= 105 ) { alarm1(); }

        else if (degreesF > 102) { noPerph(); }

     

     

    if (degreesF > 16.6) { digitalWrite(ledTempPin[0],HIGH ); }

        if (degreesF < 16.6) { digitalWrite(ledTempPin[0],LOW ); }

    if (degreesF > 33.2) { digitalWrite(ledTempPin[1],HIGH ); }

        if (degreesF < 33.2) { digitalWrite(ledTempPin[1],LOW ); }

    if (degreesF > 49.8) { digitalWrite(ledTempPin[2],HIGH ); }

        if (degreesF < 49.8) { digitalWrite(ledTempPin[2],LOW ); }

    if (degreesF > 66.4) { digitalWrite(ledTempPin[3],HIGH ); }

        if (degreesF < 66.4) { digitalWrite(ledTempPin[3],LOW ); }

    if (degreesF > 83) { digitalWrite(ledTempPin[4],HIGH ); }

      if (degreesF < 83) { digitalWrite(ledTempPin[4],LOW ); }

     

     

     

      

    if (degreesF < 100) {ledReset(); }

     

     

      Serial.print("voltage: ");

      Serial.print(voltage);

      Serial.print("  deg C: ");

      Serial.print(degreesC);

      Serial.print("  deg F: ");

      Serial.println(degreesF);

     

     

    delay(100);

     

     

     

     

     

     

    }

     

     

    void ledReset() { digitalWrite(ledAlrm1Pin,LOW); digitalWrite(ledAlrm2Pin,LOW); }

     

    //Alarm priocess

     

     

    void alarm1()  {

    alarmSpeed = 500/2;

    // alarmSpeed = alarmSpeed + 100;

     

     

     

      tone(soundPin,100,1000);

     

      digitalWrite(ledAlrm2Pin,LOW);

      digitalWrite(ledAlrm1Pin,HIGH);

     

        delay(alarmSpeed);

     

      digitalWrite(ledAlrm1Pin,LOW);

      digitalWrite(ledAlrm2Pin,HIGH);

     

      noTone(soundPin);

     

      tone(soundPin,200,1000);

     

        delay(alarmSpeed);

     

      digitalWrite(ledAlrm1Pin,HIGH);

      digitalWrite(ledAlrm2Pin,LOW);

     

      noTone(soundPin);

     

     

     

    }

     

     

    void noPerph() {

     

        digitalWrite(ledTempPin[0],LOW);

        digitalWrite(ledTempPin[1],LOW);

        digitalWrite(ledTempPin[2],LOW);

        digitalWrite(ledTempPin[3],LOW);

        digitalWrite(ledTempPin[4],LOW);

      

         digitalWrite(ledTempPin[0],LOW);

        digitalWrite(ledTempPin[1],HIGH);

      

        delay(300);

      

        delay(300);

      

        digitalWrite(ledTempPin[1],LOW);

        digitalWrite(ledTempPin[2],HIGH);

        delay(300);

      

        delay(300);

        digitalWrite(ledTempPin[2],LOW);

        digitalWrite(ledTempPin[3],HIGH);

        delay(300);

      

        delay(300);

        digitalWrite(ledTempPin[3],LOW);

        digitalWrite(ledTempPin[4],HIGH);

        delay(300);

      

        delay(300);

        digitalWrite(ledTempPin[4],LOW);

        digitalWrite(ledTempPin[0],HIGH);

        delay(300);

      

        delay(300);

     

     

     

     

    }

     

     

    float getVoltage(int pin)

    {

      // This function has one input parameter, the analog pin number

      // to read. You might notice that this function does not have

      // "void" in front of it; this is because it returns a floating-

      // point value, which is the true voltage on that pin (0 to 5V).

     

      // You can write your own functions that take in parameters

      // and return values. Here's how:

     

        // To take in parameters, put their type and name in the

        // parenthesis after the function name (see above). You can

        // have multiple parameters, separated with commas.

      

        // To return a value, put the type BEFORE the function name

        // (see "float", above), and use a return() statement in your code

        // to actually return the value (see below).

     

        // If you don't need to get any parameters, you can just put

        // "()" after the function name.

     

        // If you don't need to return a value, just write "void" before

        // the function name.

     

     

      // Here's the return statement for this function. We're doing

      // all the math we need to do within this statement:

     

      return (analogRead(pin) * 0.004882814);

     

      // This equation converts the 0 to 1023 value that analogRead()

      // returns, into a 0.0 to 5.0 value that is the true voltage

      // being read at that pin.

    }

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Robert Peter Oakes
    0 Robert Peter Oakes over 11 years ago

    I just know im going to get flamed by my community fellows for this but the simplest way of powering the whole thing from the batteries would be to simply put a couple of diodes in series with the battery, thereby dropping the voltage by 0.6*2 = 1.2V, maybe a bit less depending on the Diodes you use. This would then power your system with 4.8V on a new set of batteries and will simply drop from there as the batteries are discharged.

     

    Of course a better option is a low drop-out regulator to run at 5V but of course your going to have it fail before the batteries are discharged.

     

    Even better would be a Buck regulator powering your system at 3V3 instead of 5V. these are much more efficient than a low drop-out regulator or the diodes as your not throwing power away across the regulator/Diodes so your batteries will last much longer

     

    The only down side of running the system at 3V3 is that the micro-controller will need to run at 8Mhz instead of 16. But considering your project I don't see this as a problem

     

    Hope this helps regarding the power situation

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • mcb1
    0 mcb1 over 11 years ago in reply to Robert Peter Oakes

    Peter

    Both suggestions are reasonable given the design.

     

    I think the 3v3 regulator is the best option, since it will give the longest run time.

     

    The third option is to use rechargeable batteries, as their voltage is 1.2v  (4 x 1.2 = 4.8v)

     

    Your design appears to not have a xtal/oscillator, so it runs at 8MHz anyway (page 33 of the ATmega 328 manual)

    You might need to load it using a different board, but there is some info here (change to 328)

    http://wolfpaulus.com/jounal/embedded/minimalarduino/

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Problemchild
    0 Problemchild over 11 years ago in reply to Robert Peter Oakes

    Yeah get one of those regulators from ebay like this one

    Set it to 3.3V as stated else where, nice and cheap reliable too !!

     

    Best keep the clock rate down if you are using a 5V part like Mark said...

     

     

    John

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago

    I would recommend placing plastic backing on the Altoids tin, or spraying it with some material to keep it all from short circuiting.
    I guess you could use it as a ground, that would keep everything nice and neat.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube