Everything You Need to Know Before ESP32
للأعمار 9–14 | لا خبرة مطلوبةEverything in the universe — your desk, your body, the air you breathe — is made of tiny particles called atoms. الذرات صغيرة جدًا، حتى إن الملايين منها تتسع على رأس إبرة!
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.
Voltage is the force that pushes electrons through a wire. It's measured in Volts (V)، نسبةً إلى العالم Alessandro Volta.
Voltage is like water pressure. يدفع برج المياه المرتفع الماء عبر الأنابيب بقوة أكبر من البرج القصير.
A 9V battery pushes electrons harder than a بطارية 1.5V. جهد أكبر = دفع أقوى!
| Source | Voltage | Safe? | Used For |
|---|---|---|---|
| بطارية AA | 1.5V | ✅ Very safe | Toys, remotes |
| USB Port | 5V | ✅ Safe | Charging phones, Arduino |
| 9V Battery | 9V | ✅ Safe | Smoke detectors, guitars |
| Car Battery | 12V | ⚠️ Careful | Cars, some electronics |
| Wall Outlet (US) | 120V | ❌ Dangerous! | Home appliances |
| Wall Outlet (EU/ME) | 220–240V | ❌ Very dangerous! | Home appliances |
| خطوط الطاقة | 10,000V+ | ☠️ Deadly! | Electricity distribution |
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!
Voltage is always measured between two points. لهذا تحتوي البطاريات على + (موجب) and a – (negative) side. The difference between them is the voltage.
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.
يستهلك مصباح LED نحو 20mA (تدفّق ضئيل). يستخدم فرن الميكروويف نحو 10A (تدفق ضخم!).
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?
Resistance is anything that slows down the flow of electrons. It's measured in أوم (Ω)، نسبةً إلى Georg Ohm.
Resistance is like the width of a pipe. يسمح الأنبوب الضيق بمرور ماء أقل. وتكون مقاومة الأنبوب المسدود عالية جدًا.
A resistor limits how much current flows. A 1kΩ resistor limits more than a 100Ω resistor.
Without resistance, too much current would flow and burn out your components! Resistors are like bodyguards that protect your LEDs and chips.
Resistors have colored stripes that tell you their value. You'll learn to read these as you work with circuits!
| Color | Digit | حيلة للتذكّر |
|---|---|---|
| ⬛ Black | 0 | Blackout = zero |
| 🟫 بني | 1 | 1 دب بني |
| 🔴 أحمر | 2 | 2 عينان حمراوان |
| 🟠 برتقالي | 3 | 3 برتقالات |
| 🟡 أصفر | 4 | برسيم أصفر ذو 4 أوراق |
| 🟢 أخضر | 5 | 5 green fingers |
| 🔵 أزرق | 6 | 6-sided blue dice |
| 🟣 بنفسجي | 7 | 7 violet flowers |
| ⬜ Gray | 8 | 8 gray rocks |
| ⬜ White | 9 | 9 white clouds |
This one formula connects voltage, current، و resistance together. It's the most important formula in electronics!
بطارية 9V موصولة بمقاومة 1000Ω (1kΩ). ما شدة التيار المار؟
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!
1. مصدر الطاقة (بطارية، USB) — يوفّر الدفع.
2. موصل (سلك) — المسار الذي تسلكه الإلكترونات.
3. الحمل (LED، محرّك، طنّان) — يستهلك الكهرباء.
4. حلقة كاملة — back to the power source. If any part breaks, the circuit is "open" and nothing works!
A switch (مثل مفتاح الإضاءة على الجدار) يقطع الدارة أو يغلقها ببساطة. عند تشغيله، تكون الدارة مغلقة (مكتملة). وعند إيقافه، تكون الدارة مفتوحة (مقطوعة). هذا كل ما يفعله المفتاح!
There are two main ways to connect components in a circuit. This is super important to understand!
| Feature | Series | على التوازي |
|---|---|---|
| المسار | مسار واحد فقط | مسارات متعددة (فروع) |
| Current | Same everywhere | Splits between branches |
| Voltage | Splits between components | Same across all branches |
| If one breaks? | تتوقف كلها عن العمل | تستمر المكونات الأخرى في العمل |
| Real example | أضواء عيد الميلاد القديمة | Your house wiring! |
كانت أضواء عيد الميلاد القديمة تُوصَّل على 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.
These are the basic building blocks you'll use in your circuits. Get to know them — they'll be your best friends!
What it does: يحدّ من تدفق التيار. يحمي المكونات الأخرى من الطاقة الزائدة.
Unit: أوم (Ω). قيم شائعة: 220Ω و1kΩ و10kΩ
Tip: Has no direction — you can connect it either way!
What it does: يضيء عندما يمر فيه التيار.
Important: Has a direction! Long leg = positive (+), Short leg = negative (–)
الاحتياجات: استخدمه دائمًا مع مقاومة (عادةً 220Ω)، وإلا فسيحترق!
Colors: Red, green, blue, yellow, white — depends on materials inside.
What it does: يفتح الدائرة أو يغلقها عند الضغط عليه.
Types: لحظي (يعمل أثناء الضغط فقط) مقابل تبديل (يبقى مشغّلًا/مطفأً)
In ESP32: Used as digital input — the microcontroller reads if it's pressed!
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!)
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!
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: طرف، والمنزلق (في الوسط)، والطرف الآخر.
دون اتجاه محدد (وصّله بأي اتجاه): Resistors, push buttons, potentiometers
Has direction (connect correctly!): LEDs (long leg = +), electrolytic capacitors (marked + side), diodes (stripe = negative side), transistors (check datasheet)
أحد 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!
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!
The first integrated circuit was invented in 1958 by Jack Kilby. It had just 1 ترانزستور. تضم شريحة M4 من Apple اليوم أكثر من 28 مليار ترانزستور! كأنك تنتقل من بيت واحد إلى مدينة أكبر من أي مدينة على الأرض.
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) | طاقة منخفضة (ميلي واط) |
| Speed | Very fast (GHz) | متوسط (MHz) |
| Cost | $50 – $1000+ | $1 – $20 |
| Good at | Complex tasks (running OS, games, browsers) | Specific tasks (read sensor, blink LED, control motor) |
| Examples | Intel Core, AMD Ryzen, Apple M4 | ESP32, Arduino, STM32, Raspberry Pi Pico |
| Found in | Laptops, desktops, servers | Washing machines, cars, toys, IoT devices |
It has everything on one chip: a dual-core CPU, RAM, Flash memory, Wi-Fi, Bluetooth, GPIO pins، و built-in sensors. لهذا يحظى بهذه الشعبية — فهو نظام متكامل مقابل دولارات قليلة فقط!
In electronics, signals come in two types. Understanding this is essential for working with sensors!
| Feature | Digital | تماثلي |
|---|---|---|
| Values | فقط 0 أو 1 (إيقاف أو تشغيل) | Any value in a range (smooth) |
| مثل... | مفتاح إضاءة (تشغيل/إيقاف) | Dimmer knob (any brightness) |
| ESP32 reading | digitalRead() → 0 or 1 | analogRead() → 0 to 4095 |
| Examples | Button, switch, LED on/off | Temperature, light level, sound |
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!
Computers don't understand letters or decimal numbers. They only understand two things: 0 and 1. ويُسمى هذا binary!
Inside a computer, electricity is either flowing (1) أو not flowing (0). لا يوجد «تدفق جزئي». وهذا يجعل النظام الثنائي مثاليًا للإلكترونيات، فكل سلك إما في حالة تشغيل أو إيقاف!
Each position in binary is worth double the previous one (just like decimal positions are worth 10× more):
128 + 0 + 32 + 0 + 8 + 4 + 0 + 1 = 173
What is the binary number 1010 in decimal?
A breadboard lets you build circuits without soldering! ما عليك سوى إدخال الأسلاك والمكونات في الثقوب. يمكنك بسهولة إضافة الأجزاء وإزالتها وإعادة ترتيبها.
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. عدم توصيل مسارات الطاقة — لا تصلها الطاقة تلقائيًا. يجب مدّ أسلاك من المصدر إليها!
A multimeter is your detective tool — it measures voltage, current, and resistance. Every electronics maker needs one!
تحتوي معظم أجهزة القياس المتعددة على continuity mode (يبدو رمزه كموجة صوتية). يصدر صوتًا عند وجود اتصال بين نقطتين. مفيد جدًا للتحقق من اتصال الأسلاك أو وجود عطل!
أبدًا 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.
Electronics is fun and safe when you follow the rules! These aren't just suggestions — they're essential.
To tell the ESP32 what to do, you write code (تعليمات) بلغة برمجة تُسمّى C++ using the Arduino framework. Here are the key concepts:
البرنامج هو 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...
المتغير يشبه labeled box that holds a value. You give it a name and put something inside.
الدالة هي named block of code that does a specific job. You can call it whenever you need it.
Use if/else to make the program choose what to do based on conditions.
تتيح لك الحلقات repeat code without writing it over and over.
Every Arduino/ESP32 program has exactly two required functions:
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:
الخطوة التالية: مستكشف Alin Li ESP32!
بعد إتقان الأساسيات، أنت مستعد لكتابة أول برنامج ESP32، وإضاءة LED، وقراءة المستشعرات، وبناء مشاريع مذهلة!
⚡🎉🚀