Android Things: Electronics 101

Last week I ventured over to Pimoroni to pick myself up a new Raspberry Pi so that I could start playing around with Android Things. Although I used to toy quite a bit with my Arduino, that was a few years ago now and my electronics knowledge has become a little rusty. For that reason, I decided to recap over some fundamental electronics concepts and components, putting together a little post along the way in the hope that it will help others too 🔌


I’m not going to spend too much time here talking about Android Things as there’s a lot of resources that have done so. Instead, I’m going to be looking at some fundamental electronics concepts and components that will help you when building for the IoT (and hopefully avoid some fires doing so!). This post doesn’t aim to be a complete guide foreach of the components and concepts, mainly a quick introduction — but if you want to learn more about any of them then there are plenty of resources on the internet!


Power

Our Android Things creations are going to need power to operate, so it’s important to understand the concepts surrounding this. Our source of power (such as a power supply or similar means of electricity) is going to provide us with voltage that can be used to power our board and components that are connected to it.

But what is voltage? Well, it’s technical description states that is is the “difference in charge between two points in an electrical field” . A simpler way of looking at it is pressure, it is the force pushing electrons through our circuit. This value has a direct effect on the current of our circuit too, as the higher the voltage in our circuit the faster electrons will flow. And sometimes, we may want to reduce that flow of current through our circuit — this can be done by applying resistance to our circuit.

With voltage (V), current (I) and resistance (R) — that’s where OHMs law comes in to play. This law simply states that “electric current is proportional to voltage and inversely proportional to resistance”, meaning that we can use it to calculate one of the V / I / R values based off of the other two. This is useful as for example, if you know both the voltage and current of your circuit then you can use these values to easily calculate the resistance required for your circuit. The law states that we can calculate these values like so:

  • Voltage = Current * Resistance
  • Current = Voltage / Resistance
  • Resistance = Voltage / Current

This formulas can be easily remembered by using this visual representation:

So for example, when it comes to wondering how much resistance we need for a circuit we are building we can simply reference OHMs law in-order to calculate the resistor value that we need.

Breadboard

Before we take a look at any electrical components, it’s important to know a little about where they’re going to go!

A breadboard is the foundation of our Android Things projects — it allows us to prototype exciting ideas, giving us space to make mistakes and experiment with our electronics components. This is because it is essentially a solder-less circuit board — we can connect wires, lights, switches and more without the need to permanently attach them using a soldering iron.

This breadboard allow us to learn about electronics whilst remaining practical, easily learning from our mistakes and fixing them as we go. A typical breadboard will look like this:

Looks pretty basic, right? If you hadn’t had guessed, the holes in the breadboard are where we’re going to be sticking our connectors and components. But how do all these connect together? Let’s take a look at this simple diagram below:

The Top View shows all of the points which we can insert our components and connectors into. However, for the Bottom View you’ll notice that for each row in each column there is a corresponding strip — this is known as a terminal strip. This means that any given component in a row will be connected to any other component that is connected to the same row and column.

You’ll also notice in the original image of the breadboard there are blue and red lines down each side of the breadboard, these are known as the power rails. You’ll see from the diagram below that this looks very similar to the horizontal strips under the hood:

The main difference with the vertical power rails is the that each connector point within a column is essentially ‘connected’, rather than for each row. These rails will usually be labelled with a + or to indicate their polarity, red will be positive and blue or black for negative.

Once you’ve connected power to your breadboard, you’ll be able to use these power rails to power the components that are connected to it.

Resistors

Image Source: Sparkfun

In the section about Power, we took a quick look at what is known as Resistance. Sometimes we may need to use resistors to reduce the flow of current through our circuit.

And now we can use OHMs law to calculate the resistance we need to apply, the only thing we need to do now is find a resistor that will supply us with the required level of resistance.

Whilst larger resistors often have their value printed onto the component, we don’t have this luxury for smaller resistor values. So because of this, there is a color coding standard in place to state the resistance value of the resistor — and depending on their size, resistors can have either 4,5 or 6 colored bands. Each of these colors corresponds to a value which can be used in an formulae for resistance calculation.

  • For 4 band resistors the bands correspond to a Resistance Value (Digit), Resistance Value (Digit), Multiplier value and Tolerance rating.
  • For 5 band resistors the bands correspond to a Resistance Value (Digit), Resistance Value (Digit), Resistance Value (Digit), Multiplier value and a Tolerance rating.
  • For 6 band resistors the bands correspond to a Resistance Value (Digit), Resistance Value (Digit), Resistance Value (Digit), Multiplier value, Tolerance rating and Temperature rating.

The Resistance and Multiplier Values are what are going to be used to calculate our resistance. We’re not going to focus on the Tolerance rating (the amount in which the resistor may vary from its original value) and Temperature rating (how much the resistors value changes with temperature) right now as they aren’t required for these calculations.

From this illustration above, we are able to calculate the resistance value of a resistor using the relevant formulae. This formulae depends on the number of bands which our resistor has:

For 4 band resistors

Resistance = Digit Digit * Multiplier

For 5 & 6 band resistors

Resistance = Digit Digit Digit * Multiplier


So for example, if I had a 4 band resistor that was Brown, Brown, Brown and Red — then this formulae be:

Resistance = 1 (digit) 1 (digit) x 10 (multiplier) = 110 ohms

This can be a little confusing at first, but the easiest way to understand it is to have a play with some resistor values for yourself!

Capacitors

In electronics, the capacitance is the ability of a component to store an electrical charge. To do this, we can use components called capacitors. Pretty cool, huh?

But how does this work? Well, inside the capacitor there are separated conductive plates and between them are insulated layers known as the Dielectric. This insulated layer essentially blocks DC current within a circuit, meaning that the current is left charged across the plates and not able to flow through the capacitor. However, AC current will simply flow through the capacitor unblocked.

Because capacitors can store energy once they’ve conducted it, we are able to dissipate this energy even when our circuit has been disconnected from power. This is a common usage for capacitors, for example it allows us to retain the state of information within volatile memory when not powered.

Note: Because capacitors can store energy, it can be dangerous when dealing with ones of large capacity even when the device is disconnected — so be sure to take care when handling them!

Diodes & LEDs

A diode is a type of semiconductor, this means that the conductivity of the component changes based on it’s environment. They have many uses but primarily prevent current from flowing in the wrong direction, in turn protecting our circuits and its components from any damage. We can also use Diodes for things such as allowing current to flow given certain conditions or implementing logic gates in our circuits by pairing diodes to create gates that require specific inputs in-order to allow an output.

There are quite a few different types of diodes that are available, each one is created to allow current to pass through when a specified criteria is met. For example, there is the photodiode that flows current based on the amount of light detected and there are light emitting diodes (LEDs) that allow you to emit light based on the amount of flowing current.

Looking at the illustration above, you can see a vertical bar to the right hand side of the Diode. This bar states the direction in which the current can flow, this is usually shown on the wire as a black bar on the diode. In we reverse the diode to the opposite direction of our current, then the current will be unable to pass through.

Transistors

Transistors are quite similar to diodes in terms of functionality, but with the main difference of being able to act as an amplifier for the current flowing through them. This essentially means that they can take an input of a small current and output a larger current, hence acting as an amplifier.

Here we’re going to be taking a quick look at a junction transistor. This transistor has 3 electrical contacts which are the Base (b), Collector (c) and Emitter (e). The Base is what controls the transistor — once it receives at least 0.6v of current it begins allowing current to flow from the collector to the emitter.

When used as an amplifier we can input a small current and output a much larger one — seen in examples such as a loud speaker or hearing aid, acting as a way of boosting the input signal. On the other hand, we can use a transistor as an electrical switch to turn on something that requires a larger current to do so.

Switches

A switch is a pretty simple component that allows us to control whether a circuit is open or closed. When we open a switch we stop the flow of current through a circuit, but closing the switch allows the current to resume its flow.

Switches can only have two states, which is either on or off. The simplest example here is a light switch in your home. When you press the switch to turn your light on, this is essentially closing the circuit and allowing current to flow through to turn on your light. Pressing the switch again will open the circuit and stop the flow of current, turning your light off at the same time.

Relays

A relay is similar to a switch, except they can also be operated electronically as well as manually. The component houses an electromagnet, this generates a magnetic field when current flows through and connects the switch contact inside of the relay. On the other hand, when there is no power the electromagnet releases the contact and the switch is pulled back by a spring — meaning that no current can flow out of the relay.

Whilst relays can be either mechanical and electrical, they can also be one of the type:

  • Normally Open — Contacts for the switch are not connected by default, becoming connected when the current flows through the electromagnet
  • Normally Closed — Contacts for the switch are connected by default, disconnecting when the electromagnet

We can use relays within circuits as an electronic switch to allow current to pass through given a certain condition. A perfect example is their use with sensors and automation. For example, we may wish to turn on a desk lamp when a light sensor detects that the room has become dark. Or to turn on a fan when a temperature sensor detects it’s got a little too warm in my office.

Over to you!

Here we’ve had a quick look at a variety of different electrical components and concepts, this should give you a little more knowledge and give some curiosity to research components further when it comes to building circuits for use with Android Things! For now, I’m off to order my new Raspberry Pi so I can begin creating some android things 🚀

I’d love to hear what you’re building so let me know in a response to this post or drop me a tweet!

Check out my other projects over at joebirch.co

Leave a Reply

Your email address will not be published. Required fields are marked *