Internet of ThingsUnit 412 min read
IoT Hardware Platforms: Arduino vs. Raspberry Pi – Architecture, Use Cases & Comparisons
Unit 4 of Internet of Things explores the two foundational hardware platforms—Arduino and Raspberry Pi—that power IoT devices, covering their architectures, programming models, real-world applications, and trade-offs in performance, cost, and scalability.
TAKEAWAYS:
- Arduino and Raspberry Pi serve distinct IoT roles: Arduino excels in low-cost, low-power sensor/actuator control, while Raspberry Pi handles complex processing and cloud connectivity.
- Arduino’s simplicity (C/C++ on AVR/ARM) and Pi’s Linux-based flexibility (Python/C++) reflect their target use cases: embedded vs. general-purpose computing.
- Both platforms integrate with IoT ecosystems via libraries (e.g., Arduino’s
WiFiNINA, Pi’sMQTT), but Pi supports advanced analytics and edge computing. - Real-world examples show Arduino in smart agriculture (soil moisture sensors) and Pi in traffic management (NTC’s smart signal systems).
- Hardware limitations (e.g., Pi’s GPIO vs. Arduino’s analog pins) dictate sensor/actuator choices and system scalability.
- Security and firmware updates are critical for both, but Pi’s OS-level updates enable patching vulnerabilities in cloud-connected IoT deployments.
1. Introduction: Why Hardware Matters in IoT
IoT devices are the physical interface between the digital and real worlds. Their hardware determines:
- Data collection (sensors/actuators),
- Processing power (local vs. cloud),
- Connectivity (Wi-Fi, Bluetooth, LoRa),
- Power efficiency (battery vs. mains).
Arduino and Raspberry Pi are the two most widely used platforms for prototyping and deploying IoT systems. While Arduino dominates embedded control, Raspberry Pi excels in edge computing and cloud integration.
2. Arduino: The Embedded Workhorse
2.1 Architecture and Components
Arduino boards are microcontroller-based, meaning they run a single program (firmware) with limited OS features. Key components:
- Microcontroller (MCU): AVR (e.g., ATmega328P) or ARM (e.g., SAMD21).
- Peripherals: Digital/analog I/O pins, UART, SPI, I2C, PWM.
- Bootloader: Enables easy firmware updates via USB.
- Power: 5V or 3.3V, often battery-powered.
2.2 Programming Model
- Language: C/C++ (Arduino IDE or PlatformIO).
- Execution: Loop-based (
setup()→loop()). - Libraries: Simplify hardware access (e.g.,
WiFiNINAfor ESP8266/Arduino Wi-Fi).
Worked Example: Soil Moisture Sensor for Smart Agriculture
#include <SPI.h>
#include <WiFiNINA.h>
int moisturePin = A0;
char ssid[] = "FarmWiFi";
char pass[] = "agri123";
void setup() {
Serial.begin(9600);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) delay(500);
}
void loop() {
int moisture = analogRead(moisturePin);
if (moisture < 300) { // Dry soil
Serial.println("Water needed!");
// Trigger relay to open valve (via GPIO)
}
delay(60000); // Check every minute
}
Real-World Tie-In: Nepalese farmers use Arduino-based systems (e.g., FarmBot Nepal) to monitor soil moisture and automate irrigation, reducing water waste by 30% in pilot projects.
2.3 Advantages and Limitations
| Pros | Cons |
|---|---|
| Low cost ($5–$30) | Limited processing power |
| Ultra-low power consumption | No OS (no multitasking) |
| Simple to program (IDE-friendly) | Limited storage (32KB flash) |
| Wide sensor/actuator support | No built-in Wi-Fi (needs shields) |
Labeled pins (D0-D13, A0-A5, power, ICSP) (Image: bq, CC BY-SA 4.0, via Wikimedia Commons)
3. Raspberry Pi: The Edge Computing Hub
3.1 Architecture and Components
Raspberry Pi is a single-board computer (SBC) running Linux, designed for full-fledged applications:
- CPU: Quad-core ARM (e.g., Pi 4’s Cortex-A72 @1.5GHz).
- RAM: 1–8GB (vs. Arduino’s KB-scale SRAM).
- OS: Raspberry Pi OS (Linux-based), supports Python/C++/Node.js.
- Connectivity: Built-in Wi-Fi, Bluetooth, Ethernet, USB, HDMI.
3.2 Programming Model
- Languages: Python (most common), C++, Node.js.
- Libraries:
RPi.GPIO,pigpio,MQTT(for cloud communication). - Example: Reading a temperature sensor and publishing to AWS IoT:
import Adafruit_DHT import paho.mqtt.client as mqtt def on_connect(client, userdata, flags, rc): client.subscribe("iot/sensor/temp") client = mqtt.Client() client.on_connect = on_connect client.connect("broker.hivemq.com", 1883) while True: humidity, temperature = Adafruit_DHT.read_retry(11, 4) client.publish("iot/sensor/temp", f"{temperature:.1f}") time.sleep(60)
3.3 Advantages and Limitations
| Pros | Cons |
|---|---|
| Full Linux OS (multitasking) | Higher power consumption |
| Built-in Wi-Fi/Ethernet | Bulkier ($35–$75) |
| Supports advanced analytics | Overkill for simple sensors |
| Cloud integration (MQTT, HTTP) | Requires cooling in enclosed cases |
4. Head-to-Head Comparison
| Feature | Arduino | Raspberry Pi |
|---|---|---|
| Type | Microcontroller | Single-board computer |
| OS | None (firmware) | Linux (Raspberry Pi OS) |
| Programming | C/C++ (Arduino IDE) | Python/C++/Node.js |
| Processing Power | 8–16MHz (AVR) / 48MHz (ARM) | 1.5GHz quad-core |
| RAM | 2–8KB | 1–8GB |
| Storage | 32KB–2MB flash | MicroSD (16GB–128GB) |
| Connectivity | Wi-Fi via shields | Built-in Wi-Fi/Ethernet/USB |
| Power | 5V/3.3V (battery-friendly) | 5V (higher consumption) |
| Cost | $5–$30 | $35–$75 |
| Best For | Sensor nodes, actuators, low-power | Edge analytics, cloud gateways |
5. Real-World Applications
5.1 Arduino in Action
Smart Traffic Lights (NTC Pilot Project): Arduino Uno + ultrasonic sensors detect vehicle queues and adjust signal timings dynamically. Result: 20% reduction in Kathmandu traffic congestion at test intersections.
sequenceDiagram participant Sensor as Ultrasonic Sensor participant Arduino as Arduino Uno participant Cloud as NTC Server Sensor->>Arduino: Detects queue length Arduino->>Arduino: Adjusts GPIO (relay) Arduino->>Cloud: Sends data (MQTT) Cloud->>Arduino: Updates timing rulesKhalti’s Microtransaction Verification: Arduino-based hardware security modules (HSMs) validate low-value transactions (e.g., bus tickets) offline to reduce fraud.
5.2 Raspberry Pi in Action
- eSewa’s Smart Metering: Pi 4 + LoRa modules read electricity meters in rural areas and sync data to eSewa’s cloud via NB-IoT. Impact: 40% faster billing in Chitwan.
- Pathao’s Last-Mile Delivery Tracking: Pi Zero W + GPS modules track delivery vans in real-time, optimizing routes and reducing fuel costs by 15%.
6. Choosing the Right Platform
Use this decision tree for IoT projects:
flowchart TD
A["Need IoT Hardware?"] --> B{"Is it sensor/actuator control?"}
B -->|"Yes"| C{"Low power required?"}
C -->|"Yes"| D["Arduino + Battery"]
C -->|"No"| E["Arduino Uno/Nano"]
B -->|"No"| F{"Need cloud/analytics?"}
F -->|"Yes"| G["Raspberry Pi 4/Zero W"]
F -->|"No"| H["Arduino Mega/ESP32"]Example Scenarios:
- Smart Home Security: Arduino (motion sensors + Pi for video analytics).
- Industrial Monitoring: Pi (edge processing of vibration sensors).
- Wearable Health Device: Arduino (low power, Bluetooth LE).
7. Integration with IoT Ecosystems
Both platforms connect to cloud services via:
- Protocols: MQTT (lightweight), HTTP (REST APIs), CoAP (constrained devices).
- Services:
- AWS IoT Core (for Pi/Arduino with Wi-Fi).
- Google Cloud IoT (supports MQTT/HTTP).
- Local Brokers (Mosquitto on Pi for offline-first systems).
Example: MQTT Handshake
sequenceDiagram
participant Arduino as Arduino Uno
participant Broker as Mosquitto MQTT
participant Cloud as AWS IoT
Arduino->>Broker: CONNECT (ClientID: "soil_sensor")
Broker-->>Arduino: CONNACK (0 = Success)
Arduino->>Broker: PUBLISH (Topic: "farm/soil", Payload: "30%")
Broker->>Cloud: Forward to AWS8. Challenges and Best Practices
8.1 Common Pitfalls
- Power Management: Arduino drains batteries quickly if not optimized (use
LowPowerlibraries). - Network Reliability: Pi’s Wi-Fi may drop in noisy environments (use Ethernet or LoRa).
- Security: Default credentials on Pi/Arduino are vulnerable (always update firmware).
8.2 Best Practices
- Arduino:
- Use deep sleep modes for battery life.
- Isolate power supplies for noisy sensors.
- Raspberry Pi:
- Enable SSH headless setup for remote access.
- Use
systemdservices for persistent MQTT clients.
- Both:
- Over-the-air (OTA) updates via
arduinoOTAorrpi-update. - Log data locally (SD card) before cloud upload.
- Over-the-air (OTA) updates via
## In the Real World
eSewa’s Smart Meters:
- Platform: Raspberry Pi 4 + LoRa.
- Idea Used: Edge computing to pre-process meter data before sending to the cloud, reducing bandwidth costs by 60%.
- Impact: Enables real-time billing for 500,000+ users in Nepal.
Khalti’s Microtransaction HSMs:
- Platform: Arduino Mega + secure element.
- Idea Used: Offline transaction validation to prevent fraud in low-connectivity areas (e.g., rural bus stops).
- Result: 95% fraud reduction in test regions.
NTC’s Smart Traffic Lights:
- Platform: Arduino Uno + ultrasonic sensors.
- Idea Used: Real-time queue detection to dynamically adjust signal timings.
- Data: Reduced average wait time by 25% in Pokhara’s busy intersections.
Pathao’s Delivery Optimization:
- Platform: Raspberry Pi Zero W + GPS.
- Idea Used: Edge-based route recalculation using local traffic data (not just Google Maps).
- Outcome: 12% faster deliveries in Kathmandu’s chaotic traffic.
Nepal Electricity Authority’s Grid Monitoring:
- Platform: Raspberry Pi Cluster + IoT sensors.
- Idea Used: Distributed edge nodes to monitor power lines in remote areas (e.g., Mustang) where cloud connectivity is unreliable.
## Exam Tip
This unit is heavily tested on:
- Comparisons: Always use the table format for Arduino vs. Pi (marks are awarded for clarity and completeness).
- Worked Examples: Show code snippets (even pseudocode) for sensor/actuator integration. Examiners love seeing
setup()/loop()or Pythonwhileloops. - Real-World Applications: Tie answers to Nepalese contexts (e.g., NTC traffic, eSewa meters, Khalti transactions). Use one concrete example per question.
- Diagrams: Draw sequence diagrams for protocol exchanges (MQTT, HTTP) and block diagrams for hardware setups.
- Shortcomings: Never ignore limitations! Mention power, processing, or connectivity trade-offs in every answer.
Common Exam Traps:
- Arduino vs. Pi: Don’t confuse them as interchangeable. Pi can’t replace Arduino for battery-powered sensors, and vice versa.
- Protocols: MQTT is for IoT; HTTP is for web APIs. Always specify which to use.
- Security: Assume IoT devices are hackable unless secured. Mention firmware updates and encryption.
Based on the TU BCA syllabus for Internet of Things (CACS460), unit 4.
Discussion
Loading…