PTENES
MODULE 1.2 · FUNDAMENTALS

⚡ Essential electronics

Everything a robot does passes through wires. Here, you’ll cover the essentials of electronics so you don’t burn anything out: voltage, current, and resistance, Ohm’s law applied to an LED, the breadboard, the multimeter, and the ESP32 detail that trips up beginners the most: the logic level is 3.3 V.

6
Topics
Beginner
Level
Foundation
Type
Optional
Hardware (Wokwi works)
0%
0 of 0 topics read · Section 1 of 6

Detailed content

1

💧 Voltage, current, and resistance

Imagine a water tank connected to a pipe. The height of the water pushes it downward: that’s voltage. The amount of water flowing through the pipe per second is current. A narrow section of the pipe restricts the flow: that’s resistance. Circuits work the same way, except electrons take the place of water, and the “pipe” needs to form a closed path back to the power source.

🌱 New here?

Voltage (V, volt) is the difference in “electrical pressure” between two points; you always measure it between two points, one of which is usually GND. Current (A, ampere) is the amount of charge that passes per second; with the ESP32, we talk in milliamps (mA, thousandths of an ampere). Resistance (Ω, ohm) is how much a component impedes the flow. GND is the reference point, the circuit’s “zero volts.”

water electricity height = voltage flow = current narrow pipe = resistance + − battery resistor returns through GND (closed circuit) without a height difference, the water stops without a return path, nothing flows

How to read this map: Compare the two sides. On the left, the higher the tank, the greater the pressure; the narrow section of the pipe limits the flow. On the right, the battery is the tank, the resistor is the narrow pipe, and the cyan arrow shows that current needs to return to the negative terminal (GND). A loose wire anywhere means an open circuit and zero current.

QuantityUnitIn your robot
Voltagevolt (V)3.3 V on the ESP32 pins; 5 V over USB; 4.8 to 6 V from 4 AA batteries
Currentampere (A), mALED: 5 to 10 mA; ESP32 with Wi-Fi: up to a few hundred mA; TT motor: hundreds of mA
Resistanceohm (Ω), kΩ220 Ω for an LED; 10 kΩ in voltage dividers and pull-ups

Why learn this

Every choice of robot component comes down to a question about these three quantities: Does the battery provide enough voltage? Can the driver handle the motor’s current? What resistor protects the LED? Without these basics, you’re buying in the dark and finding out something went wrong by the smell of burning.

Key concepts

Volt (V)
pressure between two points
Ampere (A)
how much passes per second
Ohm (Ω)
how much it restricts the flow
Closed circuit
always returns to GND
2

🧮 Ohm’s law and the LED resistor

A Ohm’s law connects the three quantities: V = R × I. If you know two, you can calculate the third. At the workbench, the calculation you’ll use most often is for the LED resistor: the LED “uses up” a fixed part of the voltage, and the resistor needs to handle the rest, limiting the current to a safe level for the LED and the ESP32 pin.

🌱 New here?

A voltage drop (Vf) is the voltage an LED “uses” when it lights up: about 2.0 V for red, 2.1 V for yellow, and close to 3.0 V for blue and white. A resistor has no required orientation; an LED does. The values are printed in color code: 220 Ω = red, red, brown; 10 kΩ = brown, black, orange (the fourth band, gold, indicates 5% tolerance).

pin: 3.3 V total voltage LED: 2.0 V fixed drop (red) resistor: 1.3 V what’s left − = R = V ÷ I = 1,3 V ÷ 0,010 A = 130 Ω minimum for 10 mA; use the next standard value up with 220 Ω: I = 1.3 ÷ 220 ≈ 6 mA good brightness, pin with plenty of headroom, cool LED

How to read this map: The top row splits up the voltage (what the pin supplies minus what the LED uses is left for the resistor). The cyan box applies Ohm’s law to find the minimum resistor value. The bottom box checks the current using the value you’ll actually use: 220 Ω, the same one used for the blinking LED in module 1.1.

The calculation in four steps

1

Supply voltage

ESP32 pin = 3.3 V. If the LED is connected to 5 V, use 5 V in the calculation.

2

Subtract the LED’s voltage drop

Red ≈ 2.0 V. That leaves 1.3 V for the resistor.

3

Choose the current

Between 5 and 10 mA is enough for an indicator. Keep each ESP32 pin below about 12 mA; it isn’t a power source.

4

Divide and round up

R = 1.3 ÷ 0.010 = 130 Ω. Nearby standard values: 150, 220, 330 Ω. If you’re unsure, choose the higher value: the LED will be a little dimmer, and nothing will heat up.

✓ Do

  • ✓Use one resistor for each LED, even if they’re identical.
  • ✓Round the resistor value up to the next standard value.
  • ✓For a blue or white LED at 3.3 V, use 47 to 100 Ω (there’s little voltage left over).

✗ Don't

  • ✗Connecting an LED directly to a pin without a resistor burns out the LED and strains the pin.
  • ✗Using one resistor for several LEDs in parallel means the current won’t divide evenly.
  • ✗Connect a motor, large buzzer, or LED strip directly to a GPIO.

Why learn this

This is the calculation you’ll repeat most often at the workbench. The same idea (remaining voltage divided by the desired current) comes up in the HC-SR04 voltage divider, when choosing a transistor’s base resistor, and when reading the rover’s battery level.

Key concepts

V = R × I
two give you the third
LED voltage drop
2 V red, 3 V blue
Safe current
5 to 10 mA per LED
Color code
220 Ω = red, red, brown
3

🧩 Breadboard: how the connected rows work

A breadboard (breadboard) lets you build circuits without soldering, just by inserting wires and components. Inside, each hole is connected to others by hidden metal strips. If you don’t know this map, you can build everything “correctly” in the wrong row. There are two rules: in the middle, the 5 holes in the same column are connected; along the edges, the long + and − lines (the power rails) run along the board.

+ − connected columns of 5 ↕ (each column is a “node”) the lower half is another node center gap: separates the halves power rails: + at the top and − at the bottom, along the board

How to read this map: each colored line represents a metal strip beneath the holes. The green ones show two neighboring columns: they are NOT connected. The amber one shows that the same column on the other side of the gap is a different point. The red (+) and cyan (−) lines are the power rails. On some long boards, the rail is split in the middle: check with a multimeter (topic 4).

✓ Neat setup

  • ✓Always use a red wire for + and a black or blue wire for GND.
  • ✓Place the ESP32 over the center gap, with one row of pins on each half.
  • ✓Keep jumpers short and close to the board so you can easily trace the connections.
  • ✓Place the component’s two legs in different columns.

✗ Common mistakes

  • ✗A resistor with both legs in the same column is “shorted” and does nothing.
  • ✗Connecting + and − in the same column creates a direct short circuit across the power source.
  • ✗Powering a motor through the breadboard: the metal strips can’t handle the current.
  • ✗A wide ESP32 that occupies all the holes: some DevKits leave no free columns; use two breadboards side by side.

🌱 New here?

A jumper is the small wire with a rigid tip (male-to-male for a breadboard, male-to-female for connecting to module pins). A short circuit happens when + and − meet with nothing in between to limit the current: the power source delivers as much as it can, the wire heats up, and the battery may swell.

Why learn this

Half of the circuits that “don’t work” are correct on paper but one row off. Knowing the internal map helps you find the fault by looking, instead of rewriting the code.

Key concepts

Power rail
long + and − line
Jumper
quick-connect wire
Short circuit
+ meets − with no load
Neat setup
consistent colors, short wires
4

📏 Multimeter: measure before powering on

O multimeter is the instrument that turns “I think it’s right” into certainty. A simple digital model can handle everything Trail 1 asks you to do: measure a battery’s voltage , check the value of a resistor and test the continuity of a wire (whether it’s intact or two points are connected).

🌱 New here?

DC (direct current, shown by a V with a straight line) is what cells, batteries, and the ESP32 use; AC (alternating current, shown by a wave symbol) is what comes from a wall outlet, which you won’t measure in this course. Continuity is the mode that beeps when there’s a connection between the probes. The black probe goes into the COM terminal and onto GND in the circuit; the red probe goes into the VΩ terminal and onto the point you want to measure.

Three measurements you’ll repeat all the time

1

Battery voltage (circuit powered on)

Set the dial to V DC, 20 V range. Black probe on −, red probe on +. Four charged NiMH cells should read close to 5.2 to 5.6 V; below about 4.4 V, it’s time to recharge them. A negative reading just means the probes are reversed.

2

Resistor value (circuit powered off)

Set the dial to Ω, 2 kΩ range for a 220 Ω resistor. Touch one probe to each leg, without holding both tips with your fingers (your body acts as a resistor in parallel). Expected: 209 to 231 Ω for 5% tolerance.

3

Continuity of a wire or trace (powered off)

Set the dial to the sound symbol. Touch the probes together: it should beep. Then test the suspect jumper or two breadboard holes. No beep = broken wire or holes that aren’t connected.

⚠️ Measure resistance and continuity only with everything powered off

In these modes, the multimeter injects a small current. Measuring with the battery connected gives an incorrect reading and can damage the device. And never leave the red probe in the current terminal (10A or mA) when measuring voltage: that creates a short circuit through the multimeter.

✓ Good habit

  • ✓Measure the battery before blaming the code.
  • ✓Check that the ESP32’s 3V3 pin reads close to 3.3 V.
  • ✓Start with the highest range if you don’t know the value.

✗ Bad habit

  • ✗Turn the dial while the probes are touching the circuit.
  • ✗Measure current without knowing what you’re doing (save that for later).
  • ✗Leave the multimeter on: its 9 V battery will run out.

💡 Don’t have a multimeter yet?

In Wokwi, there’s a “Voltmeter” component, and the ESP32 itself can measure voltage through the ADC (topic 6). But a basic digital multimeter is one of the cheapest and most useful tools on the workbench; it’s worth getting one before you work with motors.

Why learn this

When the rover in module 1.6 stops in the middle of the room, the first question is “is the battery OK?” If you can measure it in seconds, you won’t waste the afternoon suspecting the program. Checking continuity before powering up also saves boards from a short you didn’t notice.

Key concepts

DC range
V with a straight line
Continuity
beeps when there’s a connection
Black probe on GND
measurement reference
Powered off
to measure Ω and continuity
5

🔢 Digital, analog, and 3.3 V logic

A digital signal has only two states: on (HIGH) or off (LOW), like a switch. An analog signal varies continuously, like the voltage from a turning potentiometer or a discharging battery. The ESP32 reads both: digital signals with digitalRead() and the analog one through the ADC with analogRead(). And here's the critical point: on the ESP32, HIGH is 3.3 V, not 5 V.

🌱 New here?

GPIO (general-purpose input/output) is a pin that the program configures as an input or output. ADC (analog-to-digital converter) turns a voltage into a number: on the ESP32, it has 12 bits, meaning values from 0 to 4095. Logic level is the voltage range the board understands as 0 or 1. A level shifter is a small module that translates 5 V signals to 3.3 V and vice versa.

3,6 3,3 0 V danger zone: 5 V here will burn out the pin digital: HIGH or LOW analog: any value ADC: 0 V → 0 · 3.3 V → 4095 digitalRead() → 1 or 0

How to read this map: on the left, the green line only occupies two levels, 0 and 3.3 V. On the right, the cyan line passes through all the values in between, and the ADC gives a proportional number. The red band at the top is the limit: the ESP32 tolerates only about 3.6 V at a pin, so a sensor that outputs 5 V needs a voltage divider (topic 6) or a level shifter.

Kit componentSignal it outputsCaution on the ESP32
Buttondigitaluse a pull-up (topic 6)
Potentiometeranalogpower it with 3.3 V, not 5 V
HC-SR04 (ECHO)5 V digital pulsevoltage divider on ECHO
IR obstacle sensordigitalpower it with 3.3 V when the module supports it

💡 Which pin to use for the ADC

On the classic ESP32 (WROOM-32), prefer ADC1 pins (GPIO 32 to 39). ADC2 pins stop reading when Wi-Fi is on, and you'll only see this in Track 2, by which time you've already forgotten why. GPIO 34 to 39 are input-only: great for reading sensors, useless for turning on an LED.

Why learn this

Many tutorials and modules were made for the Arduino Uno, which runs at 5 V. Connecting one of these directly to the ESP32 is the fastest way to kill a pin, and sometimes the whole board. Knowing what signal each component outputs determines which pin to use, which reading function to call, and whether protection is needed.

Key concepts

HIGH / LOW
3.3 V / 0 V on the ESP32
ADC
voltage → 0 to 4095
GPIO
input or output pin
Level shifter
5 V ↔ 3,3 V
6

🪜 Voltage divider and pull-up resistor

Two circuits made from two components show up in almost every robot. A voltage divider uses two resistors in series to deliver a fraction of the voltage: Vsaída = Ventrada × R2 ÷ (R1 + R2). With two equal resistors, the output is half the input. A pull-up is a resistor that “pulls” an input up to 3.3 V while nothing is happening, so the pin never stays undefined.

🌱 New here?

A floating input is an input pin connected to nothing: it picks up noise from its surroundings, and its reading switches between 0 and 1 on its own. The ESP32 has an internal pull-up (a resistor of tens of kΩ inside the chip) that you enable in code with INPUT_PULLUP. With it, the button goes between the pin and GND: it reads 1 when released and 0 when pressed.

voltage divider battery ≈ 5.2 V R1 = 10 kΩ GPIO 34 ≈ 2,6 V R2 = 10 kΩ GND button with internal ESP32 3,3 V pull-uppull-up GPIO 4 button GND released: reads 1 pressed: reads 0

How to read this map: on the left, follow the voltage from top to bottom: the two equal resistors divide the battery voltage in half, and the green midpoint goes to GPIO 34, always staying below 3.3 V. On the right, the internal resistor connects GPIO 4 to 3.3 V; when you press the button, the pin connects directly to GND and reads 0. The “inverted” logic (pressed = 0) is normal with a pull-up.

Goal: read the voltage of 4 AA batteries through the divider and the state of a button with an internal pull-up, displaying both in the Serial Monitor twice per second. In Wokwi, replace the battery with a potentiometer connected between 3.3 V and GND (the middle output to GPIO 34) and watch the “battery” voltage change.

battery-and-button.ino
// Voltage divider + button with pull-up (ESP32, esp32 package 3.x)
// Battery → R1 10k → GPIO 34 → R2 10k → GND   |   Button: GPIO 4 ↔ GND

const int PINO_BATERIA = 34;   // ADC1, input only
const int PINO_BOTAO   = 4;    // has internal pull-up
const float FATOR_DIVISOR = 2.0;  // (R1 + R2) / R2 = (10k + 10k) / 10k

void setup() {
  Serial.begin(115200);
  pinMode(PINO_BOTAO, INPUT_PULLUP);  // released = HIGH, pressed = LOW
  analogReadResolution(12);           // 0 a 4095
  Serial.println("Battery and button reading ready");
}

void loop() {
  int bruto = analogRead(PINO_BATERIA);               // number from 0 to 4095
  int mvPino = analogReadMilliVolts(PINO_BATERIA);    // already in mV, calibrated
  float vBateria = mvPino * FATOR_DIVISOR / 1000.0;  // undoes the divider
  bool apertado = (digitalRead(PINO_BOTAO) == LOW);

  Serial.print("ADC: ");        Serial.print(bruto);
  Serial.print(" | pin: ");    Serial.print(mvPino);   Serial.print(" mV");
  Serial.print(" | battery: "); Serial.print(vBateria, 2); Serial.print(" V");
  Serial.print(" | button: ");   Serial.println(apertado ? "APERTADO" : "solto");
  delay(500);
}

How to check

  • ✓With 4 fully charged NiMH batteries, “battery” should show around 5.2 to 5.6 V; check with a multimeter (a difference of up to about 0.1 V is normal).
  • ✓“button” changes to PRESSED only while you hold it down.
  • ✗“button” changing on its own? The pin you chose doesn't have a pull-up (GPIO 34 to 39), or the wire is loose.
  • ✗ADC stuck at 4095? The pin is receiving 3.3 V or more: the divider is missing or wired backwards.

⚠️ Calculate before connecting to the battery

With 2 18650 cells in series (up to 8.4 V), two equal resistors would deliver 4.2 V to the pin: above the limit. Use R1 = 20 kΩ and R2 = 10 kΩ (divides by 3, maximum of 2.8 V) and change FATOR_DIVISOR to 3.0. Always redo the calculation using the battery's MAXIMUM fully charged voltage.

Why learn this

The divider protects the ESP32 from the 5 V ECHO pin on the HC-SR04 (module 1.4) and lets the rover warn you when the battery is running low. The pull-up lets buttons, limit switches, and “collision” sensors give reliable readings without false signals.

Key concepts

Divider
Vin × R2 ÷ (R1 + R2)
Internal pull-up
INPUT_PULLUP
Floating input
reads random noise
analogReadMilliVolts
ADC already in mV

✅ Module summary

✓
Voltage pushes, current flows, resistance holds it back, and current only flows when there's a closed path to GND.
✓
V = R × I: a red LED at 3.3 V needs at least 130 Ω; 220 Ω gives about 6 mA.
✓
Breadboard: groups of 5 holes are connected in the middle, power rails run along the edges, and the center gap separates the two sides.
✓
Multimeter: measure voltage with everything connected; measure resistance and continuity with everything disconnected.
✓
The ESP32 runs at 3.3 V: A 5 V signal on a pin will burn it out; a divider or level shifter will solve the problem.
✓
Voltage divider and pull-up: measure the battery safely and read buttons without false signals.

To go further

Next module

1.3 · ESP32: your first program. Arduino IDE 2.x, esp32 3.x package, your first upload to a real board, Serial Monitor, inputs, and PWM with the new API.