Alin Li Elektroonika alused

Everything You Need to Know Before ESP32

Vanusele 9–14 | Varasemat kogemust pole vaja

⚛️ 1. Aatomid ja elektronid — kõige algus

Everything in the universe — your desk, your body, the air you breathe — is made of tiny particles called atoms. Aatomid on nii väikesed, et neid mahub nõelaotsale miljoneid!

Inside an Atom

Protons + Neutronid TUUM e⁻ e⁻ e⁻ Free electron! (Saab ringi liikuda) Inner electron (Tihedalt seotud) In metals like copper, outer electrons can move freely — this is what makes electricity possible!
⚡ Conductors Materjalid, kus elektronid liiguvad easily. Näited: vask, alumiinium, kuld, hõbe, vesi (soolaga). Sellepärast tehaksegi juhtmed vasest!
🛑 Isolaatorid Materjalid, kus elektronid cannot move easily. Examples: rubber, plastic, glass, wood, air. That's why wires have plastic coating!
Fun Fact

When you get a static shock from touching a doorknob, that's billions of electrons jumping from your body to the metal all at once! It's the same electricity — just uncontrolled.

🔋 2. Pinge — tõukejõud

Voltage is the force that pushes electrons through a wire. It's measured in Volts (V), mis on nimetatud teadlase Alessandro Volta järgi.

🚰 Veemaailm

Voltage is like water pressure. Kõrge veetorn surub vett torudest läbi tugevamini kui madal torn.

=

⚡ Electric World

A 9V battery pushes electrons harder than a 1.5V patarei. Suurem pinge = tugevam tõuge!

Common Voltages You'll See

SourceVoltageSafe?Used For
AA-patarei1.5V✅ Very safeToys, remotes
USB Port5V✅ SafeCharging phones, Arduino
9V Battery9V✅ SafeSmoke detectors, guitars
Car Battery12V⚠️ CarefulCars, some electronics
Wall Outlet (US)120V❌ Dangerous!Home appliances
Wall Outlet (EU/ME)220–240V❌ Very dangerous!Home appliances
Toiteliinid10,000V+☠️ Deadly!Electricity distribution
Important

In our ESP32 projects, we only use 3.3V ja 5V — completely safe voltages powered by USB. We MITTE KUNAGI work with wall outlets or high voltage. Always ask an adult before working with anything above 12V!

Key Concept

Voltage is always measured between two points. Seepärast on patareidel + (positiivne) and a – (negative) side. The difference between them is the voltage.

🌊 3. Vool — liikumine

Current is the amount of electrons actually flowing through a wire. It's measured in Amprid (A), või lihtsalt Amprid.

🚰 Veemaailm

Current is like the amount of water flowing through a pipe. A fire hose has more current than a drinking straw.

=

⚡ Electric World

LED tarbib umbes 20mA (väike nire). Mikrolaineahi kasutab umbes 10A (hiiglaslik voog!).

Current Units

1 A (amper) Full ampere — used for big devices (motors, heaters)
1 mA (milliamper) = 0.001 A — used for LEDs, sensors, small circuits
1 μA (mikroamper) = 0.000001 A — used for sleep mode, tiny sensors
Think About It

The ESP32 typically uses about 80mA when running normally, and can drop to 10μA in deep sleep mode. That's like going from drinking a glass of water to barely a single drop!

If voltage is the "push" and current is the "flow" — what determines how much actually flows?

Click to reveal the answer! 👆
Resistance! The next section explains how resistance controls the flow of current, just like a narrow pipe slows down water.

🚧 4. Takistus — aeglustamine

Resistance is anything that slows down the flow of electrons. It's measured in Oomid (Ω), mis on nimetatud Georg Ohmi järgi.

🚰 Veemaailm

Resistance is like the width of a pipe. Peenike toru laseb vähem vett läbi. Ummistunud torul on väga suur takistus.

=

⚡ Electric World

A resistor limits how much current flows. A 1kΩ resistor limits more than a 100Ω resistor.

Why Do We Need Resistance?

Without resistance, too much current would flow and burn out your components! Resistors are like bodyguards that protect your LEDs and chips.

Without vs With Resistor

❌ Without Resistor 3.3V Too much current! 💥 LED burns out! Current: uncontrolled = DAMAGE ✅ With Resistor 3.3V 220Ω 💡 Safe! Current: ~15mA = PERFECT

Resistor Color Bands

Resistors have colored stripes that tell you their value. You'll learn to read these as you work with circuits!

ColorDigitMeeldejätmise nipp
⬛ Black0Blackout = zero
🟫 Pruun11 pruunkaru
🔴 Punane22 punast silma
🟠 Oranž33 apelsini
🟡 Kollane44-leheline kollane ristik
🟢 Roheline55 green fingers
🔵 Sinine66-sided blue dice
🟣 Violetne77 violet flowers
⬜ Gray88 gray rocks
⬜ White99 white clouds

📐 5. Ohmi seadus — võluvalem

This one formula connects voltage, current, ja resistance together. It's the most important formula in electronics!

V = I × R
Voltage (V) = Current (A) × Resistance (Ω)

The Ohm's Law Triangle — Cover What You Need!

V I R × Cover what you want to find → the remaining parts show the formula!

Harjutame!

Example 1: Find Current Battery = 3.3V, Resistor = 220Ω
I = V ÷ R = 3.3 ÷ 220 = 0.015A = 15mA
Ideaalne LED-ile!
Example 2: Find Resistance Battery = 5V, LED needs 20mA
R = V ÷ I = 5 ÷ 0.02 = 250Ω
Use a 270Ω resistor (closest common value)

9V patarei on ühendatud 1000Ω (1kΩ) takistiga. Kui suur vool läbib ahelat?

Click to reveal the answer! 👆
I = V ÷ R = 9 ÷ 1000 = 0.009A = 9mA. See on väike ja ohutu vool!

🔄 6. Circuits — The Complete Path

A circuit is a complete loop that electricity flows through. The word "circuit" comes from "circle" — because electricity must travel in a complete loop to work!

Avatud ja suletud vooluring

❌ Open Circuit (Broken) BAT BREAK! VÄLJAS Puudub terviklik tee → vool ei liigu LED stays OFF ✅ Closed Circuit (Complete) BAT SEES! Complete loop → Current flows! LED lights up 💡
Every Circuit Has

1. Toiteallikas (aku, USB) — annab edasiviiva jõu.
2. Juht (juhe) — elektronide liikumistee.
3. Koormus (LED, mootor, sumisti) — kasutab elektrit.
4. Täielik ahel — back to the power source. If any part breaks, the circuit is "open" and nothing works!

Fun Fact

A switch (nagu seinal olev valguslüliti) lihtsalt katkestab või sulgeb vooluringi. Kui see on SEES, on vooluring suletud (terviklik). Kui see on VÄLJAS, on vooluring avatud (katkestatud). See ongi kõik, mida lüliti teeb!

🔗 7. Series vs Parallel Circuits

There are two main ways to connect components in a circuit. This is super important to understand!

Series Circuit

BAT L1 L2 L3 Üks voolutee — kõikjal sama vool If one breaks, ALL stop! 🔴

Rööpvooluring

BAT L1 L2 L3 Mitu teed — sama pinge If one breaks, others still work! ✅
FeatureSeriesRööbiti
TeeÜksainus vooluteeMitu teed (harud)
CurrentSame everywhereSplits between branches
VoltageSplits between componentsSame across all branches
If one breaks?KÕIK lakkavad töötamastTeised töötavad edasi
Real exampleVanad jõulutuledYour house wiring!
Fun Fact

Vanad jõulutuled olid ühendatud series — if one bulb burned out, the entire string went dark and you had to find the bad one! Modern Christmas lights use parallel so one dead bulb doesn't ruin the whole string.

🧩 8. Electronic Components

These are the basic building blocks you'll use in your circuits. Get to know them — they'll be your best friends!

🔧

Resistor

What it does: Piirab voolu. Kaitseb teisi komponente liigse võimsuse eest.
Unit: Oomid (Ω). Levinud väärtused: 220Ω, 1kΩ, 10kΩ
Tip: Has no direction — you can connect it either way!

💡

LED (Light-Emitting Diode)

What it does: Süttib, kui vool sellest läbi liigub.
Important: Has a direction! Long leg = positive (+), Short leg = negative (–)
Vajab: Kasuta alati koos takistiga (tavaliselt 220Ω), muidu põleb see läbi!
Colors: Red, green, blue, yellow, white — depends on materials inside.

🔘

Push Button / Switch

What it does: Avab või sulgeb vajutamisel vooluringi.
Types: Hetkeline (SEES ainult vajutades) või lülituv (jääb SISSE/VÄLJA)
In ESP32: Used as digital input — the microcontroller reads if it's pressed!

⚡

Capacitor

What it does: Stores and releases small amounts of electrical energy — like a tiny rechargeable battery.
Unit: Farads (F). Usually microfarads (μF) or picofarads (pF)
Uses: Smoothing power, filtering noise, timing circuits.
Types: Ceramic (small, no direction) and Electrolytic (bigger, has + and – sides!)

🔀

Transistor

What it does: Toimib elektroonilise lüliti või võimendina. Väike signaal juhib suuremat.
Think of it as: Veekraan — väike käepideme pööre juhib suurt veevoolu.
Why it matters: Transistors are the building blocks of ALL computer chips! A modern CPU has billions of transistors!

🔌

Diode

What it does: Laseb voolul liikuda ainult one direction — like a one-way street for electricity.
LED is a type of diode! (Valgusdiood)
Used for: Protecting circuits from reverse current, converting AC to DC power.

🎚️

Potentsiomeeter (muuttakisti)

What it does: Takisti nupuga, mida keerates saad takistust muuta.
Used for: Volume knobs, brightness dimmers, reading analog input on ESP32.
Has 3 pins: Üks ots, liugur (keskel) ja teine ots.

Component Directions

Suunata (ühenda kumba pidi tahes): Resistors, push buttons, potentiometers
Has direction (connect correctly!): LEDs (long leg = +), electrolytic capacitors (marked + side), diodes (stripe = negative side), transistors (check datasheet)

🖥️ 9. Chips & Integrated Circuits (ICs)

Üks Integrated Circuit (IC) — often just called a chip — is a tiny piece of silicon with millions or billions of transistors packed inside. It's like a whole city of electronic components shrunk to the size of a fingernail!

🏗️ Before ICs (1960s)

Building a computer required a room full of separate wires, resistors, and transistors. Slow, expensive, unreliable.

→

📱 Pärast integraallülitusi (tänapäeval)

Üks kiip, mille suurus on nagu sinu thumbnail holds billions of transistors. Your phone is more powerful than early supercomputers!

Types of Chips

🧠 CPU (keskprotsessor) The "brain" — executes instructions. Found in your computer and phone.
💾 Mälukiibid (RAM/Flash) Store data. RAM is temporary (lost when power off). Flash is permanent.
📡 Sidekiibid Handle Wi-Fi, Bluetooth, cellular. The ESP32 has these built in!
⚡ Microcontroller (MCU) Terve miniarvuti ühel kiibil — protsessor + mälu + sisend/väljund. Just selline on ESP32!
Fun Fact

The first integrated circuit was invented in 1958 by Jack Kilby. It had just 1 transistor. Tänapäeval on Apple'i M4 kiibis üle 28 miljardit transistorit! See on nagu koliksid ühest majast linna, mis on suurem kui ükski linn Maal.

🤖 10. Mikrokontroller ja mikroprotsessor

These sound similar but are quite different! Understanding the difference helps you know why we use the ESP32.

FeatureMikroprotsessorMikrokontroller
What is it?Just a CPU (brain)CPU + Memory + I/O all in one!
Vajab lisasid?Yes — needs external RAM, storage, etc.Ei — kõik on sisseehitatud!
ToideHigh power (watts)Väike energiatarve (millivatid)
SpeedVery fast (GHz)Keskmine (MHz)
Cost$50 – $1000+$1 – $20
Good atComplex tasks (running OS, games, browsers)Specific tasks (read sensor, blink LED, control motor)
ExamplesIntel Core, AMD Ryzen, Apple M4ESP32, Arduino, STM32, Raspberry Pi Pico
Found inLaptops, desktops, serversWashing machines, cars, toys, IoT devices
The ESP32 is a Microcontroller!

It has everything on one chip: a dual-core CPU, RAM, Flash memory, Wi-Fi, Bluetooth, GPIO pins, ja built-in sensors. Sellepärast ongi see nii populaarne — terviklik süsteem vaid mõne dollari eest!

📊 11. Digitaalsed ja analoogsignaalid

In electronics, signals come in two types. Understanding this is essential for working with sensors!

Digital Signal

SEES VÄLJAS Ainult SEES (1) või VÄLJAS (0)

Analoogsignaal

High Madal Any value between Low and High
FeatureDigitalAnaloog
ValuesAinult 0 või 1 (VÄLJAS või SEES)Any value in a range (smooth)
Nagu...Valguslüliti (sees/väljas)Dimmer knob (any brightness)
ESP32 readingdigitalRead() → 0 or 1analogRead() → 0 to 4095
ExamplesButton, switch, LED on/offTemperature, light level, sound
ADC — sild

The real world is analog (temperature changes smoothly), but computers think in digital (0s and 1s). The ADC (analoog-digitaalmuundur) built into the ESP32 converts analog signals to digital numbers so the chip can understand them!

🔢 12. Kahendsüsteem ja bitid — kuidas arvutid mõtlevad

Computers don't understand letters or decimal numbers. They only understand two things: 0 and 1. Seda nimetatakse binary!

Why Binary?

Inside a computer, electricity is either flowing (1) või not flowing (0). „Natuke voolamist“ pole olemas. Seetõttu sobib kahendsüsteem elektroonikale ideaalselt — iga juhe on kas SEES või VÄLJAS!

Counting in Binary

Each position in binary is worth double the previous one (just like decimal positions are worth 10× more):

1
128
0
64
1
32
0
16
1
8
1
4
0
2
1
1
=
173

128 + 0 + 32 + 0 + 8 + 4 + 0 + 1 = 173

Key Terms

Bit Üks 0 või 1. Väikseim andmeühik. Nagu üks valguslüliti.
Byte 8 bits grouped together. Can represent 0–255 (256 values). Like 8 light switches.
Kilobyte (KB) 1024 baiti. Lühike tekstifail, näiteks mõni lõik teksti.
Megabait (MB) 1024 KB. Foto või lühike laul. ESP32-l on 4 MB välkmälu!

What is the binary number 1010 in decimal?

Click to reveal the answer! 👆
1×8 + 0×4 + 1×2 + 0×1 = 8 + 0 + 2 + 0 = 10! The binary 1010 equals decimal 10.

🍞 13. Makettplaadid — sinu ehitusplats

A breadboard lets you build circuits without soldering! Pista lihtsalt juhtmed ja komponendid aukudesse. Osi saab hõlpsasti lisada, eemaldada ja ümber paigutada.

How a Breadboard is Connected Inside

+ − ← All connected horizontally (Power +) → ← All connected horizontally (Ground −) → a b c d e ↕ Each column of 5 holes is connected vertically ───── CENTER GAP (nothing connects across) ───── f g h i j ↕ Same — each column of 5 is connected VCC GND
🔴🔵 Toiterööpad The long rows at top and bottom. Red (+) for power, Blue (–) for ground. All holes in each row are connected horizontally.
🟢 Põhiala The middle section. Each column of 5 holes (a–e or f–j) is connected vertically. The center gap separates the two halves — nothing connects across it!
Common Mistakes

1. Putting both legs of a component in the same column (that shorts it!).
2. Forgetting that the center gap separates the two halves.
3. Toiterööpad pole ühendatud — need ei saa automaatselt voolu. Ühenda need juhtmetega toiteallikaga!

🔍 14. Multimeetri kasutamine

A multimeter is your detective tool — it measures voltage, current, and resistance. Every electronics maker needs one!

What Can It Measure?

V — Voltage Set dial to V (DC). Touch red to +, black to –. Read the display!
Ω — Resistance Set dial to Ω. Touch both probes to resistor ends. Shows ohms.
A — voolutugevus Set dial to A. Must be in SERIES with the circuit. Be careful!
Continuity Mode

Enamikul multimeetritel on continuity mode (näeb välja nagu helilaine sümbol). See piiksub, kui kahe punkti vahel on ühendus. Väga kasulik kontrollimaks, kas juhtmed on ühendatud või miski on katki!

Safety

Mitte kunagi measure current (amps) on a wall outlet or high-voltage source. For our ESP32 projects, we only measure low voltages (3.3V–5V) which are completely safe.

🛡️ 15. Ohutusreeglid

Electronics is fun and safe when you follow the rules! These aren't just suggestions — they're essential.

1
Ära puutu KUNAGI seinapistikuid ega kõrgepinget. We only work with USB-powered circuits (5V or less). If you see exposed wires or damaged cables, tell an adult immediately.
2
Lahuta alati toide enne vooluahela muutmist. Unplug the USB cable before adding or removing wires and components. This prevents short circuits and damage.
3
Double-check your wiring before powering on. Ühenda pluss plussiga ja miinus miinusega. Vastupidine ühendus võib komponente kahjustada.
4
Kasuta LED-idega alati takisteid. Without a resistor, too much current flows and the LED burns out (sometimes with a tiny pop and bad smell!).
5
Don't mix voltage levels. The ESP32 uses 3.3V. Never connect 5V directly to its pins. If using 5V sensors, use a voltage divider or level shifter.
6
Keep your workspace clean and organized. Tiny components can get lost easily. Use containers for parts and keep drinks away from your circuits!
7
If something smells burnt or gets hot — disconnect immediately! Unplug USB, wait for it to cool, then check your circuit for errors.
8
Ask questions! If you're unsure about something, ask your instructor or an adult. There are no silly questions in electronics — only fried components from not asking!

💻 16. Programmeerimise alused

To tell the ESP32 what to do, you write code (juhised) programmeerimiskeeles nimega C++ using the Arduino framework. Here are the key concepts:

What is a Program?

Programm on list of instructions that the computer follows, one by one, from top to bottom. It's like a recipe — do step 1, then step 2, then step 3...

Key Concepts

📦

Variables — Storing Data

Muutuja on nagu labeled box that holds a value. You give it a name and put something inside.

Variables int age = 12; // Täisarv float temperature = 23.5; // Kümnendarv bool isOn = true; // true või false String name = "Alin Li"; // Tekst
🔧

Functions — Reusable Blocks

Funktsioon on named block of code that does a specific job. You can call it whenever you need it.

Functions // Defineeri funktsioon void blinkLED() { digitalWrite(2, HIGH); // Lülita sisse delay(500); digitalWrite(2, LOW); // Lülita välja delay(500); } // Kutsu seda välja, millal soovid! blinkLED(); // Vilguta üks kord blinkLED(); // Vilguta uuesti
❓

Conditions — Making Decisions

Use if/else to make the program choose what to do based on conditions.

Conditions int temperature = 35; if (temperature > 30) { Serial.println(„Palav on!“); } else if (temperature > 20) { Serial.println(„Ilm on mõnus.“); } else { Serial.println(„Külm on!“); }
🔁

Tsüklid — asjade kordamine

Tsüklid võimaldavad sul repeat code without writing it over and over.

Tsüklid // For-tsükkel: vilguta 5 korda küsimusele (int i = 0; i < 5; i++) { blinkLED(); // Töötab 5 korda! } // While-tsükkel: jätka, kuni nupp on all while (digitalRead(15) == LOW) { Serial.println("Button held!"); }

The Arduino Program Structure

Every Arduino/ESP32 program has exactly two required functions:

setup() — Runs ONCE at start
→
loop() — Runs FOREVER
→
loop() again...
→
loop() forever...
Arduino Structure void setup() { // Töötab ühe korra plaadi sisselülitamisel // Seadista viigud, alusta jadasidet, lähtesta vajalik } void loop() { // Kordub lõputult // Loe andureid, tee otsuseid, juhi väljundeid }

🚀 17. Oled ESP32 jaoks valmis!

Congratulations! You now understand the fundamentals of electronics that form the foundation for everything you'll do with the ESP32. Let's review what you've learned:

⚛️ Atoms & ElectronsElectricity is the flow of electrons
🔋 PingeThe push (measured in Volts)
🌊 CurrentThe flow (measured in Amps)
🚧 TakistusThe slowdown (measured in Ohms)
📐 Ohmi seadusV = I × R
🔄 VooluringidComplete loops for electricity
🧩 KomponendidResistors, LEDs, capacitors...
🖥️ Kiibid ja integraallülitusedBillions of transistors in one package
🤖 MikrokontrolleridCPU + Memory + I/O = ESP32!
📊 Digitaalne või analoogne0/1 võrreldes sujuvate vahemikega
🔢 KahendsüsteemThe language of computers
💻 ProgrammeerimineVariables, functions, loops, conditions

Järgmine samm: Alin Li ESP32 avastaja!

Nüüd, kui alused on olemas, oled valmis esimeseks ESP32 programmiks, LEDide vilgutamiseks, andurite lugemiseks ja ägedateks projektideks!

⚡🎉🚀