Electricity and power are a fundamental part of many electrical and electronic devices. 

At the heart of most electronic devices these days, from your toaster, to your mobile phone, lies a microcontroller.

So does a microcontroller need a battery?

The answer is yes. A microcontroller does not have an in-built battery, therefore you will need to provide an external battery source to make it work properly. Without providing a battery source, the microcontroller will be rendered useless.

There are many ways to power a microcontroller. Using a battery is one of the options. Other options include power supplies, DC adapters, USB etc. 

The main point is that a microcontroller needs an energy source that provides it a voltage and current that is specified in its datasheet. 

Like most other electronic devices, microcontrollers have maximum and minimum voltage and current ratings. Trying to provide voltages above the threshold levels, increase the chances of frying your device. 

Supplying a voltage below the recommended minimum means that your microcontroller will not function optimally. 

The voltage and specifications are listed on the devices datasheet, which can be found on the manufacturers website.

Why do electronics need electricity?

All electronics do work. 

This work can be a motor spinning, LED lighting up, heater producing heat etc.

All this work requires a certain amount of energy. This energy is provided in the form of electrons.

Without going into too much detail,we all know all matter is made up of atoms. Atoms contain electrons that have the ability to carry charge in the form of current.

 This current is the fundamental aspect of providing energy to many electronic components.

So, basically electricity provides electronics with current (flow of electrons) that has the ability to provide the energy needed to perform work.

Different form of electricity

The two forms of electricity that exist are Static and Current electricity.

Static electricity deals with the accumulation of opposite charges on objects that are separated by an insulator. 

When the charges find a path to reunite to balance the system out, a static discharge occurs. 

You might have experienced this in the form of a shock when walking across a carpet with socks on, and then touching a metal object or a person.

Static electricity is not a suitable form of electricity when it comes to powering electronics like a microcontroller.

As a matter of fact, due to the voltages generated by static electricity, measures are taken to protect sensitive devices (which include microcontrollers) against static discharges.

Current electricity, which is defined as the constant flow of electrons, is the form of electricity that we are concerned with when powering electronic devices. 

While static electricity deals with charges at rest, current electricity deals with charges that are dynamic.

Purpose of a battery

As we saw above, electronic components like microcontrollers need electrons to provide them energy to do work.

But, in order for the electrons to provide energy to electronic devices, they themselves require a little force. 

This force is provided by an electric field and is given a term we are all familiar with known as, Voltage (V).

The purpose of a battery is to provide an electric field that gives the electrons the force required to move through a circuit and provide energy to components.

The electric field that a battery provides is generated through a chemical reaction that occurs within the battery.

An example of this can be a simple circuit containing a battery, switch, and a lamp.

Initially the switch is open, and all the electrons in the circuit are at rest.

Once the switch is closed completing the circuit, a chemical reaction occurs inside the battery, resulting in an electric field providing the force to push the electrons through the circuit.

These electrons then move through the circuit and arrive at the lamp, providing the filament inside the lamp with energy which in turn creates heat and light. 

This process carries on as long as the switch is closed, or the battery voltage runs out.

Different types of batteries

Batteries come in many different sizes, voltages, current capacities, and chemical compositions.

Some batteries have the added benefit of being able to be recharged so they can be used multiple times.

Batteries can be classed into two categories; Primary and Secondary.

Primary batteries cannot be recharged. 

This means once the battery’s chemical reactions are depleted, the battery must be disposed of (properly).

The most common chemical composition of primary batteries is Alkaline. 

The sizes of Alkaline batteries include coin cell, AA, AAA, D cell, C, D and 9V batteries.

Their voltages range from 1.2 volts to 9 volts.

Secondary batteries on the other hand, have the ability to be charged and used again.

This is why they are referred to as rechargeable batteries.

The most common chemical composition of secondary batteries are Lithium-Ion (Li-Ion), Nickel-Cadmium (Ni-Cd), Nickel-Metal Hydride (Ni-MH), and Lead Acid.

The different chemical compositions of these rechargeable batteries all give them different characteristics like energy density, power, charge/discharge efficiency, discharge rate and cycle durability.

The sizes and voltages all vary from one rechargeable battery to the next.

From the flat 3.7V Li-Ion battery to the massive 12V Lead Acid cube found in your car.

So depending on your application, you will be able to find the right rechargeable battery.

Other forms to power your Microcontroller

While batteries are cheap, easy to find and use, there are other options at your disposal to provide a voltage source for your microcontroller.

These can include a power supply, DC wall adapter (like the ones used to charge your phones), USB cable via your computer or a power bank and many more.

As long as you can supply the right voltage and enough current you should be fine.

How to power a Microcontroller?

When it comes to microcontrollers you are spoilt for choice. 

There are many different families of microcontrollers available. The most common of them are the Atmel AVR, PIC, 8051. 

Even within each family exists multiple different types of microcontrollers.

For example, the Atmel AVR family has chips such as the ATMega 8, ATTiny 16, ATMega 16 and so on. 

Each subset of microcontroller has a different number of pins and features such as clock speed, number of timers etc.

Though there are many different manufacturers of microcontrollers, and different versions of them, the one thing that stays consistent is, the way they are powered.

The battery voltage that a microcontroller will operate effectively depends entirely on the type of microcontroller itself.

Depending on what microcontroller you have, you can either run it at a voltage of 3V or 5V. The voltage specification can be found on the microcontroller datasheet.

Lets look at the Atmel AVR microcontroller; ATMega8 as an example.

The ATMega8 comes in two versions; ATMega8 and ATMega8L.

The ATMega8 operates effectively at voltages ranging from 4.5V-5.5V.

Whereas, the ATMega8L operates effectively at voltages from 2.7V-5.5V.

So, you can see, the voltage depends entirely on the chip which is specified in its datasheet. 

But, the common voltage range for most microcontrollers ranges from 3V-5V.

How do you connect the Battery to the Microntroller?

We are all familiar with batteries and their terminals. 

But, to cover all bases, batteries come with two terminals; Positive (+) and Negative(-).

Every electronic device powered by a battery will have a battery holder embedded in it. 

To make sure the device operates correctly, you will have to match the battery according to the battery holder. 

The negative terminals of the battery must touch the negative terminals of the battery holder, and the same for positive.

The same concept applies for the microcontroller. 

However, microcontrollers do not have the luxury of an embedded battery holder or  pins labelled positive (+) and negative (-).

The  microcontroller’s positive and negative pins are VCC (positive) and GND (negative) respectively.

Note VCC is a common notation for the positive pin, but not always the case. The notation depends entirely on the manufacturer.

It is common for a microcontroller to have two sets of GND pins. Make sure these are both connected to the negative terminal of the battery. 

Which pins of the microcontroller are VCC and GND can be found on its datasheet.

Breadboards

Breadboards are a great way to test and prototype circuits seen in Figure 1

Figure 1

They are also a great way to power your microcontroller using a battery.  You can place the microcontroller in the breadboard as seen in the picture below

Figure 2

You will then need a battery holder with leads like the one below.

Figure 3

After that you will connect the battery’s positive and negative leads to the microcontroller’s VCC and GND respectively as seen in Figure 4.

Figure 4

Conclusion

So, like with any other electronic device, to make a microcontroller function properly we need to supply it with a voltage and current.

While there are many other ways to power a microcontroller, a common and easy way to do so is to use batteries.

They come in many different sizes, voltage levels, current capacities and chemical compositions.

There are also batteries that can be recharged and used multiple times.

When providing a voltage to the microcontroller using a battery, make sure the output voltage of the battery matches the voltage specified in the microcontrollers datasheet (which can be found on the manufacturer’s website).