AWS Builder Center
ESP32 + AWS IoT + Terraform + GenAI: Building a Smart Home Inventory System in One Night

ESP32 + AWS IoT + Terraform + GenAI: Building a Smart Home Inventory System in One Night

How I built a smart pantry inventory system with ESP32 + AWS IoT Core + Lambda + DynamoDB in one Monday night — from first breadboard to live dashboard. Zero cloud cost, full serverless, real-time MQTT.

AWS Golden Jacket | Kiro Ambassador 🟣 | Founder & Global Lead — Golden Jackets

From Zero to AWS IoT in One Night — Building a Smart Pantry with ESP32

How I went from "I don't know how to put this on a breadboard" to seeing real-time messages on AWS IoT Core — in a single Monday night.

The Problem

I buy groceries. I forget what I have at home. I buy duplicates. My wife gets annoyed.
Sound familiar?
I wanted a system that tracks everything entering and leaving my pantry — automatically. Scan a barcode when you put something in, scan when you take it out. The system keeps count and tells you what to buy.
Simple concept. But I wanted it serverless, IoT-native, and AI-powered — running on AWS for less than $1/month.

The Stack

  • ESP32 — $8 microcontroller with WiFi + Bluetooth
  • AWS IoT Core — MQTT broker with mutual TLS authentication
  • Lambda — processes scan events
  • DynamoDB — single-table design for inventory
  • Bedrock (coming soon) — generates smart shopping lists
  • Terraform — infrastructure as code
  • GitHub Actions — CI/CD
Total AWS cost: $0/month (free tier covers everything).

The Journey

8:50 PM — Unboxing

I had never touched a microcontroller before. The ESP32 arrived in an antistatic bag. The breadboard was a white plastic board with holes. I had no idea which end was up.

9:00 PM — First Signs of Life

Plugged the ESP32 into the breadboard (straddling the center channel — I had to ask what that meant). Connected a micro-USB cable. A red LED turned on. The computer recognized it as COM3 (CH9102 chip).

9:15 PM — Blink!

Compiled a simple blink firmware using PlatformIO on WSL, flashed it via esptool on Windows PowerShell (WSL can't access USB directly — lesson learned). The blue LED started blinking. First microcontroller ever programmed. ✅

9:40 PM — WiFi Connected

Updated the firmware to connect to my home WiFi. Serial monitor showed:
1
2
Connecting to Lippi... connected!
WiFi connected! IP: 192.168.15.17

9:50 PM — AWS IoT Core Connected

Created an X.509 certificate via AWS CLI, embedded the certs in the firmware, established mutual TLS connection to AWS IoT Core. The serial monitor showed:
1
2
Connecting to AWS IoT... connected!
Published to stockhome/dev01/status

9:55 PM — The Magic Moment

Opened the MQTT Test Client in the AWS Console, subscribed to stockhome/#, and there it was:
1
2
3
4
{
"status": "online",
"device": "stockhome-dev01"
}
A message from the ESP32 sitting on my desk, arriving in the AWS cloud in real-time. From zero to cloud in one hour.

10:15 PM — End-to-End Flow

Fixed the IoT Rule permission (the Lambda couldn't be invoked — classic missing lambda:InvokeFunction permission). Published a test scan message. Checked DynamoDB:
1
2
3
4
5
6
7
{
"PK": "HOUSEHOLD#h001",
"SK": "PRODUCT#7891234567890",
"name": "Banana",
"current_stock": 1,
"mode": "IN"
}
Full pipeline working: ESP32 → IoT Core → IoT Rule → Lambda → DynamoDB ✅

11:00 PM — Live Dashboard

Created a Lambda Function URL serving both HTML and API endpoints over HTTPS. The dashboard pulls real data from DynamoDB — products, stock levels, alerts. The admin panel shows a Leaflet map with my device's location and real-time status.

Architecture

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
ESP32 (WiFi + Certs)
│
│ MQTT over TLS (port 8883)
▼
AWS IoT Core
│
│ IoT Rule (SELECT * FROM 'stockhome/+/scan')
▼
Lambda ─ process_scan
│
│ PutItem / UpdateItem
▼
DynamoDB ─ Single-Table Design
│
│ Query (PK = HOUSEHOLD#h001)
▼
Lambda Function URL ─ API + Dashboard
│
│ HTTPS
▼
Browser

Lessons Learned

  1. WSL can't access USB serial ports — use esptool directly on Windows PowerShell
  2. Always flash bootloader + partitions + firmware — flashing only the app binary causes boot loops
  3. IoT Rule → Lambda needs explicit permission — lambda:InvokeFunction from iot.amazonaws.com
  4. Lambda Function URLs need TWO permissions — InvokeFunctionUrl AND InvokeFunction
  5. Mixed content kills you — serve HTML and API from the same HTTPS endpoint

What's Next

  • Barcode scanner (GM67 module arriving from China) — real product scanning
  • Load cell (HX711 + 5kg cell) — weight-based inventory tracking
  • Bedrock AI — smart shopping list generation based on consumption patterns
  • WhatsApp alerts — "You're out of coffee!" via Z-API

Open Source

The full project is on GitHub: ricardogulias/stockhome 
Stack: ESP32 (C++) + Python 3.12 + Terraform + DynamoDB + IoT Core + Lambda

Built in one night with an ESP32, a breadboard, and AWS. Total cost: R$40 in hardware + $0/month in cloud. Sometimes the best projects start at midnight on a Monday. 🚀
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article