Hardware + Software
IoT connects physical devices to the internet and cloud.
Typical components
| Component | Function |
|---|---|
| Microcontroller | Arduino, ESP32 |
| Sensors | Temperature, motion |
| Actuators | LEDs, motors, relays |
| Communication | WiFi, MQTT, HTTP |
Basic Arduino
// Blink LED
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
}
MQTT
Lightweight protocol for IoT:
Sensor โ MQTT Broker โ Your server
โ
Dashboard
ESP32 + MQTT
#include <WiFi.h>
#include <PubSubClient.h>
WiFiClient espClient;
PubSubClient client(espClient);
void setup() {
WiFi.begin("SSID", "password");
client.setServer("broker.hivemq.com", 1883);
}
void loop() {
float temp = readTemperature();
client.publish("home/temperature", String(temp).c_str());
delay(5000);
}
Cloud services
| Service | Use |
|---|---|
| AWS IoT | Enterprise |
| HiveMQ | Free MQTT |
| Adafruit IO | Hobby |
Practice
โ Arduino + MQTT