Alin Li أساسيات الإلكترونيات

Everything You Need to Know Before ESP32

للأعمار 9–14 | لا خبرة مطلوبة

⚛️ 1. الذرات والإلكترونات — من هنا تبدأ القصة

Everything in the universe — your desk, your body, the air you breathe — is made of tiny particles called atoms. الذرات صغيرة جدًا، حتى إن الملايين منها تتسع على رأس إبرة!

Inside an Atom

Protons + النيوترونات النواة e⁻ e⁻ e⁻ Free electron! (يمكن تحريكه) Inner electron (مرتبط بإحكام) In metals like copper, outer electrons can move freely — this is what makes electricity possible!
⚡ Conductors مواد تتحرك فيها الإلكترونات easily. أمثلة: النحاس والألومنيوم والذهب والفضة والماء (مع الملح). ولهذا تُصنع الأسلاك من النحاس!
🛑 العوازل مواد تتحرك فيها الإلكترونات 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. الجهد — قوة الدفع

Voltage is the force that pushes electrons through a wire. It's measured in Volts (V)، نسبةً إلى العالم Alessandro Volta.

🚰 عالم المياه

Voltage is like water pressure. يدفع برج المياه المرتفع الماء عبر الأنابيب بقوة أكبر من البرج القصير.

=

⚡ Electric World

A 9V battery pushes electrons harder than a بطارية 1.5V. جهد أكبر = دفع أقوى!

Common Voltages You'll See

SourceVoltageSafe?Used For
بطارية AA1.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
خطوط الطاقة10,000V+☠️ Deadly!Electricity distribution
Important

In our ESP32 projects, we only use 3.3V و5V — completely safe voltages powered by USB. We أبدًا 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. لهذا تحتوي البطاريات على + (موجب) and a – (negative) side. The difference between them is the voltage.

🌊 3. التيار — التدفق

Current is the amount of electrons actually flowing through a wire. It's measured in أمبير (A)، أو ببساطة أمبير.

🚰 عالم المياه

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

=

⚡ Electric World

يستهلك مصباح LED نحو 20mA (تدفّق ضئيل). يستخدم فرن الميكروويف نحو 10A (تدفق ضخم!).

Current Units

1 A (أمبير) Full ampere — used for big devices (motors, heaters)
1 mA (ملي أمبير) = 0.001 A — used for LEDs, sensors, small circuits
1 μA (ميكرو أمبير) = 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. المقاومة — إبطاء التدفق

Resistance is anything that slows down the flow of electrons. It's measured in أوم (Ω)، نسبةً إلى Georg Ohm.

🚰 عالم المياه

Resistance is like the width of a pipe. يسمح الأنبوب الضيق بمرور ماء أقل. وتكون مقاومة الأنبوب المسدود عالية جدًا.

=

⚡ 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!

ColorDigitحيلة للتذكّر
⬛ Black0Blackout = zero
🟫 بني11 دب بني
🔴 أحمر22 عينان حمراوان
🟠 برتقالي33 برتقالات
🟡 أصفر4برسيم أصفر ذو 4 أوراق
🟢 أخضر55 green fingers
🔵 أزرق66-sided blue dice
🟣 بنفسجي77 violet flowers
⬜ Gray88 gray rocks
⬜ White99 white clouds

📐 5. قانون أوم — المعادلة السحرية

This one formula connects voltage, current، و 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!

لنتدرّب!

Example 1: Find Current Battery = 3.3V, Resistor = 220Ω
I = V ÷ R = 3.3 ÷ 220 = 0.015A = 15mA
مثالي لمصباح LED!
Example 2: Find Resistance Battery = 5V, LED needs 20mA
R = V ÷ I = 5 ÷ 0.02 = 250Ω
Use a 270Ω resistor (closest common value)

بطارية 9V موصولة بمقاومة 1000Ω ‏(1kΩ). ما شدة التيار المار؟

Click to reveal the answer! 👆
I = V ÷ R = 9 ÷ 1000 = 0.009A = 9mA. إنه تيار صغير وآمن!

🔄 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!

دائرة مفتوحة مقابل دائرة مغلقة

❌ Open Circuit (Broken) BAT BREAK! إيقاف لا مسار مكتمل ← لا تيار LED stays OFF ✅ Closed Circuit (Complete) BAT تشغيل! Complete loop → Current flows! LED lights up 💡
Every Circuit Has

1. مصدر الطاقة (بطارية، USB) — يوفّر الدفع.
2. موصل (سلك) — المسار الذي تسلكه الإلكترونات.
3. الحمل (LED، محرّك، طنّان) — يستهلك الكهرباء.
4. حلقة كاملة — back to the power source. If any part breaks, the circuit is "open" and nothing works!

Fun Fact

A switch (مثل مفتاح الإضاءة على الجدار) يقطع الدارة أو يغلقها ببساطة. عند تشغيله، تكون الدارة مغلقة (مكتملة). وعند إيقافه، تكون الدارة مفتوحة (مقطوعة). هذا كل ما يفعله المفتاح!

🔗 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 مسار واحد — التيار نفسه في كل موضع If one breaks, ALL stop! 🔴

دائرة على التوازي

BAT L1 L2 L3 مسارات متعددة — الجهد نفسه If one breaks, others still work! ✅
FeatureSeriesعلى التوازي
المسارمسار واحد فقطمسارات متعددة (فروع)
CurrentSame everywhereSplits between branches
VoltageSplits between componentsSame across all branches
If one breaks?تتوقف كلها عن العملتستمر المكونات الأخرى في العمل
Real exampleأضواء عيد الميلاد القديمةYour house wiring!
Fun Fact

كانت أضواء عيد الميلاد القديمة تُوصَّل على 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: يحدّ من تدفق التيار. يحمي المكونات الأخرى من الطاقة الزائدة.
Unit: أوم (Ω). قيم شائعة: 220Ω و1kΩ و10kΩ
Tip: Has no direction — you can connect it either way!

💡

LED (Light-Emitting Diode)

What it does: يضيء عندما يمر فيه التيار.
Important: Has a direction! Long leg = positive (+), Short leg = negative (–)
الاحتياجات: استخدمه دائمًا مع مقاومة (عادةً 220Ω)، وإلا فسيحترق!
Colors: Red, green, blue, yellow, white — depends on materials inside.

🔘

Push Button / Switch

What it does: يفتح الدائرة أو يغلقها عند الضغط عليه.
Types: لحظي (يعمل أثناء الضغط فقط) مقابل تبديل (يبقى مشغّلًا/مطفأً)
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: يعمل كمفتاح إلكتروني أو مضخّم. تتحكم إشارة صغيرة في أخرى أكبر.
Think of it as: صنبور ماء — لفة صغيرة للمقبض تتحكم في تدفق كبير للمياه.
Why it matters: Transistors are the building blocks of ALL computer chips! A modern CPU has billions of transistors!

🔌

Diode

What it does: يسمح بمرور التيار فقط في one direction — like a one-way street for electricity.
LED is a type of diode! (صمام ثنائي باعث للضوء)
Used for: Protecting circuits from reverse current, converting AC to DC power.

🎚️

مقياس جهد (مقاومة متغيرة)

What it does: مقاومة بمقبض يمكن تدويره لتغيير قيمة المقاومة.
Used for: Volume knobs, brightness dimmers, reading analog input on ESP32.
Has 3 pins: طرف، والمنزلق (في الوسط)، والطرف الآخر.

Component Directions

دون اتجاه محدد (وصّله بأي اتجاه): 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)

أحد 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.

→

📱 بعد الدوائر المتكاملة (اليوم)

شريحة واحدة بحجم thumbnail holds billions of transistors. Your phone is more powerful than early supercomputers!

Types of Chips

🧠 CPU (وحدة المعالجة المركزية) The "brain" — executes instructions. Found in your computer and phone.
💾 شرائح الذاكرة (RAM/Flash) Store data. RAM is temporary (lost when power off). Flash is permanent.
📡 شرائح الاتصال Handle Wi-Fi, Bluetooth, cellular. The ESP32 has these built in!
⚡ Microcontroller (MCU) حاسوب مصغر كامل على شريحة واحدة — CPU + ذاكرة + إدخال/إخراج. هذا هو ESP32!
Fun Fact

The first integrated circuit was invented in 1958 by Jack Kilby. It had just 1 ترانزستور. تضم شريحة M4 من Apple اليوم أكثر من 28 مليار ترانزستور! كأنك تنتقل من بيت واحد إلى مدينة أكبر من أي مدينة على الأرض.

🤖 10. المتحكم الدقيق مقابل المعالج الدقيق

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

Featureمعالج دقيقمتحكّم دقيق
What is it?Just a CPU (brain)CPU + Memory + I/O all in one!
هل يحتاج إضافات؟Yes — needs external RAM, storage, etc.لا — كل شيء مدمج!
الطاقةHigh power (watts)طاقة منخفضة (ميلي واط)
SpeedVery fast (GHz)متوسط (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، و built-in sensors. لهذا يحظى بهذه الشعبية — فهو نظام متكامل مقابل دولارات قليلة فقط!

📊 11. الإشارات الرقمية والتناظرية

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

Digital Signal

تشغيل إيقاف فقط تشغيل (1) أو إيقاف (0)

إشارة تماثلية

High منخفض Any value between Low and High
FeatureDigitalتماثلي
Valuesفقط 0 أو 1 (إيقاف أو تشغيل)Any value in a range (smooth)
مثل...مفتاح إضاءة (تشغيل/إيقاف)Dimmer knob (any brightness)
ESP32 readingdigitalRead() → 0 or 1analogRead() → 0 to 4095
ExamplesButton, switch, LED on/offTemperature, light level, sound
ADC — الجسر

The real world is analog (temperature changes smoothly), but computers think in digital (0s and 1s). The ADC (محوّل تماثلي إلى رقمي) built into the ESP32 converts analog signals to digital numbers so the chip can understand them!

🔢 12. النظام الثنائي والبتات — كيف تفكر الحواسيب

Computers don't understand letters or decimal numbers. They only understand two things: 0 and 1. ويُسمى هذا binary!

Why Binary?

Inside a computer, electricity is either flowing (1) أو not flowing (0). لا يوجد «تدفق جزئي». وهذا يجعل النظام الثنائي مثاليًا للإلكترونيات، فكل سلك إما في حالة تشغيل أو إيقاف!

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 رقم واحد: 0 أو 1. أصغر وحدة بيانات. يشبه مفتاح إضاءة واحدًا.
Byte 8 bits grouped together. Can represent 0–255 (256 values). Like 8 light switches.
Kilobyte (KB) 1024 بايت. ملف نصي قصير، مثل بضع فقرات.
ميغابايت (MB) 1024 KB. صورة أو أغنية قصيرة. ويضم ESP32 ذاكرة فلاش بسعة 4 MB!

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. لوحات التجارب — ساحتك للبناء

A breadboard lets you build circuits without soldering! ما عليك سوى إدخال الأسلاك والمكونات في الثقوب. يمكنك بسهولة إضافة الأجزاء وإزالتها وإعادة ترتيبها.

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
🔴🔵 خطوط الطاقة The long rows at top and bottom. Red (+) for power, Blue (–) for ground. All holes in each row are connected horizontally.
🟢 المنطقة الرئيسية 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. عدم توصيل مسارات الطاقة — لا تصلها الطاقة تلقائيًا. يجب مدّ أسلاك من المصدر إليها!

🔍 14. استخدام المقياس المتعدد

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 — التيار Set dial to A. Must be in SERIES with the circuit. Be careful!
Continuity Mode

تحتوي معظم أجهزة القياس المتعددة على continuity mode (يبدو رمزه كموجة صوتية). يصدر صوتًا عند وجود اتصال بين نقطتين. مفيد جدًا للتحقق من اتصال الأسلاك أو وجود عطل!

Safety

أبدًا 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. قواعد السلامة

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

1
لا تلمس أبدًا مقابس الكهرباء أو الجهد العالي. We only work with USB-powered circuits (5V or less). If you see exposed wires or damaged cables, tell an adult immediately.
2
افصل الطاقة دائمًا قبل تغيير دائرتك. 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. تأكّد من توصيل الموجب بالموجب والسالب بالسالب. عكس التوصيل قد يُتلف المكونات.
4
استخدم دائمًا مقاومات مع مصابيح LED. 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. أساسيات البرمجة

To tell the ESP32 what to do, you write code (تعليمات) بلغة برمجة تُسمّى C++ using the Arduino framework. Here are the key concepts:

What is a Program?

البرنامج هو 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

المتغير يشبه labeled box that holds a value. You give it a name and put something inside.

Variables int age = 12; // عدد صحيح float temperature = 23.5; // عدد عشري bool isOn = true; // true أو false String name = "Alin Li"; // نص
🔧

Functions — Reusable Blocks

الدالة هي named block of code that does a specific job. You can call it whenever you need it.

Functions // عرّف دالة void blinkLED() { digitalWrite(2, HIGH); // تشغيل delay(500); digitalWrite(2, LOW); // إيقاف التشغيل delay(500); } // استدعها متى شئت! blinkLED(); // أومض مرة واحدة blinkLED(); // أومض مجددًا
❓

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(«الجو حار!»); } else if (temperature > 20) { Serial.println(«الجو لطيف.»); } else { Serial.println(«الجو بارد!»); }
🔁

الحلقات — تكرار الأشياء

تتيح لك الحلقات repeat code without writing it over and over.

الحلقات // حلقة for: أومض 5 مرات لـ (int i = 0; i < 5; i++) { blinkLED(); // يعمل 5 مرات! } // حلقة while: استمر ما دام الزر مضغوطًا 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() { // يعمل مرة واحدة عند تشغيل اللوحة // اضبط الأطراف وابدأ الاتصال التسلسلي وهيّئ المكونات } void loop() { // يتكرر إلى الأبد // اقرأ المستشعرات واتخذ القرارات وتحكم في المخرجات }

🚀 17. أنت جاهز لـ ESP32!

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
🔋 الجهدThe push (measured in Volts)
🌊 CurrentThe flow (measured in Amps)
🚧 المقاومةThe slowdown (measured in Ohms)
📐 قانون أومV = I × R
🔄 الدوائرComplete loops for electricity
🧩 المكوّناتResistors, LEDs, capacitors...
🖥️ الشرائح والدوائر المتكاملةBillions of transistors in one package
🤖 المتحكّمات الدقيقةCPU + Memory + I/O = ESP32!
📊 الرقمي مقابل التناظري0/1 مقابل نطاقات متصلة
🔢 النظام الثنائيThe language of computers
💻 البرمجةVariables, functions, loops, conditions

الخطوة التالية: مستكشف Alin Li ESP32!

بعد إتقان الأساسيات، أنت مستعد لكتابة أول برنامج ESP32، وإضاءة LED، وقراءة المستشعرات، وبناء مشاريع مذهلة!

⚡🎉🚀