IoT Raspberry Pi Basics
Raspberry Pi is a credit-card-sized computer that runs a full operating system. Unlike a microcontroller, it handles web servers, databases, cameras, and even simple AI models. Makers and engineers use it as a smart hub for IoT projects.
Raspberry Pi vs a Microcontroller
| Feature | Raspberry Pi | Arduino-class Board |
|---|---|---|
| Type | Single-board computer | Microcontroller |
| Operating system | Linux (Raspberry Pi OS) | None |
| Power use | Moderate | Very low |
| Best job | Gateway, camera, local server | Sensor reading, simple control |
| Languages | Python, C, JavaScript, more | C and C++ |
A simple comparison helps: the microcontroller acts like a calculator that does one task perfectly, and the Raspberry Pi acts like a small laptop that juggles many tasks.
Board Anatomy
┌──────────────────────────────────────────┐ │ GPIO header (40 pins) ░░░░░░░░░░░░░░░░░░ │ │ │ │ [CPU + RAM] [Wi-Fi + Bluetooth] │ │ │ │ USB ports Ethernet HDMI Power │ │ microSD card slot (holds the OS) │ └──────────────────────────────────────────┘
Important Parts
- GPIO pins: General-purpose pins that connect sensors, LEDs, and relays.
- microSD slot: Stores the operating system and your files.
- Wireless chip: Adds Wi-Fi and Bluetooth on most models.
- USB and HDMI: Attach keyboards, cameras, and screens.
Getting Started
- Write Raspberry Pi OS onto a microSD card with the official imager tool.
- Insert the card, connect power, and let the board start.
- Join your Wi-Fi network and change the default password.
- Open a terminal and update the software.
A Tiny Python Example
from gpiozero import LED
from time import sleep
led = LED(17)
while True:
led.on()
sleep(1)
led.off()
sleep(1)The script blinks an LED connected to GPIO pin 17. The gpiozero library hides the low-level details and keeps the code readable.
Common IoT Roles
Home Gateway
The Pi collects data from many sensors in the house and forwards it to the cloud.
Local Dashboard Server
The Pi hosts a small web page that shows live readings inside the local network.
Smart Camera
A camera module plus motion detection software turns the Pi into a budget monitoring device.
Sample Architecture
[Temp sensor]──┐
[Door sensor]──┼──► [Raspberry Pi gateway] ──► Internet ──► [Cloud dashboard]
[Light sensor]─┘ │
└──► Local web page
Safety and Care Tips
- Check the voltage rating of each sensor before connecting it to GPIO. Pins accept 3.3 volts, not 5 volts.
- Use a quality power supply to avoid random restarts.
- Shut down the system properly before removing power to protect the memory card.
- Keep the operating system updated.
Choosing a Model
Full-size models suit gateways and cameras. The compact Zero series fits wearable and tight-space builds. The Pico family offers microcontroller-style boards from the same maker for very low power tasks.
Reading a Sensor with Python
Many sensors speak digital languages such as I2C. A single library hides the details, and a few lines fetch the data. The sketch below shows the typical pattern with a temperature module, using a made-up library name for clarity.
from time import sleep
import sensor_library
probe = sensor_library.Temperature()
while True:
print("Temperature:", probe.read(), "C")
sleep(5)The program prints a reading every five seconds. Add a few lines that publish the value to an MQTT broker, and the Pi becomes a complete IoT node that feeds a cloud dashboard.
When to Pick a Pi
- The project needs a camera or a local web page.
- Several sensors feed one hub.
- The code uses large libraries for data analysis.
Choose a microcontroller instead when the project needs a battery life of months and only reads a single sensor.
Key Takeaway
Raspberry Pi connects the tiny world of sensors with the big world of networks and software. Pair it with microcontrollers, and you can build layered projects that read, store, display, and act on data without renting any outside equipment.
