IOT & Robotics
September 8, 2026 28 min read

Electronics

Hs
Hemant singh
Technical Writer & Educator

Electronics Fundamentals

If you want to learn IoT and Robotics, you cannot directly jump into sensors, motors, ESP32, Arduino, or other microcontrollers without understanding some basic electronics.

The good news is that you don't need to become an electrical engineer first.

You only need to understand a few fundamental concepts really well.

In this tutorial, we will build those concepts step by step.

By the end, you should be able to understand what voltage and current actually mean, why a resistor is required with an LED, what happens when a circuit is shorted, how batteries work, why sensors can produce analog values, and how a voltage divider works.

1. What Is Electricity?

Before understanding electronics, let's first understand electricity.

Electricity is associated with the movement and behavior of electric charges.

In the circuits that we normally build with Arduino, ESP32, sensors, LEDs, and motors, the important charge carriers are electrons.

You can think about electricity using a water-pipe example.

Imagine that you have a pipe containing water. If there is pressure in the pipe, the water can be pushed through it.

An electrical circuit works in a somewhat similar way.

Voltage provides the electrical potential difference that can drive charge through a circuit, while current describes how much charge is flowing.

Resistance opposes that flow.

This gives us three of the most important concepts in electronics:

Voltage → electrical push

Current → flow of electric charge

Resistance → opposition to that flow

Once these three ideas become clear, many other electronics concepts become much easier.

Electricity in a real electronic device

Consider an ESP32.

When you connect the ESP32 to a power source, electrical energy is supplied to the board.

That energy allows the ESP32 to operate its processor, memory, Wi-Fi circuitry, GPIO pins, and other internal components.

The same basic idea applies to almost every electronic device.

A sensor needs electrical power to operate.

An LED converts electrical energy into light.

A motor converts electrical energy into mechanical motion.

A buzzer converts electrical energy into sound.

So when we build an IoT or robotics project, we are essentially creating circuits that allow electrical energy and signals to interact with different components.

2. Voltage

Voltage is one of the most important concepts you will encounter in electronics.

Voltage is the electrical potential difference between two points.

The unit of voltage is the volt (V).

A useful beginner analogy is water pressure.

Imagine two water tanks.

If one tank has much higher water pressure than the other, there is a greater potential for water to flow between them.

Voltage is somewhat similar.

It provides the potential difference that can drive current through a circuit.

Example

Suppose we have a 5V power supply.

This means there is a 5-volt potential difference between its positive and negative terminals.

If we connect an appropriate circuit between those terminals, current can flow.

A USB power supply commonly provides around 5V.

Many small electronic modules are designed to work from 5V or 3.3V.

An ESP32 uses 3.3V logic for its GPIO signals.

Voltage does not mean current

This is a very important distinction.

Voltage and current are not the same thing.

A power supply can provide a particular voltage, while the amount of current that actually flows depends on the circuit connected to it.

For example, connecting a 5V supply to one circuit may result in 20mA of current, while another circuit connected to the same 5V supply may draw 500mA.

The circuit determines the current it draws, within the limits of the power source.

How do we measure voltage?

Voltage is measured using a multimeter.

When measuring voltage, the multimeter is connected across two points.

For example, if you want to measure the voltage of a battery, you place one probe on the positive terminal and the other probe on the negative terminal.

3. Current

Current tells us how much electric charge is flowing through a circuit per unit of time.

The unit of current is the ampere (A).

For small electronic circuits, we commonly use milliamps.

1 A = 1000 mA

So:

0.1 A = 100 mA

0.02 A = 20 mA

Understanding current using water

Imagine water flowing through a pipe.

If a large amount of water passes through the pipe every second, the water flow is high.

If only a small amount passes through, the flow is low.

Electrical current can be thought of in a similar way.

A circuit carrying 1A has more current flowing through it than a circuit carrying 10mA.

Why current matters in robotics

Current becomes particularly important when working with motors.

A small LED may require only a small amount of current.

A servo motor may require considerably more.

A DC motor can require even more, especially when starting or when its load increases.

This is one reason why we don't normally connect a motor directly to an ESP32 GPIO pin.

The GPIO pin is intended primarily for control signals and has limited current capability.

Instead, we normally use an appropriate driver circuit or transistor/MOSFET and a suitable power supply.

4. Resistance

Resistance is the opposition to the flow of electric current.

The unit of resistance is the ohm (Ω).

A resistor is a component designed to provide a specific amount of resistance.

For example:

100Ω resistor

1kΩ resistor

10kΩ resistor

The letter "k" means thousand.

Therefore:

1kΩ = 1000Ω

Why do we need resistance?

Consider an LED.

If you connect an LED directly to an inappropriate voltage source, excessive current can flow through it and damage the LED.

A resistor can be placed in series with the LED to limit the current.

For example:

5V → Resistor → LED → GND

The resistor controls the current flowing through the LED.

This is one of the first practical electronics circuits you should understand.

Resistance and current

For a given voltage, increasing resistance generally reduces current.

For example, suppose a 5V source is connected to:

100Ω

The current would be much higher than if the same source were connected to:

1kΩ

This relationship is described by Ohm's Law.

5. Ohm's Law

Ohm's Law is one of the most important formulas in basic electronics.

It describes the relationship between voltage, current, and resistance.

The formula is:

V = I × R

Where:

V = Voltage

I = Current

R = Resistance

From this formula, we can also calculate:

I = V / R

and

R = V / I

Example

Suppose we have:

Voltage = 5V

Resistance = 1000Ω

We want to calculate current.

I = V / R

I = 5 / 1000

I = 0.005A

Since:

0.005A = 5mA

The current is 5mA.

This simple calculation is extremely useful when designing circuits.

Why should you learn Ohm's Law?

Because as you progress into electronics, you will constantly need to answer questions such as:

How much current will flow?

What resistor should I use?

What voltage will appear at this point?

Will this component handle the current?

Ohm's Law helps answer these questions.

6. Electrical Power

Voltage and current tell us about a circuit, but there is another important quantity called power.

Electrical power tells us how quickly electrical energy is being transferred or consumed.

Power is measured in watts (W).

The basic formula is:

P = V × I

For example, suppose a device operates at 5V and draws 0.2A.

P = 5 × 0.2

P = 1W

Therefore, the device is consuming approximately 1 watt of electrical power.

Why power is important

Power becomes very important in robotics.

Consider a small LED.

Its power requirement may be very small.

Now consider a motor.

The motor may require significantly more power.

This means that when designing a robot, we need to think not only about the microcontroller but also about the power requirements of motors, sensors, displays, communication modules, and other components.

A common beginner mistake is to think:

"My ESP32 has 5V available, so I can power everything from it."

That is not necessarily true.

The voltage may be correct while the available current and power may be insufficient.

7. What Is a Circuit?

A circuit is a path through which electrical current can flow.

A basic circuit usually contains a power source, connecting wires, and one or more components that use or control electrical energy.

For example:

Battery → Resistor → LED → Battery

This forms a complete path.

The battery provides the electrical potential difference.

The wires provide the conducting path.

The resistor limits current.

The LED converts electrical energy into light.

Circuit in an IoT project

An IoT project may contain a much more complicated circuit.

For example:

Battery → Voltage Regulator → ESP32 → Sensor

The ESP32 may then communicate with a Wi-Fi network and send sensor data to a server.

Although the project is much more complicated, the fundamental idea remains the same:

Electrical components must be connected in appropriate circuits so that power and signals can move correctly.

8. Open Circuit and Closed Circuit

To understand circuits, you need to understand the difference between an open circuit and a closed circuit.

Closed Circuit

A closed circuit has a complete electrical path.

For example:

Battery → Switch → LED → Battery

When the switch allows the connection to be completed, current can flow and the LED can turn on.

Open Circuit

An open circuit contains a break in the electrical path.

For example, if the switch is opened, the path is broken.

Current cannot flow through the complete circuit.

This is exactly how a normal switch controls an electrical device.

Easy way to remember

Closed circuit → complete path → current can flow

Open circuit → broken path → current cannot flow

This concept will become very useful when working with push buttons, switches, relays, sensors, and digital inputs.

9. Short Circuit

A short circuit is an unintended low-resistance path between points that normally should not be directly connected.

Consider a battery.

If we connect its positive and negative terminals directly with a wire, we create a very low-resistance path.

A large current can potentially flow.

This can cause wires and components to heat up and can damage the battery or circuit.

Example

Suppose you accidentally connect:

5V → GND

with a wire.

This is generally a short circuit.

The power supply may enter protection mode, the voltage may collapse, or the supply and wiring may heat up depending on the source.

Important safety rule

Never intentionally short-circuit batteries or power supplies as an experiment.

When building circuits, always check your wiring before applying power.

This is especially important when working with lithium batteries and higher-current power supplies.

10. Series and Parallel Circuits

Components can be connected in different ways.

Two of the most important arrangements are series and parallel.

Series

In a series circuit, components are connected one after another along the same path.

For example:

Battery → R1 → R2 → LED → Battery

In a simple series circuit, the same current flows through each component.

For resistors connected in series:

Rtotal = R1 + R2 + R3

For example:

R1 = 100Ω

R2 = 200Ω

R3 = 300Ω

Therefore:

Rtotal = 100 + 200 + 300

Rtotal = 600Ω

Parallel

In a parallel circuit, components are connected across the same two nodes, creating multiple paths for current.

For two resistors in parallel:

1/Rtotal = 1/R1 + 1/R2

The voltage across each parallel branch is the same, while the current divides between the branches.

Why does this matter?

Understanding series and parallel connections is essential when connecting:

LEDs

Resistors

Batteries

Motors

Sensors

Power supplies

and many other components.

11. AC and DC

There are two important types of electrical current you will encounter: DC and AC.

DC — Direct Current

In a DC system, the current has a fixed direction under steady conditions.

Batteries provide DC electrical power.

USB power is also DC.

Arduino and ESP32 projects commonly use DC power.

For example:

Battery → ESP32

is a DC-powered system.

AC — Alternating Current

In an AC system, the voltage and current periodically change direction.

Household mains electricity is AC.

AC is widely used for electrical power distribution because it can be efficiently transformed between voltage levels and transmitted over long distances.

Important safety warning

Household mains electricity can cause severe injury or death.

When learning electronics, work with safe low-voltage circuits such as battery-powered or USB-powered systems.

Do not experiment directly with household mains voltage.

12. Analog and Digital

Another extremely important concept for IoT and robotics is the difference between analog and digital signals.

Digital

A digital signal uses discrete states.

A very common example is:

LOW

and

HIGH

For example, a push button can be connected to a microcontroller.

The microcontroller can interpret the signal as:

LOW → button not pressed

HIGH → button pressed

The exact logic depends on how the circuit is wired, so HIGH does not universally mean "pressed."

Analog

An analog signal can represent a continuously varying value within a range.

For example, imagine a potentiometer.

As you rotate the knob, its output voltage changes.

It might produce:

0.5V

1.2V

2.1V

2.8V

3.0V

and many other values within its operating range.

A microcontroller can use an ADC (Analog-to-Digital Converter) to measure such a voltage and convert it into a digital number.

IoT example

Imagine a light sensor.

The amount of light changes continuously.

The sensor may produce a changing voltage.

The microcontroller reads that voltage and converts it into a numerical value.

Your program can then decide:

"If the light level is below this value, turn on the lamp."

This is the basic idea behind many sensor-based IoT systems.

13. Voltage Divider

A voltage divider is a simple circuit that allows us to obtain a lower voltage from a higher voltage.

A basic voltage divider uses two resistors.

The arrangement looks conceptually like this:

Vin → R1 → Vout → R2 → GND

The output voltage is taken from the point between the two resistors.

The formula is:

Vout = Vin × R2 / (R1 + R2)

Example

Suppose:

Vin = 5V

R1 = 10kΩ

R2 = 10kΩ

Then:

Vout = 5 × 10k / (10k + 10k)

Vout = 2.5V

Therefore, the output is approximately 2.5V.

Why is a voltage divider useful?

Voltage dividers are commonly used for:

Reading a higher voltage with a lower-voltage input

Creating reference voltages

Reading certain resistive sensors

Level shifting in some simple situations

For example, suppose a sensor produces a voltage that is higher than the maximum voltage allowed by a microcontroller input.

A properly designed voltage divider can reduce that voltage before it reaches the input.

However, a voltage divider should not normally be used as a power supply for a device that requires significant current.

For powering electronics, use an appropriate voltage regulator or power converter.

14. Battery Basics

A battery is a source of electrical energy.

It converts stored chemical energy into electrical energy.

Batteries are extremely important in robotics and IoT because many projects need to operate without being connected to a wall power supply.

Battery voltage

Different batteries provide different voltages.

For example:

A typical alkaline AA cell is approximately 1.5V when fresh.

A typical single lithium-ion cell has a nominal voltage around 3.6–3.7V, with its actual voltage varying depending on its state of charge.

A common 9V battery has a nominal voltage of 9V.

The voltage of a battery must be compatible with the circuit being powered.

Battery capacity

Battery capacity is commonly expressed in:

mAh — milliamp-hours

or

Ah — amp-hours

Capacity gives us an indication of how much charge a battery can deliver under specified conditions.

For example, a 2000mAh battery has a greater nominal capacity than a 500mAh battery.

However, you should not assume that a 2000mAh battery will always last exactly four times as long as a 500mAh battery. Real-world runtime depends on load, discharge characteristics, efficiency, temperature, and other factors.

Battery polarity

A battery has:

Positive (+)

and

Negative (−)

terminals.

Polarity matters.

If a component is polarity-sensitive and you connect it incorrectly, it may not work and could potentially be damaged.

This is why you should always identify positive and negative connections before powering your circuit.


Electronic Components

Now that we understand the basic concepts of electricity, voltage, current, resistance, power, and circuits, we can start learning the actual electronic components used to build circuits.

In real IoT and robotics projects, we combine different components to perform different jobs.

For example:

A resistor can limit current.

An LED can produce light.

A push button can provide user input.

A potentiometer can provide a variable voltage.

A capacitor can store and release electrical charge.

A transistor or MOSFET can control larger currents.

A relay can switch another circuit.

A voltage regulator can provide a stable voltage.

A sensor can detect something from the physical world.

A motor can create movement.

A servo motor can create controlled movement.

Let's understand each component one by one.

1. Resistor

A resistor is one of the most common electronic components.

Its primary purpose is to oppose and control the flow of current in a circuit.

Resistance is measured in ohms (Ω).

Resistors are available in many values, such as:

100Ω

220Ω

330Ω

1kΩ

4.7kΩ

10kΩ

100kΩ

The correct resistor value depends on what the circuit is trying to accomplish.

Why do we use resistors?

One of the most common uses of a resistor is to limit current.

For example, an LED should normally not be connected directly to a power supply without considering current limiting.

A resistor can be connected in series with the LED.

The circuit can look like:

5V → Resistor → LED → GND

The resistor limits the current flowing through the LED.

Resistors in microcontroller circuits

Resistors are also commonly used with:

Push buttons

Sensors

Transistors

Communication signals

Voltage dividers

Microcontroller inputs

A 10kΩ resistor, for example, is commonly used as a pull-up or pull-down resistor.

Reading resistor values

Traditional resistors often have colored bands that represent their resistance value.

For example, a resistor may have bands representing:

220Ω

1kΩ

10kΩ

However, when learning electronics, it is useful to verify the actual resistance using a multimeter.

Practical experiment

Take a resistor and set your multimeter to resistance mode.

Touch one probe to each end of the resistor.

The multimeter should show a resistance value close to the resistor's rated value.

This is one of the easiest ways to become familiar with a multimeter.

2. LED

LED stands for Light Emitting Diode.

An LED is a semiconductor component that produces light when current flows through it in the appropriate direction.

LEDs are used everywhere in electronics.

Examples include:

Power indicators

Status indicators

Displays

Lighting

Sensors

Communication systems

Robotics

IoT devices

LED polarity

An LED has two terminals:

Anode (+)

Cathode (−)

The LED is polarity-sensitive.

In a typical through-hole LED, the longer leg is usually the anode and the shorter leg is usually the cathode.

The flat edge on many LED packages also indicates the cathode side.

However, when working with real components, it is better to verify the component's datasheet or markings rather than relying only on physical conventions.

Why does an LED need a resistor?

An LED is not simply a resistor.

If too much current flows through an LED, it can be damaged.

Therefore, a current-limiting resistor is commonly used.

For example:

GPIO → Resistor → LED → GND

When the GPIO is HIGH, current flows through the resistor and LED, causing the LED to illuminate.

LED and ESP32

One of the first experiments you can perform with an ESP32 is controlling an LED using a GPIO pin.

Your program can turn the GPIO:

HIGH → LED ON

LOW → LED OFF

This introduces an important concept:

Software can control physical electronics.

That idea is at the heart of IoT and robotics.

3. Push Button

A push button is a simple input device.

It allows a user to manually connect or disconnect an electrical path.

When you press the button, its internal contacts change state.

When you release it, they return to their original state.

Why are push buttons useful?

Push buttons can be used to:

Start a robot

Stop a motor

Turn an LED on or off

Trigger an action

Reset a system

Provide user input

In an IoT project, a button could be used to tell an ESP32 to perform a particular action.

Push button with ESP32

A typical setup connects a button between a GPIO pin and either:

GND

or

3.3V

A pull-up or pull-down resistor is then used to ensure that the GPIO has a known state when the button is not pressed.

Many microcontrollers, including ESP32, also provide internal pull-up or pull-down configurations for suitable GPIOs.

Important concept: floating input

Suppose an ESP32 GPIO is configured as an input but is not connected to a defined HIGH or LOW voltage.

The input can become floating.

A floating input may randomly read HIGH or LOW because it can pick up electrical noise.

Pull-up and pull-down resistors prevent this by giving the input a defined default state.

4. Potentiometer

A potentiometer is a variable resistor.

Unlike a normal resistor, its resistance can be changed mechanically by rotating a knob or moving a control.

A typical potentiometer has three terminals.

The two outer terminals are connected to the resistive element.

The middle terminal is connected to a movable contact called the wiper.

How does it work?

When you rotate the knob, the wiper moves across the resistive element.

This changes the resistance between the wiper and each outer terminal.

This makes the potentiometer useful for creating a variable voltage.

Potentiometer as a voltage divider

A common connection is:

3.3V → Outer terminal

GND → Other outer terminal

Middle terminal → Analog input

As the knob rotates, the voltage at the middle terminal changes.

For example, it may vary from approximately:

0V → 3.3V

The ESP32 can read this changing voltage using an ADC.

Why is this useful?

A potentiometer is an excellent component for learning analog input.

For example, you could build a project where:

Turn knob → ESP32 reads value → LED brightness changes

or:

Turn knob → ESP32 reads value → Servo position changes

This connects a physical control to software.

5. Capacitor

A capacitor is an electronic component that stores electrical charge and can release that energy when needed.

Capacitors are measured in farads (F).

Common capacitor values are much smaller:

µF — microfarad

nF — nanofarad

pF — picofarad

What does a capacitor do?

Capacitors have many uses.

They can be used for:

Power supply smoothing

Noise reduction

Filtering

Timing circuits

Signal coupling

Energy storage

Motor circuits

Microcontroller power stabilization

Capacitor in a power supply

When a digital circuit switches rapidly, the current it draws can change quickly.

A capacitor placed near a component's power pins can help provide short-duration current locally and reduce voltage fluctuations.

This is why you will often see capacitors placed close to microcontrollers and other electronic ICs.

Capacitor polarity

Some capacitors are polarized.

For example, many electrolytic capacitors have a positive and negative terminal.

These must be connected correctly.

Other capacitors, such as many ceramic capacitors, are non-polarized.

Always check the component markings or datasheet.

Practical example

Suppose an electronic circuit is experiencing small voltage fluctuations.

A suitable capacitor placed across the power and ground rails may help smooth those fluctuations.

This is one reason capacitors are commonly found throughout electronic circuits.

6. Diode

A diode is a semiconductor component that primarily allows current to flow more easily in one direction than the other.

This one-way behavior makes diodes extremely useful.

Diode terminals

A diode has two terminals:

Anode

Cathode

The cathode is commonly marked with a stripe on a standard through-hole diode.

Common uses

Diodes are used for:

Reverse-polarity protection

Rectification

Signal protection

Switching circuits

Voltage regulation

Flyback protection

Diode in a motor circuit

Motors and relays contain coils.

When current through a coil is suddenly switched off, the collapsing magnetic field can generate a voltage spike.

A diode can be placed across the coil to provide a safer path for this energy.

This type of diode is commonly called a flyback diode.

This becomes very important when controlling motors, relays, and solenoids using transistors or MOSFETs.

7. Transistor

A transistor is a semiconductor device that can be used to switch or amplify electrical signals.

For beginners in IoT and robotics, one of the most important uses is switching.

A microcontroller GPIO cannot directly control every type of load.

For example, a GPIO might be able to control an LED, but a motor may require considerably more current.

A transistor can act as an electronic switch between the microcontroller and the load.

Basic idea

Instead of:

ESP32 → Motor

we can use:

ESP32 → Transistor → Motor

The ESP32 provides the control signal.

The transistor handles the switching of the load current.

Common transistor types

Two major categories are:

BJT — Bipolar Junction Transistor

MOSFET — Metal-Oxide-Semiconductor Field-Effect Transistor

Common BJT examples include:

2N2222

BC547

BC557

BJT terminals

A BJT normally has three terminals:

Base

Collector

Emitter

A small current at the base can control a larger collector-emitter current, within the transistor's ratings and circuit configuration.

Example

Suppose we want an ESP32 to control a small buzzer or another load.

The ESP32 GPIO controls the transistor.

The transistor then switches the load.

This allows the microcontroller to control a load without forcing the GPIO pin to carry the load's entire current.

8. MOSFET

MOSFET stands for:

Metal-Oxide-Semiconductor Field-Effect Transistor

A MOSFET is another type of transistor and is extremely important in robotics and power electronics.

MOSFETs are commonly used as electronic switches.

MOSFET terminals

A typical MOSFET has three main terminals:

Gate

Drain

Source

The gate is the control terminal.

A voltage applied between the gate and source controls whether the MOSFET conducts between drain and source.

Why are MOSFETs useful?

MOSFETs can be used to control loads such as:

DC motors

LED strips

Solenoids

Pumps

Fans

Relays

Heaters

and many other loads.

MOSFET with ESP32

Suppose you want an ESP32 to control a 12V LED strip.

You should not connect the 12V LED strip directly to an ESP32 GPIO.

Instead, an appropriate logic-level MOSFET can be used as a switching device.

Conceptually:

ESP32 GPIO → MOSFET Gate

12V supply → LED strip → MOSFET → GND

The ESP32 controls the MOSFET.

The separate 12V supply provides the power for the LED strip.

This is a fundamental pattern in robotics and IoT.

Logic-level MOSFET

When using a microcontroller such as an ESP32, it is important to choose a MOSFET that can turn on properly at the available gate voltage.

This is why the term logic-level MOSFET is important.

You should always check the MOSFET's datasheet rather than choosing one only by its part number.

9. Relay

A relay is an electrically controlled switch.

It allows one circuit to control another circuit while providing electrical isolation between the control side and switched contacts in many relay configurations.

A relay typically contains a coil and mechanical contacts.

When current flows through the coil, it creates a magnetic field that moves the contacts.

Relay terminals

A common relay contact arrangement includes:

COM — Common

NO — Normally Open

NC — Normally Closed

When the relay is not energized:

COM is connected to NC.

When the relay is energized:

COM switches to NO.

Why use a relay?

Relays can be useful when you need to switch loads such as:

Lamps

Fans

Pumps

Motors

Other electrical equipment

However, the relay itself still needs to be driven correctly. A microcontroller should generally not drive a relay coil directly unless the relay/module is specifically designed for that purpose.

A transistor or MOSFET driver is commonly used.

Relay vs transistor

A relay uses mechanical contacts.

A transistor or MOSFET performs switching electronically.

Transistors are usually faster and have no moving parts.

Relays can be useful when contact isolation or switching requirements make them appropriate.

10. Voltage Regulator

A voltage regulator is a circuit or component that provides a controlled output voltage from an input supply.

Electronic components often require a specific voltage.

For example, one circuit may need:

5V

while another may need:

3.3V

A voltage regulator can convert an available voltage into a suitable regulated voltage.

Example

Suppose you have a battery whose voltage is higher than the voltage required by your electronics.

A regulator can provide a stable lower voltage.

For example:

Battery → Voltage Regulator → ESP32

The regulator helps provide an appropriate supply voltage to the ESP32.

Linear regulator

A linear regulator reduces voltage by dissipating excess energy as heat.

It is simple and can be useful when the voltage difference and current are relatively modest.

Switching regulator

A switching regulator uses switching circuitry to convert voltage efficiently.

Common types include:

Buck converter → reduces voltage

Boost converter → increases voltage

Buck-boost converter → can increase or decrease voltage depending on the design

Switching regulators are especially useful in battery-powered IoT and robotics projects where efficiency matters.

11. Buzzer

A buzzer is a component that produces sound when electrically driven.

Buzzers are commonly used to provide audible feedback.

For example:

Button pressed → buzzer sounds

Sensor detects motion → buzzer sounds

Distance becomes too small → buzzer sounds

Alarm condition → buzzer sounds

Active and passive buzzers

Two common types are:

Active buzzer

Passive buzzer

An active buzzer generally contains its own oscillator and can produce a tone when powered.

A passive buzzer requires an appropriate changing electrical signal to generate a tone.

With a microcontroller, a passive buzzer can be driven with different frequencies to create different tones.

Buzzer with ESP32

The ESP32 can generate a suitable signal to control a buzzer.

For example:

Distance > 50cm → no sound

Distance < 50cm → buzzer

Distance < 20cm → faster or higher-frequency alert

This is a simple example of combining a sensor, microcontroller, and output device.

12. LDR

LDR stands for Light Dependent Resistor.

It is a resistor whose resistance changes depending on the amount of light falling on it.

An LDR generally has:

Higher resistance in darkness

Lower resistance in brighter light

The exact behavior depends on the component.

Why is an LDR useful?

An LDR can be used to detect changes in light.

For example:

Automatic night light

Street light controller

Light intensity measurement

Robot light detection

Alarm systems

LDR with a voltage divider

An LDR is commonly combined with a fixed resistor to create a voltage divider.

The resulting voltage changes when the light level changes.

The microcontroller can then read this voltage using an analog input.

For example:

Bright light → one analog value

Dark environment → another analog value

The software can then make a decision.

For example:

If light level < threshold → turn ON LED

This is a simple example of an IoT system responding to the physical environment.

13. Thermistor

A thermistor is a resistor whose resistance changes significantly with temperature.

The word comes from:

Thermal + Resistor

There are two common types.

NTC

NTC means:

Negative Temperature Coefficient

For an NTC thermistor, resistance generally decreases as temperature increases.

PTC

PTC means:

Positive Temperature Coefficient

For a PTC thermistor, resistance generally increases as temperature increases.

How can we measure temperature?

A thermistor can be combined with a fixed resistor to create a voltage divider.

As the temperature changes, the thermistor's resistance changes.

This changes the voltage at the divider output.

The microcontroller reads that voltage.

The software can then convert the measured value into an estimated temperature using the thermistor's characteristics.

Applications

Thermistors are used in:

Temperature sensing

Battery monitoring

Power supplies

Heating systems

Electronic protection

Appliances

IoT temperature monitoring

14. Sensors

A sensor is a device that detects or measures something from the physical world and provides information that an electronic system can use.

Sensors are extremely important in IoT and robotics.

They allow a system to understand its environment.

Examples of sensors

Temperature sensor

Humidity sensor

Light sensor

Motion sensor

Distance sensor

Pressure sensor

Gas sensor

Sound sensor

Accelerometer

Gyroscope

Magnetic sensor

Touch sensor

Sensors in IoT

Imagine a temperature-monitoring system.

The sensor measures temperature.

The microcontroller reads the sensor.

The software processes the value.

The ESP32 sends the data over Wi-Fi.

A server stores the data.

A website displays the temperature.

The complete flow can be:

Physical world → Sensor → ESP32 → Internet → Server → Dashboard

This is one of the fundamental patterns of IoT.

Analog and digital sensors

Sensors can provide different types of outputs.

An analog sensor may provide a continuously varying voltage.

A digital sensor may communicate using a digital protocol such as:

I2C

SPI

UART

or simply provide a HIGH/LOW signal.

Understanding the sensor's output type is important when connecting it to a microcontroller.

15. Motors

A motor converts electrical energy into mechanical motion.

Motors are extremely important in robotics.

They allow robots to:

Move

Rotate wheels

Open doors

Move arms

Rotate mechanisms

Operate pumps

Move linear mechanisms

DC motor

A basic DC motor rotates when electrical power is applied.

Changing the polarity of the supply can reverse the direction of rotation.

The speed can often be controlled by changing the average power delivered to the motor, commonly using PWM in suitable driver circuits.

Why can't we normally connect a motor directly to an ESP32 GPIO?

A motor can require much more current than a microcontroller GPIO is designed to provide.

Motors can also generate electrical noise and voltage spikes.

Therefore, a motor driver or appropriate transistor/MOSFET circuit is normally used.

The architecture becomes:

ESP32 → Motor Driver → Motor

The ESP32 provides the control signals.

The motor driver handles the motor's power requirements.

Motor driver

A motor driver is an electronic circuit that allows a microcontroller to control a motor safely and effectively.

Depending on the driver, it can provide functions such as:

Motor ON/OFF

Speed control

Direction control

Braking

Current handling

This is a very important concept in robotics.

16. Servo Motors

A servo motor is designed for controlled movement.

Unlike a simple DC motor, which is commonly controlled mainly by speed and direction, a hobby servo is typically controlled to move its output shaft toward a commanded position within its mechanical range.

A typical hobby servo contains:

A motor

Gears

Control electronics

A position-feedback mechanism

Servo wires

Many hobby servos have three wires:

VCC

GND

Signal

The colors depend on the manufacturer, so always check the servo documentation.

How does a servo work?

The microcontroller sends a control signal to the servo.

The servo interprets that signal and moves its shaft toward the requested position.

For example, depending on the servo and control scheme, you may command positions such as:

90°

180°

The exact usable range varies between servo models.

Servo vs DC motor

A DC motor is primarily designed for continuous rotation.

A servo is designed for controlled positioning.

For example:

DC motor:

"Rotate the wheel."

Servo:

"Move the arm to this position."

This makes servo motors very useful in robotics.

They can be used for:

Robot arms

Pan-tilt mechanisms

Camera positioning

Steering mechanisms

Grippers

Small robotic joints

Important power consideration

A servo motor should not automatically be powered directly from an ESP32's 3.3V pin.

Servos can draw significant current, especially when starting or under load.

A suitable external power supply is often required.

When using a separate power supply for the servo and an ESP32, the grounds normally need to be connected together so that the control signal has a common reference, unless an appropriate isolated interface is being used.

How These Components Work Together

The real power of electronics comes from combining components.

A single component usually performs one basic function.

A complete project combines many components to create useful behavior.

Consider a simple automatic light system.

We could use:

LDR → detects light

Resistor → creates a voltage divider

ESP32 → processes the reading

MOSFET → switches the load

LED → produces light

The system could work like this:

Light level changes

LDR resistance changes

Voltage divider output changes

ESP32 reads the analog value

Software compares it with a threshold

ESP32 controls the MOSFET

MOSFET switches the LED

This is already a small IoT/automation system.

Now imagine replacing the LDR with a temperature sensor.

Or replacing the LED with a motor.

Or connecting the ESP32 to Wi-Fi.

The same fundamental electronics concepts continue to apply.

Component Categories

It is useful to mentally group these components according to what they do.

Components that control electrical behavior

Resistor

Potentiometer

Capacitor

Diode

Voltage regulator

Components that provide input

Push button

LDR

Thermistor

Sensors

Components that provide output

LED

Buzzer

Motor

Servo motor

Components that perform switching

Transistor

MOSFET

Relay

Components that provide power

Battery

Power supply

Voltage regulator