|

IoT 入门指南 IoT Beginner Guide

IoT Beginner Guide

从零开始你的物联网之旅 — 不需要任何编程或硬件经验

Start your IoT journey — no programming or hardware experience required

查看学习路线图 ↓ View learning roadmap ↓
Step 1

🌐 什么是物联网?

🌐 What is IoT?

物联网(Internet of Things, IoT)是指将日常设备连接到互联网,让它们能够收集和分享数据的技术。简单来说,就是让"东西"变得"智能"。

现实中的物联网

  • 智能家居 (Smart Home):用手机远程控制灯光、空调、门锁
  • 可穿戴设备 (Wearables):智能手表监测心率、步数、睡眠
  • 工业传感器 (Industrial Sensors):工厂设备实时监控温度、压力、振动
  • 智慧农业 (Smart Agriculture):土壤湿度传感器自动灌溉

关键术语 (Key Terms)

传感器 (Sensor) — 检测环境数据(温度、光线、运动)
执行器 (Actuator) — 执行动作(开关灯、转动电机)
网关 (Gateway) — 连接设备与互联网的中间设备
云端 (Cloud) — 存储和处理数据的远程服务器

The Internet of Things (IoT) is the practice of connecting everyday devices to the internet so they can collect and share data. In short — making "things" smart.

IoT in the real world

  • Smart Home — control lights, AC, and door locks from your phone
  • Wearables — smartwatches tracking heart rate, steps, and sleep
  • Industrial Sensors — factory equipment monitoring temperature, pressure, and vibration in real time
  • Smart Agriculture — soil moisture sensors triggering automatic irrigation

Key Terms

Sensor — detects environmental data (temperature, light, motion)
Actuator — performs physical actions (switches lights, turns motors)
Gateway — intermediate device connecting your hardware to the internet
Cloud — remote servers that store and process data
Step 2

🛒 你需要准备什么

🛒 What You Need

硬件清单 (Hardware List)

物品规格建议参考价格
ESP32 开发板ESP32-WROOM-32 或 ESP32-C3¥15-30
USB 数据线Micro-USB 或 USB-C(取决于开发板)¥5-10
面包板 (Breadboard)400孔或830孔¥5-8
杜邦线 (Jumper Wires)公对公、公对母各10根¥3-5
DHT22 温湿度传感器数字输出,精度±0.5°C¥8-15
LED + 电阻5mm LED + 220Ω电阻¥1-2

软件安装 (Software Setup)

  1. 安装 Arduino IDE — 从 arduino.cc 下载最新版
  2. 安装 ESP32 开发板支持 — 在 IDE 的 Board Manager 中搜索 ESP32 并安装
  3. 安装 USB 驱动 — 根据开发板芯片型号安装 CH340 或 CP2102 驱动
  4. 选择开发板和端口 — Tools → Board → ESP32 Dev Module

第一个程序:点亮 LED

连接 LED 到 GPIO 引脚,上传 Blink 示例代码(File → Examples → Basics → Blink),恭喜!你已经完成了第一个嵌入式程序。

关键术语 (Key Terms)

开发板 (Development Board) — 集成了微控制器的电路板,方便开发调试
烧录 (Flash/Upload) — 将程序写入微控制器的过程
串口 (Serial Port) — 电脑与开发板通信的接口
面包板 (Breadboard) — 无需焊接即可连接电子元件的实验板

Hardware list

ItemRecommended specPrice (¥, RMB)
ESP32 dev boardESP32-WROOM-32 or ESP32-C3¥15-30
USB cableMicro-USB or USB-C depending on the board¥5-10
Breadboard400 or 830 tie-points¥5-8
Jumper wires10 male-to-male + 10 male-to-female¥3-5
DHT22 temp/humidity sensorDigital output, ±0.5°C accuracy¥8-15
LED + resistor5mm LED + 220Ω resistor¥1-2

Software setup

  1. Install Arduino IDE — download the latest from arduino.cc
  2. Install ESP32 board support — search ESP32 in the IDE's Board Manager and install
  3. Install USB driver — CH340 or CP2102, depending on your board's chip
  4. Select board and port — Tools → Board → ESP32 Dev Module

Your first program: blink an LED

Wire an LED to a GPIO pin, upload the Blink example (File → Examples → Basics → Blink). Congratulations — you've just written your first embedded program.

Key Terms

Development Board — a PCB with a microcontroller, ready for development and debugging
Flash / Upload — the process of writing a program into the microcontroller
Serial Port — interface for communication between your computer and the board
Breadboard — a solderless prototyping board for connecting components
Step 3

💡 核心概念

💡 Core Concepts

传感器 (Sensors)

传感器是物联网的"感官",负责检测环境中的物理量并转换为电信号。

  • 温湿度传感器:DHT22、SHT30 — 测量温度和湿度
  • 光照传感器:BH1750 — 测量环境光强度(勒克斯 lux)
  • 距离传感器:HC-SR04 超声波 — 测量物体距离
  • 存在传感器:RCWL-0516 毫米波 — 检测人体存在

执行器 (Actuators)

执行器是物联网的"手脚",根据指令执行物理动作。

  • LED — 最简单的输出设备,指示状态
  • 继电器 (Relay) — 控制高电压设备(如电灯、风扇)
  • 电机 (Motor) — 伺服电机、步进电机、直流电机
  • 蜂鸣器 (Buzzer) — 发出声音提醒

微控制器基础 (MCU Basics)

GPIO — 通用输入输出引脚,可读取传感器或控制执行器
ADC — 模拟数字转换器,读取模拟传感器(如光敏电阻)
PWM — 脉宽调制,模拟输出(调节LED亮度、电机速度)
I2C / UART — 通信协议,连接传感器和模块

数据流 (Data Flow)

一个典型的物联网系统数据流:

📊 传感器采集 🔌 微控制器处理 📡 网络传输 ☁️ 云端存储 📱 手机/电脑查看

关键术语 (Key Terms)

数据采集 (Data Acquisition) — 从传感器读取数据的过程
数字引脚 (Digital Pin) — 只能读取/输出高低电平(0或1)
模拟引脚 (Analog Pin) — 可以读取连续变化的电压值
通信协议 (Communication Protocol) — 设备之间通信的规则和格式

Sensors

Sensors are the "senses" of an IoT system — they detect physical quantities and convert them into electrical signals.

  • Temperature / humidity — DHT22, SHT30 measure temperature and humidity
  • Light — BH1750 measures ambient light in lux
  • Distance — HC-SR04 ultrasonic sensor measures object distance
  • Presence — RCWL-0516 millimeter-wave radar detects human presence

Actuators

Actuators are the "hands and feet" of IoT — they perform physical actions on command.

  • LED — the simplest output, indicates status
  • Relay — switches high-voltage devices like lights and fans
  • Motor — servos, steppers, DC motors
  • Buzzer — audio alerts

MCU Basics

GPIO — general-purpose I/O pins; read sensors or drive actuators
ADC — analog-to-digital converter; reads analog sensors (e.g. light-dependent resistors)
PWM — pulse-width modulation; simulates analog output for LED brightness or motor speed
I2C / UART — communication protocols for connecting sensors and modules

Data Flow

A typical IoT system pipeline:

📊 Sensor acquisition 🔌 MCU processing 📡 Network transport ☁️ Cloud storage 📱 Phone / PC view

Key Terms

Data Acquisition — the process of reading data from sensors
Digital Pin — reads or outputs only HIGH or LOW (0 or 1)
Analog Pin — reads continuously varying voltage
Communication Protocol — rules and formats for device-to-device communication
Step 4

📡 通信协议入门

📡 Protocols 101

物联网设备需要通过网络通信。不同的场景需要不同的协议,就像不同的交通工具适合不同的距离。

短距离无线通信

协议范围功耗适用场景
WiFi~100m高带宽、持续供电设备
BLE~50m极低可穿戴、手机配对
Zigbee~100m智能家居 mesh 网络
Thread~100m新一代智能家居标准

长距离无线通信

协议范围功耗适用场景
LoRa~10km极低农业、环境监测
NB-IoT蜂窝覆盖城市基础设施、计量
4G Cat.1蜂窝覆盖移动设备、中等数据量

应用层协议

  • MQTT — 发布/订阅模式,轻量级,物联网首选。设备"发布"数据到"主题",其他设备"订阅"该主题即可接收
  • HTTP/REST — 你熟悉的网页协议,较重但通用性强

关键术语 (Key Terms)

发布/订阅 (Publish/Subscribe) — MQTT 的核心模式,解耦发送方和接收方
Mesh 网络 — 设备之间互相中继,扩大覆盖范围
Broker — MQTT 消息中转服务器
Topic — MQTT 消息的分类标签(如 home/living-room/temp)

IoT devices need to communicate over networks. Different scenarios call for different protocols — like choosing the right vehicle for different distances.

Short-range wireless

ProtocolRangePowerUse case
WiFi~100mHighHigh bandwidth, mains-powered devices
BLE~50mVery lowWearables, phone pairing
Zigbee~100mLowSmart home mesh networks
Thread~100mLowNext-gen smart home standard

Long-range wireless

ProtocolRangePowerUse case
LoRa~10kmVery lowAgriculture, environmental monitoring
NB-IoTCellularLowCity infrastructure, metering
4G Cat.1CellularMediumMobile devices, moderate data

Application-layer protocols

  • MQTT — publish/subscribe model, lightweight, IoT's top choice. Devices publish data to a topic; other devices subscribe to that topic to receive it.
  • HTTP/REST — the web protocol you already know; heavier but universally supported

Key Terms

Publish/Subscribe — MQTT's core pattern; decouples sender from receiver
Mesh network — devices relay messages to each other, extending coverage
Broker — MQTT message relay server
Topic — MQTT's message label (e.g. home/living-room/temp)
物联网

物联网中最常用的5大无线通信协议

今天我就和大家聊聊物联网领域目前使用最广泛的10大无线通信协议。 物联网的蓬勃发展让我们生活变得更便捷,但各种无线通信协议的出现也给产品选型带来不小困扰。下面我就按使用频率从高到低为大家详细介绍一下当前物联网领域最主要的10种无线通信技术。 1. 蓝牙/BLE 蓝牙是一种短距离、低功耗的无线连接技术,主要用于连接固定设备和移动设备。它的主要优势包括: -...

阅读全文 →
物联网

2026 MQTT物联网实战:ESP32数据采集+Node-RED可视化

从零搭建完整MQTT物联网监控系统:Mosquitto服务器部署与配置、ESP32传感器数据采集上报、Node-RED实时仪表盘可视化展示。附完整源码、接线图和常见故障排查方案,涵盖QoS设置、断线重连等实战技巧,适合物联网初学者和开发者参考。

阅读全文 →
物联网

2026 MQTT代理自建教程:Mosquitto服务器配置与优化

用Eclipse Mosquitto在Linux服务器上自建MQTT代理,数据完全掌控不依赖公共平台。涵盖Mosquitto安装部署、用户认证与ACL权限配置、TLS/SSL加密通信,以及连接数调优等性能优化技巧。适合物联网开发者搭建安全可靠的本地化消息中枢。

阅读全文 →
物联网

Zigbee 3.0 协议解析:低功耗 mesh 网络智能家居实战

深入讲解 Zigbee 3.0 协议原理,从零搭建低功耗 mesh 网络,实现智能家居设备互联互通,包含完整代码示例和故障排查指南。

阅读全文 →
嵌入式开发

LoRa SX1278 远距离组网实战:ESP32 无线通信模块教程 2026

在物联网项目里,WiFi 和蓝牙够用了——直到你需要覆盖几百米甚至几公里。 农场温湿度监控、园区安防、水库水位监测……这些场景里,WiFi 信号?不存在的。这时候 LoRa(Long Range)就派上用场了。 而 SX1278,是目前性价比最高的 LoRa 芯片之一。淘宝上 15 块钱就能买到一个模块,加上 ESP32 主控,就能搭建一个覆盖数公里的无线传感器网络。...

阅读全文 →
IoT

Top 5 Most Common Wireless Communication Protocols in IoT

Today I'll discuss the 10 most widely used wireless communication protocols in the IoT field. The rapid development of IoT has made our lives more convenient, but the emergence of various wireless communication protocols also brings considerable trouble to product selection. Below, I'll introduce in detail the 10 most important wireless communication technologies in the current IoT field, ranked by usage frequency from high to low. 1. Bluetooth/BLE Bluetooth is a short-distance, low-power wireless connection technology, mainly used to connect fixed devices and mobile devices. Its main advantages include: -...

阅读全文 →
IoT

2026 MQTT IoT Practice: ESP32 Data Collection + Node-RED Visualization

Build a complete MQTT IoT monitoring system from scratch: Mosquitto server deployment and configuration, ESP32 sensor data collection and reporting, Node-RED real-time dashboard visualization. Includes complete source code, wiring diagrams, and common troubleshooting solutions, covering QoS settings, auto-reconnection and other practical techniques, suitable for IoT beginners and developers.

阅读全文 →
IoT

2026 MQTT Broker Self-Hosting Tutorial: Mosquitto Server Configuration and Optimization

Self-host MQTT broker with Eclipse Mosquitto on Linux server, complete data control without relying on public platforms. Covers Mosquitto installation and deployment, user authentication and ACL permission configuration, TLS/SSL encrypted communication, and connection tuning performance optimization tips. Suitable for IoT developers to build secure and reliable localized message hub.

阅读全文 →
IoT

Zigbee 3.0 Protocol Analysis: Low-Power Mesh Network Smart Home Practice

In-depth guide on Zigbee 3.0 protocol principles, building low-power mesh networks from scratch, achieving smart home device interoperability, including complete code examples and troubleshooting guide.

阅读全文 →
Embedded Development

LoRa SX1278 Long-Range Networking Practice: ESP32 Wireless Communication Module Tutorial 2026

In IoT projects, WiFi and Bluetooth are sufficient - until you need to cover hundreds of meters or even several kilometers. Farm temperature/humidity monitoring, campus security, reservoir water level monitoring... in these scenarios, WiFi signal? Doesn't exist. This is when LoRa (Long Range) comes in handy. And SX1278 is currently one of the most cost-effective LoRa chips. You can buy a module for 15 yuan on Taobao, add an ESP32 main controller, and build a wireless sensor network covering several kilometers...

阅读全文 →
Step 5

🔧 第一个IoT项目

🔧 Your First IoT Project

🎯 项目目标:智能温湿度监控

读取 DHT22 传感器的温湿度数据,通过 WiFi 发送到 MQTT 服务器,在手机上实时查看。

步骤 1:连接硬件

将 DHT22 传感器连接到 ESP32:

  • DHT22 VCC → ESP32 3.3V
  • DHT22 GND → ESP32 GND
  • DHT22 DATA → ESP32 GPIO 4(加 10kΩ 上拉电阻)

步骤 2:读取传感器数据

使用 Arduino DHT 库读取温湿度值。安装库:Sketch → Include Library → Manage Libraries → 搜索 "DHT sensor library"。

步骤 3:连接 WiFi

使用 ESP32 内置的 WiFi 库连接到你的家庭网络。将 WiFi 名称和密码写入代码。

步骤 4:发送 MQTT 数据

使用 PubSubClient 库连接 MQTT Broker,将温湿度数据发布到 home/living-room/temphome/living-room/humidity 主题。

步骤 5:查看数据

在手机上安装 MQTT Dashboard 应用(如 IoT MQTT Panel),订阅相同主题,即可实时查看数据。

常见问题 (Troubleshooting)

  • 传感器读数为 NaN — 检查接线,确认上拉电阻已连接
  • WiFi 连接失败 — 确认密码正确,ESP32 仅支持 2.4GHz WiFi
  • MQTT 连接超时 — 检查 Broker 地址和端口(默认 1883)

关键术语 (Key Terms)

数据采集 (Data Acquisition) — 从传感器读取并记录数据
仪表盘 (Dashboard) — 可视化展示数据的界面
发布/订阅 (Publish/Subscribe) — MQTT 通信模式
上拉电阻 (Pull-up Resistor) — 确保信号线默认为高电平

🎯 Project goal: smart temperature & humidity monitor

Read temperature and humidity from a DHT22, send it over WiFi to an MQTT server, and view it live on your phone.

Step 1: wire the hardware

Connect the DHT22 to the ESP32:

  • DHT22 VCC → ESP32 3.3V
  • DHT22 GND → ESP32 GND
  • DHT22 DATA → ESP32 GPIO 4 (with a 10kΩ pull-up resistor)

Step 2: read sensor data

Use the Arduino DHT library to read temperature and humidity. Install it: Sketch → Include Library → Manage Libraries → search for "DHT sensor library".

Step 3: connect to WiFi

Use the ESP32's built-in WiFi library to connect to your home network. Put your WiFi SSID and password in the code.

Step 4: publish MQTT data

Use the PubSubClient library to connect to the MQTT broker and publish temperature and humidity to the topics home/living-room/temp and home/living-room/humidity.

Step 5: view the data

Install an MQTT Dashboard app on your phone (e.g. IoT MQTT Panel), subscribe to the same topics, and watch the data stream in.

Troubleshooting

  • Sensor reads NaN — check wiring; confirm the pull-up resistor is connected
  • WiFi won't connect — verify the password; ESP32 only supports 2.4GHz WiFi
  • MQTT connection times out — check the broker address and port (default 1883)

Key Terms

Data Acquisition — reading and logging data from sensors
Dashboard — a visual interface for displaying data
Publish / Subscribe — MQTT's communication pattern
Pull-up Resistor — keeps the signal line at HIGH by default
Step 6

🚀 下一步去哪

🚀 What's Next

恭喜你!你已经完成了 IoT 入门的基础知识,并成功构建了第一个物联网项目。接下来,你可以探索以下进阶方向:

进阶方向

  • 边缘 AI (Edge AI / TinyML) — 在微控制器上运行机器学习模型,实现本地智能决策
  • 智能家居 (Smart Home) — 使用 Matter 协议构建跨品牌智能家居系统
  • 工业物联网 (Industrial IoT) — Modbus、CAN 总线等工业通信协议
  • 低功耗设计 — 电池供电设备的深度睡眠和能耗优化
  • PCB 设计 — 从面包板原型到定制电路板

🎉 You're now an IoT maker!

继续探索 237 篇教程,从入门到精通。

返回首页 → Back to homepage →

Congratulations — you've covered the fundamentals of IoT and built your first IoT project. Here are some advanced directions to explore next:

Advanced paths

  • Edge AI / TinyML — run machine learning models on microcontrollers for local intelligence
  • Smart Home — build cross-brand smart home systems with the Matter protocol
  • Industrial IoT — Modbus, CAN bus, and other industrial protocols
  • Low-power design — deep sleep and energy optimization for battery-powered devices
  • PCB design — go from breadboard prototypes to custom circuit boards

🎉 You're now an IoT maker!

浏览 237 篇教程,涵盖 ESP32、物联网、嵌入式开发等领域

返回首页 → Back to homepage →
Embedded Development

Getting Started with Edge AI on ESP32-S3: A Hands-On TinyML Image Recognition Tutorial

A step-by-step guide to running a TinyML image classification model on ESP32-S3 + OV2640 camera — recognize faces, cats, dogs, and objects entirely offline. Perfect for embedded developers diving into edge AI.

阅读全文 →
物联网

ESP32-C6 in Practice: Building a Smart Home Node with WiFi 6 + Matter Dual Protocol

Build a smart home node powered by ESP32-C6 that supports both WiFi 6 and Matter protocols, enabling cross-brand device interoperability. A complete hands-on guide covering hardware selection, firmware compilation, and HomeKit integration.

阅读全文 →
Development Environment

2026 DIY Smart Doorbell: Face Recognition + WeChat Push (Cost <¥300)

DIY a smart doorbell with Raspberry Pi + camera module, integrating AI face recognition and WeChat message push functionality. Total cost under 300 yuan, can automatically identify family members, alert in real-time when strangers ring, and notify instantly when deliveries arrive. Includes complete hardware list, Python code, and WeChat ServerChan push configuration tutorial, a security project that can be completed over a weekend.

阅读全文 →
嵌入式开发

TinyML Anomaly Detection: Edge-Based Predictive Maintenance for Industrial Equipment

Run an anomaly detection model on an MCU using Arduino Nano 33 BLE Sense + Edge Impulse to detect motor, pump, and fan faults early, achieving low-latency predictive maintenance.

阅读全文 →