top of page

Building the Sensor Pocket

A Journey of Innovation and Problem-Solving  

Subtitle: How I Designed a Portable Sensor Hub with Arduino R4 WiFi, ILC Display, and Relay Control

Introduction  

​In today’s connected world, compact and versatile IoT solutions are in high demand. Meet the Sensor Pocket—a portable, self-contained device that monitors environmental data, displays it in real-time, and triggers actions via relays. Designed for flexibility, it’s powered by a phone power bank, making it ideal for fieldwork or smart home applications. Here’s how I built it, the challenges I faced, and the solutions that brought it to life.  

IMG_4580.jpg

Project Overview

The Sensor Pocket combines sensing, visualization, and control in one handheld package. Key features:  

  • Real-time data display on a 2.7” ILC screen.  

  • Relay modules to control external devices (e.g., lights, fans).  

  • WiFi connectivity (via Arduino R4) for future IoT integration.  

  • Portable power via USB power bank.  

Components Used

1. Arduino Uno R4 WiFi (replaced ESP32 due to display compatibility).  

2. ILC 2.7-inch SPI Display (27x0 resolution).  

3. 2-Channel Relay Module (for device control).  

4. Sensors (e.g., temperature/humidity, motion—customizable).  

5. Portable Power Bank (5V USB output).  

6. Custom 3D-Printed Enclosure. 

Step-by-Step Build

1. Hardware Setup

  •  Sensor & Display: Connected the DHT22 to Arduino’s digital pin and the ILC screen via SPI (SCK, MOSI, CS).  

  • Relays: Linked to digital pins to switch pumps/misters on/off.  

  • Power: Arduino and peripherals powered by a USB power bank.  

​

2. Initial Roadblock: ESP32 Display Failure

  • Problem: The ILC screen wouldn’t initialize with ESP32 due to SPI library conflicts.  

  • Solution: Switched to Arduino R4 WiFi, which offered better compatibility and 5V logic support.  

 

3. Firmware Development Key Code Features:  

  •   Read DHT22 data and update the ILC screen.  

  •   Trigger relays based on sensor thresholds (e.g., humidity <50% activates misters).  

  •   Sync data and controls with Blynk.  

#include <SPI.h>

#include <DHT.h>

#include <Adafruit_GFX.h>

#include <Adafruit_ILI9341.h>

#include <BlynkSimpleArduino_UNOWiFiR4.h>

 

#define DHTPIN 2

#define DHTTYPE DHT22

DHT dht(DHTPIN, DHTTYPE);

 

Adafruit_ILI9341 tft(10, 9); // CS, DC pins

BlynkTimer timer;

 

void updateBlynk() {

  float h = dht.readHumidity();

  float t = dht.readTemperature();

  

  // Send data to Blynk

  Blynk.virtualWrite(V0, t);

  Blynk.virtualWrite(V1, h);

  

  // Update display

  tft.setCursor(0, 0);

  tft.printf("Temp: %.1fC\nHumidity: %.1f%%", t, h);

}

 

BLYNK_WRITE(V2) { // Blynk app button controls relay

  int state = param.asInt();

  digitalWrite(RELAY_PIN, state); 

}

 

void setup() {

  Serial.begin(115200);

  dht.begin();

  tft.begin();

  tft.fillScreen(ILI9341_BLACK);

  

  Blynk.begin(BLYNK_AUTH_TOKEN, "WiFi_SSID", "WiFi_PASS");

  timer.setInterval(2000L, updateBlynk);

}

 

void loop() {

  Blynk.run();

  timer.run();

}

Key Challenges & Solutions 

1. ESP32 Display Compatibility

  • Issue: The ILC screen failed to initialize due to voltage mismatches and SPI timing.  

  • Fix: Switched to Arduino R4 WiFi and optimized SPI clock speed.  

 

2. Blynk Integration Hurdles

  • Issue: Initial latency in Blynk commands and sensor sync.  

  • Fix: Reduced `BlynkTimer` intervals and added error handling for sensor reads.  

 

3. macOS USB Firmware Crash

 

4. Relay Feedback Noise

  • Issue: Relay switching caused screen flickering.  

  • Fix: Added a decoupling capacitor across the relay’s power pins. 

IMG_1471.HEIC

Final Assembly & Testing

  •  Enclosure: Designed a 3D-printed case with slots for sensors and buttons.  

  • Blynk Dashboard: Created a mobile/desktop interface with real-time graphs and toggle buttons.  

  • Portability Test: Ran for 12+ hours on a 10,000mAh power bank without issues.

FIGURE: Find the GND and Download pins on the 6-pin header next to the USB-C connector.

Why This Matters for My Career

This project demonstrates my ability to:  

  • Adapt Hardware: Pivoted from ESP32 to Arduino R4 to meet project needs.  

  • Solve Complex Problems: Resolved firmware crashes, SPI conflicts, and cloud latency.  

  • Bridge IoT Layers: Integrated sensors, microcontrollers, relays, and cloud platforms into a user-friendly product.  

  • Communicate Clearly: Documented every step for reproducibility — a skill critical for collaborative tech environments like Google.  

 

Future Improvements

  • Add predictive analytics using sensor data history.  

  • Implement solar charging for indefinite outdoor use.  

  • Upgrade to Google Cloud IoT Core for enterprise scalability. 

© 2023 All Rights Reserved to Penpisuth Boonnoon

bottom of page