13  Hardware Components and Tools

13.1 Learning Objectives

By the end of this chapter, you will be able to:

  • Select appropriate sensors for different measurement requirements based on accuracy, interface, and power
  • Choose actuators for motion, switching, and output applications matching drive requirements
  • Compare communication module options (Wi-Fi, BLE, LoRa, cellular) for different connectivity scenarios
  • Design power subsystems with proper regulators, battery management, and level conversion
  • Assemble a prototyping workstation with essential measurement and soldering tools

Key Concepts

  • Passive Component: Electronic component (resistor, capacitor, inductor) that does not require a power source to operate.
  • Active Component: Electronic component (transistor, IC, LED driver) that requires power and can amplify or switch signals.
  • Decoupling Capacitor: Small capacitor placed near IC power pins to suppress high-frequency switching noise on the supply rail.
  • Pull-up Resistor: Resistor connecting an I/O line to VCC to define a default high state when no driver is asserting the line.
  • ESD Protection Diode: Clamping diode protecting IC pins from electrostatic discharge during handling or in-field use.
  • Voltage Regulator: IC maintaining a stable output voltage despite varying input voltage and load current.
  • Crystal Oscillator: Precision frequency reference providing the clock source for microcontrollers requiring accurate timing.

Prototyping is building rough, working versions of your IoT device to test ideas quickly and cheaply. Think of it like building a model airplane before constructing the real thing – a prototype reveals problems when they are still easy and inexpensive to fix. Modern prototyping tools make it possible to go from idea to working device in days rather than months.

“Building a prototype is like assembling a puzzle,” said Sammy the Sensor. “You need the right pieces! There are environmental sensors (temperature, humidity, pressure), motion sensors (accelerometers, gyroscopes), proximity sensors, light sensors, and many more. Each one has specific pins, voltages, and communication interfaces.”

Max the Microcontroller listed essential tools: “A breadboard for connecting components without soldering. Jumper wires for making connections. A multimeter for measuring voltage and checking circuits. And a USB cable for programming and power. With just these tools, you can build hundreds of projects!”

Lila the LED added, “Do not forget output components! LEDs for visual feedback, buzzers for audio alerts, displays for showing data, and motors for physical movement. A good prototype combines input sensors, processing by Max, and output so humans can see what is happening.” Bella the Battery reminded everyone, “Always check the voltage requirements. Mixing 3.3-volt and 5-volt components without proper level shifting is the fastest way to destroy a sensor!”

13.2 Sensors

13.2.1 Environmental Sensors

Type Common Options Interface Use Cases
Temperature DS18B20, DHT22, BME280 OneWire, Digital, I2C Weather stations, HVAC
Humidity DHT11/DHT22, BME280, SHT3x Digital, I2C Agriculture, indoor air
Pressure BMP280, BME680 I2C, SPI Weather, altitude
Air Quality MQ-series, CCS811, PMS5003 Analog, I2C Indoor air monitoring
Light LDR, BH1750, TSL2561 Analog, I2C Automation, displays

13.2.2 Motion and Position Sensors

Type Common Options Interface Use Cases
Accelerometer ADXL345, MPU6050 I2C, SPI Tilt detection, vibration
Gyroscope L3G4200D, MPU6050 I2C, SPI Rotation tracking
IMU (9-axis) MPU9250 I2C, SPI Orientation, navigation
GPS NEO-6M, NEO-M8N UART Location tracking
Distance HC-SR04, VL53L0X Digital, I2C Obstacle detection

13.2.3 Proximity and Touch Sensors

  • PIR Motion: HC-SR501 - detects human movement
  • Capacitive Touch: TTP223 - touch-activated switches
  • Proximity: APDS-9960, VCNL4010 - detect nearby objects

13.2.4 Industrial Sensors

  • Current: ACS712, INA219 - measure electrical current
  • Vibration: SW-420, accelerometers - detect motion/vibration
  • Flow: YF-S201 - measure liquid flow rates

13.2.5 Knowledge Check: Sensor Selection


13.3 Actuators

13.3.1 Motion Actuators

Type Examples Driver Use Cases
Servo Motor SG90, MG996R Direct PWM Precise angle control
DC Motor Various L298N, TB6612 Continuous rotation
Stepper Motor 28BYJ-48, NEMA17 DRV8825 Precise positioning

13.3.2 Switching Actuators

  • Relays: Electromechanical (5V/12V coil) or solid-state for high-current loads
  • Transistors: BJT (2N2222) or MOSFET (IRF520) for smaller loads

13.3.3 Output Devices

Type Examples Interface Use Cases
LEDs Single, RGB, WS2812B Digital, PWM, Data Indicators, lighting
Displays LCD 1602, OLED SSD1306, TFT I2C, SPI User interface
Speakers Piezo buzzer, speakers PWM, DAC Audio feedback

13.4 Communication Modules

13.4.1 Wireless Connectivity

Protocol Modules Range Best For
Wi-Fi ESP-01, ESP32 50-100m Home IoT, internet
Bluetooth HC-05, HM-10 10-30m Wearables, proximity
LoRa RFM95W, SX1276 2-15km Agriculture, smart city
Cellular SIM800L, SIM7600 Network Remote monitoring
Zigbee XBee Series 2/3 10-100m Mesh networks
NFC/RFID PN532, RC522 <10cm Access control

13.5 Power Components

13.5.1 Voltage Regulators

Type Examples Efficiency Use Case
Linear LM7805, LD1117 30-80% Low noise, small drops
Buck LM2596 85-95% Step-down, battery
Boost MT3608 85-93% Step-up from battery

13.5.2 Interactive Regulator Efficiency Calculator

13.5.3 Battery Management

  • Charging ICs: TP4056, MCP73831 - Li-ion/LiPo charging
  • Protection: BMS circuits - prevent over-discharge/charge
  • Monitoring: INA219 - current and voltage sensing

13.5.4 Knowledge Check: Power Design

13.5.5 Logic Level Conversion

3.3V to 5V Conversion:

  • Bi-directional level shifters: TXS0108E, BSS138-based modules
  • Voltage dividers: Resistive (5V to 3.3V only, not bidirectional)
  • MOSFET logic level shifters: Low-cost, reliable
Critical: Never Connect 5V to 3.3V Directly

Connecting a 5V output directly to a 3.3V input can damage the 3.3V device. ESP32, Raspberry Pi, and most modern MCUs use 3.3V logic and can be damaged by 5V signals. Always use level shifters or voltage dividers.


13.6 Worked Example: BOM for a Smart Environment Monitor

Project: Build a battery-powered indoor environment monitor that measures temperature, humidity, CO2, and ambient light, displays values on an OLED screen, and sends data via Wi-Fi every 5 minutes.

Component Part Interface Voltage Cost (1 qty)
MCU ESP32-S3-DevKitC N/A 3.3V $8.00
Temp/Humidity BME280 breakout I2C (0x76) 3.3V $3.50
CO2 Sensor SCD40 breakout I2C (0x62) 3.3V $25.00
Light Sensor BH1750 breakout I2C (0x23) 3.3V $2.00
Display SSD1306 0.96” OLED I2C (0x3C) 3.3V $3.50
Battery 18650 Li-ion 3000 mAh N/A 3.7V $4.00
Charger TP4056 USB-C module N/A 5V in $0.80
Breadboard Half-size N/A N/A $3.00
Jumper wires M-F pack of 40 N/A N/A $2.50
Total $52.30

I2C Wiring (all four sensors + display share 2 wires):

ESP32 GPIO21 (SDA) --+-- BME280 SDA --+-- SCD40 SDA --+-- BH1750 SDA --+-- OLED SDA
                      |                                                      |
ESP32 GPIO22 (SCL) --+-- BME280 SCL --+-- SCD40 SCL --+-- BH1750 SCL --+-- OLED SCL
                      |
                   4.7K pull-up to 3.3V on both SDA and SCL

I2C Address Map (verify no conflicts):

Device Address Conflict?
BME280 0x76 No
SCD40 0x62 No
BH1750 0x23 No
SSD1306 0x3C No

All four devices have unique I2C addresses, so they can share the same bus without address conflicts.

Power Budget Estimate:

Component Active Current Sleep Current
ESP32-S3 80 mA 8 uA
BME280 0.35 mA (measuring) 0.1 uA
SCD40 75 mA (measuring) 2 uA
BH1750 0.12 mA (measuring) 0.01 uA
SSD1306 20 mA (on) 0 uA (off)
Total Active 175 mA ~10 uA

With a 5-minute duty cycle (10 seconds active, 290 seconds sleep):

Average current = (175 mA x 10s + 0.01 mA x 290s) / 300s = 5.84 mA
Battery life = 3000 mAh / 5.84 mA = 514 hours = 21 days

To extend battery life, turn off the OLED between readings (saves 20 mA active) and use the SCD40 low-power mode (saves 40 mA active but reduces accuracy).

13.6.1 Interactive Power Budget Calculator

The duty cycle calculation reveals how brief active periods dominate power consumption. For a 300-second cycle with 10 seconds active:

\[ \text{Duty cycle} = \frac{t_{\text{active}}}{t_{\text{total}}} = \frac{10\text{ s}}{300\text{ s}} = 3.33\% \]

Despite only 3.33% activity, the active current is 17,500× the sleep current (175 mA vs 0.01 mA). Computing the weighted average:

\[ I_{\text{avg}} = \frac{175 \times 10 + 0.01 \times 290}{300} = \frac{1750 + 2.9}{300} = 5.84\text{ mA} \]

The active phase contributes \(1750 / 1752.9 = 99.8\%\) of the total energy. Reducing active current by 20 mA (OLED off) yields:

\[ I_{\text{avg,new}} = \frac{155 \times 10 + 0.01 \times 290}{300} = 5.18\text{ mA} \quad \rightarrow \quad \text{Battery life} = \frac{3000}{5.18} = 579\text{ h (24 days)} \]

A 11% active current reduction produces a 13% battery life extension, demonstrating the leverage effect of optimizing active-mode consumption.

13.7 Code Example: I2C Bus Scanner and Sensor Initialization

When assembling a prototype with multiple I2C devices, the first step is verifying all sensors are detected. This Arduino sketch scans the bus, reports found devices, and initializes the BME280:

#include <Wire.h>

// Known I2C addresses for common sensors
struct I2CDevice {
    uint8_t address;
    const char* name;
};

I2CDevice knownDevices[] = {
    {0x23, "BH1750 Light Sensor"},
    {0x3C, "SSD1306 OLED Display"},
    {0x62, "SCD40 CO2 Sensor"},
    {0x76, "BME280 (SDO=GND)"},
    {0x77, "BME280 (SDO=VDD)"},
};

void scanI2CBus() {
    Serial.println("Scanning I2C bus...");
    int found = 0;

    for (uint8_t addr = 1; addr < 127; addr++) {
        Wire.beginTransmission(addr);
        uint8_t error = Wire.endTransmission();

        if (error == 0) {
            found++;
            Serial.printf("  0x%02X: ", addr);

            // Match against known devices
            bool identified = false;
            for (auto& dev : knownDevices) {
                if (dev.address == addr) {
                    Serial.println(dev.name);
                    identified = true;
                    break;
                }
            }
            if (!identified) Serial.println("Unknown device");
        }
    }
    Serial.printf("Found %d device(s)\n", found);
}

void setup() {
    Serial.begin(115200);
    Wire.begin(21, 22);  // ESP32: SDA=21, SCL=22
    delay(100);

    scanI2CBus();

    // Expected output for Smart Environment Monitor BOM:
    // Scanning I2C bus...
    //   0x23: BH1750 Light Sensor
    //   0x3C: SSD1306 OLED Display
    //   0x62: SCD40 CO2 Sensor
    //   0x76: BME280 (SDO=GND)
    // Found 4 device(s)
}

Debugging with the scanner: If a sensor is missing from the scan results, check in this order: (1) wiring – swap SDA/SCL is the most common mistake, (2) pull-up resistors – I2C requires 4.7K pull-ups on both lines, (3) power – verify 3.3V with a multimeter at the sensor Vcc pin, (4) address conflicts – some sensors ship with the same default address.

13.8 Common Component Interfacing Pitfalls

Pitfall Symptom Solution
Missing I2C pull-ups Intermittent communication, garbage data Add 4.7K resistors to SDA/SCL
5V sensor on 3.3V MCU MCU damage or no communication Use bidirectional level shifter
Long I2C wires (>30cm) Data corruption, bus lockup Use lower clock speed (100 kHz) or switch to SPI
Floating GPIO inputs Random readings, high power draw Add pull-up or pull-down resistors
Sharing SPI CS pins Both devices respond simultaneously Each SPI device needs its own CS pin
No decoupling capacitors Random resets when motor/relay activates Add 100 nF cap near each IC power pin
Servo + MCU on same supply MCU resets when servo moves Use separate power supply for servos

13.9 Prototyping Tools

13.9.1 Essential Equipment

Tool Purpose Recommended
Soldering Iron Permanent connections Temperature-controlled, 60W+
Multimeter Measure V/I/R, continuity Auto-ranging, True RMS
Power Supply Provide power during testing Adjustable 0-30V, current limiting
Oscilloscope Visualize signals USB scope or benchtop 50MHz+
Logic Analyzer Debug digital protocols 8+ channels, I2C/SPI decode

13.9.2 Additional Useful Tools

  • Wire strippers and cutters - prepare wires for connections
  • Helping hands - hold boards during soldering
  • Heat gun - SMD rework, heat shrink tubing
  • 3D printer - custom enclosures and mounts
  • ESD protection - anti-static mat and wrist strap
In 60 Seconds

This chapter covers hardware components and tools, explaining the core concepts, practical design decisions, and common pitfalls that IoT practitioners need to build effective, reliable connected systems.

13.9.3 PCB Prototyping Options

Method Cost Time Best For
Breadboard $5-15 Minutes Initial testing
Perfboard $1-3 Hours Semi-permanent
Fab service (JLCPCB) $2-10 1-2 weeks Production-intent
CNC mill $200+ Hours Rapid custom PCBs

13.10 How It Works: I2C Sensor Bus Architecture

When multiple sensors share an I2C bus (like the Smart Environment Monitor example), the system operates through a master-slave protocol:

Physical Layer: Two wires (SDA = data, SCL = clock) connect all devices in parallel. Pull-up resistors (typically 4.7K) ensure the bus idles at HIGH voltage.

Addressing: Each I2C device has a unique 7-bit address (0x00 to 0x7F). The BME280 at 0x76, SCD40 at 0x62, BH1750 at 0x23, and OLED at 0x3C never conflict because the microcontroller addresses them individually.

Communication Sequence:

  1. MCU sends START condition (SDA drops while SCL is HIGH)
  2. MCU sends device address + R/W bit
  3. Addressed device ACKs by pulling SDA LOW
  4. Data bytes transfer (MSB first), each followed by ACK
  5. MCU sends STOP condition (SDA rises while SCL is HIGH)

Bus Arbitration: If you read all four sensors in sequence, the MCU initiates four separate transactions. The bus scanner code demonstrates this – it tries every address (1-127), and only devices actually present will ACK.

Critical Constraints: I2C speed is limited by bus capacitance. With four devices and 30cm wiring, 100 kHz (standard mode) is reliable. Pushing to 400 kHz (fast mode) risks data corruption on longer wires. Each device adds ~5 pF capacitance; the I2C spec allows max 400 pF total.

13.11 Concept Relationships

Prerequisites: Electronics Basics - Understanding voltage, current, and resistance is essential before interfacing sensors. Reading a Spec Sheet - Component selection requires interpreting datasheet specifications for voltage, current, and interface compatibility.

Related Concepts: PCB Design and Fabrication - After breadboard validation, transition to PCB for reliable connections. Energy-Aware Considerations - Power budget calculations determine battery life for prototypes. Sensor Fundamentals - Deeper understanding of sensor types and characteristics.

Builds Toward: Best Practices and Debugging - Systematic debugging of component integration issues. Testing and Validation - Validating sensor accuracy and system reliability.

13.12 See Also

Official Documentation: Espressif ESP32 Datasheet - GPIO specifications and I2C timing. I2C-bus specification and user manual - NXP’s complete I2C protocol reference. Arduino Wire Library - I2C library documentation for Arduino/ESP32.

Tools: DigiKey BOM Tool - Component sourcing and cost estimation. IPC-2221 Trace Width Calculator - Calculate safe current capacity for PCB traces. Fritzing - Visual circuit design and breadboard layout tool.

Community Resources: Adafruit Learn - Sensor tutorials and integration examples. SparkFun Tutorials - Component hookup guides and projects. Reddit r/AskElectronics - Community help for component selection and debugging.

13.13 Try It Yourself: Build a Multi-Sensor Weather Station

Challenge: Create a portable weather station that logs temperature, humidity, and light levels every 5 minutes to an SD card.

Hardware Requirements:

  • ESP32 development board ($8)
  • BME280 temperature/humidity sensor ($3.50)
  • BH1750 light sensor ($2)
  • MicroSD card module ($1.50)
  • Breadboard, jumper wires, USB cable
  • Total: ~$17

Implementation Steps:

  1. Wire BME280 to I2C bus (SDA=GPIO21, SCL=GPIO22, VCC=3.3V, GND=GND)
  2. Add BH1750 to same I2C bus (parallel connection)
  3. Wire SD card module to SPI bus (MOSI=GPIO23, MISO=GPIO19, SCK=GPIO18, CS=GPIO5)
  4. Add 4.7K pull-up resistors to SDA and SCL (if sensors don’t have onboard pull-ups)
  5. Run I2C scanner to verify sensor addresses
  6. Initialize SD card and create CSV file
  7. Read sensors every 5 minutes and append data to SD card
  8. Add RTC module (DS3231) if you need accurate timestamps

What to Observe: Check I2C scanner output – you should see BME280 at 0x76 and BH1750 at 0x23. If sensors don’t appear, check wiring (swap SDA/SCL is common mistake). Monitor power consumption – ESP32 draws 80 mA active but can deep sleep at 10 uA between readings, extending battery life to months.

Extensions: Add battery power (18650 LiPo + TP4056 charger). Display current readings on OLED screen. Transmit data via Wi-Fi to cloud dashboard. Add solar panel for continuous outdoor operation.

Common Pitfalls

Adding too many features before validating core user needs wastes weeks of effort on a direction that user testing reveals is wrong. IoT projects frequently discover that users want simpler interactions than engineers assumed. Define and test a minimum viable version first, then add complexity only in response to validated user requirements.

Treating security as a phase-2 concern results in architectures (hardcoded credentials, unencrypted channels, no firmware signing) that are expensive to remediate after deployment. Include security requirements in the initial design review, even for prototypes, because prototype patterns become production patterns.

Designing only for the happy path leaves a system that cannot recover gracefully from sensor failures, connectivity outages, or cloud unavailability. Explicitly design and test the behaviour for each failure mode and ensure devices fall back to a safe, locally functional state during outages.

13.14 What’s Next

If you want to… Read this
Explore application domains for this technology Application Domains Overview
Learn about UX design for connected devices UX Design for IoT
Start prototyping with the concepts covered Prototyping Essentials