15 Prompts for IoT and Embedded Systems: Arduino, ESP32, Raspberry Pi
Introduction
The Internet of Things (IoT) and embedded systems are reshaping industries—from smart agriculture and industrial automation to home health monitoring. Arduino, ESP32, and Raspberry Pi form the backbone of countless projects, yet many developers spend hours debugging sensor readings or configuring MQTT brokers. The right prompt can turn a vague idea into a working prototype in minutes.
This article presents 15 ready-to-use prompts for IoT development, covering sensor data acquisition, wireless communication with MQTT, automation logic, and performance optimization. Each prompt is specific, copy-paste ready, and includes a usage example. Whether you are a hobbyist or a professional embedded engineer, these prompts will streamline your workflow and reduce trial-and-error.
Why Use Prompts for IoT Development?
Writing code for embedded devices often involves repetitive boilerplate—initializing I2C, handling JSON parsing, or setting up MQTT callbacks. Large language models (LLMs) trained on extensive code repositories can generate reliable snippets, but only if the prompt is precise. A well-crafted prompt includes:
- The board or chip (e.g., ESP32, Arduino Uno, Raspberry Pi 4)
- The sensor or module (e.g., DHT22, BME280, HC-SR04)
- The communication protocol (I2C, SPI, UART, MQTT)
- Expected output format (serial monitor, JSON, cloud dashboard)
- Constraints (power consumption, memory limits, real-time requirements)
Below are 15 prompts organized by task category. Each has a brief explanation and a concrete example.
1. Reading Temperature and Humidity from DHT22 (Arduino Uno)
Prompt:
Write an Arduino sketch for an Arduino Uno that reads temperature and humidity from a DHT22 sensor connected to digital pin 2. Print the values to the serial monitor every 2 seconds. Use the DHT sensor library. Include error handling for failed reads.
Explanation: This prompt is specific about the board (Arduino Uno), sensor (DHT22), pin (digital 2), library (DHT sensor library), and behavior (every 2 seconds, with error handling). It avoids ambiguity.
Usage example output (serial monitor):
Temperature: 23.5°C Humidity: 61.2%
Temperature: 23.6°C Humidity: 61.0%
Failed to read from DHT sensor!
2. ESP32 MQTT Publisher for BME280 Data
Prompt:
Create an ESP32 program that reads pressure, temperature, and humidity from a BME280 sensor over I2C. Publish the readings as a JSON payload to an MQTT broker at
mqtt.eclipseprojects.ioon topicsensor/bme280. Use WiFiManager for easy network configuration. Include reconnect logic.
Explanation: Combines sensor reading (BME280, I2C), MQTT publishing (JSON), and robust network handling (WiFiManager, reconnect). The broker address is a real public test broker.
Usage example output (MQTT payload):
{"temperature": 24.1, "humidity": 55.3, "pressure": 1013.2}
3. Raspberry Pi GPIO Blink with Python
Prompt:
Write a Python script for Raspberry Pi 4 that blinks an LED connected to GPIO 17 every 1 second. Use the RPi.GPIO library. Add a try/except block to cleanly release GPIO on Ctrl+C.
Explanation: Simple but essential—blinking an LED is the "Hello World" of embedded. The prompt specifies library, pin, timing, and cleanup.
Usage example output (terminal):
LED ON
LED OFF
LED ON
4. Reading Ultrasonic Distance Sensor HC-SR04 on ESP32
Prompt:
Write an ESP32 program using Arduino framework that measures distance with an HC-SR04 ultrasonic sensor (Trig pin 13, Echo pin 12). Print distance in centimeters to serial monitor every 500 ms. Apply a moving average filter over 5 readings.
Explanation: Adds a real-world requirement (moving average filter) to reduce noise. Pin numbers are explicit.
Usage example output:
Distance: 45.2 cm
Distance: 45.5 cm
Distance: 45.3 cm
5. MQTT Bridge Between Two ESP32s
Prompt:
Write code for two ESP32s: one as a publisher (reads a potentiometer on ADC pin 34 and publishes the value to MQTT topic
pot/value), and the other as a subscriber (receives the value and controls an LED brightness via PWM on pin 5). Use the same MQTT broker. Include WiFi credentials as constants.
Explanation: Demonstrates a complete IoT pipeline—sensor → MQTT → actuator. The prompt defines roles, topics, and pins.
Usage example: When potentiometer is turned, the LED on the second ESP32 changes brightness proportionally.
6. ESP32 Deep Sleep with Wake on Timer
Prompt:
Create an ESP32 Arduino sketch that reads a DS18B20 temperature sensor (on GPIO 4, one-wire), publishes the value via MQTT, then enters deep sleep for 10 minutes. Use the
ESP.deepSleep()function. Print wake-up reason.
Explanation: Critical for battery-powered IoT. Includes one-wire protocol, MQTT, and low-power mode.
Usage example output (serial after wake):
Wake-up reason: timer
Temperature: 22.1°C
Publishing...
Going to sleep...
7. Raspberry Pi Camera with Motion Detection
Prompt:
Write a Python script for Raspberry Pi 4 with a Pi Camera module that captures a frame every 5 seconds. Use OpenCV to detect motion by comparing consecutive frames (absolute difference threshold > 5000 pixels). On motion, save the frame as
motion_YYYYMMDD_HHMMSS.jpg.
Explanation: Combines camera, OpenCV, and file I/O. Threshold values are given to reduce guesswork.
Usage example: Files saved in the working directory when motion occurs.
8. Arduino Uno with SD Card Logger
Prompt:
Write an Arduino sketch that reads an analog sensor on A0 and logs the value along with a timestamp (millis) to an SD card (CS pin 10) every second. Use the SD library. Append data to
log.csv. If the card is missing, print error to serial.
Explanation: Data logging is fundamental in embedded. The prompt specifies pin, library, file format, and error handling.
Usage example (log.csv):
100,512
200,489
300,501
9. ESP32 Web Server with Sensor Dashboard
Prompt:
Write an ESP32 Arduino program that hosts a web server on port 80. Serve an HTML page that displays real-time readings from a DHT22 (pin 4) and an LDR (pin 34) using Server-Sent Events (SSE). Update every 2 seconds. Include auto-refresh.
Explanation: Creates a full web dashboard without external services. SSE is efficient for real-time data.
Usage example: Open browser to ESP32 IP—see temperature, humidity, and light level updating live.
10. Raspberry Pi I2C Communication with Arduino
Prompt:
Write a Python script on Raspberry Pi 4 (master) that sends a byte
0x01to an Arduino Uno (slave address 0x08) via I2C, and reads back 2 bytes. Print the received value. On the Arduino side, write a sketch that receives the byte and sends back0x02, 0x03.
Explanation: Demonstrates inter-board communication. Addresses and data bytes are explicit.
Usage example output (Raspberry Pi):
Sent: 1
Received: [2, 3]
11. OTA (Over-the-Air) Update for ESP32
Prompt:
Write an ESP32 Arduino sketch that enables OTA updates using the ArduinoOTA library. Include a function to blink an LED (pin 2) while OTA is in progress. Set the hostname to "ESP32-OTA-Device". Use a password "1234".
Explanation: OTA is essential for deployed devices. The prompt includes safety (blink during update) and authentication.
Usage example: Upload new firmware via Arduino IDE over WiFi without physical access.
12. ESP32 with OLED Display (SSD1306)
Prompt:
Create an ESP32 Arduino sketch that displays temperature from a DS18B20 sensor on a 128x64 OLED (I2C address 0x3C). Use the Adafruit SSD1306 and GFX libraries. Update display every 5 seconds. Show temperature with one decimal and a degree symbol.
Explanation: Combines sensor, display, and formatting. Library names and I2C address are given.
Usage example: OLED shows "Temp: 23.5°C".
13. Raspberry Pi MQTT Subscriber with Relay Control
Prompt:
Write a Python script for Raspberry Pi 4 that subscribes to MQTT topic
home/light/switch. When message is "ON", set GPIO 17 high (relay on). When "OFF", set GPIO 17 low. Use paho-mqtt. Include callback function and graceful exit.
Explanation: Home automation classic. The prompt defines topic, message format, and GPIO.
Usage example: Publish "ON" to home/light/switch → relay clicks on.
14. ESP32 Bluetooth Classic (SPP) Serial Communication
Prompt:
Write an ESP32 Arduino sketch that acts as a Bluetooth Classic SPP server. Accept a connection from a smartphone. When the phone sends '1', turn on an LED (pin 2); when '0', turn it off. Send back "OK" after each command.
Explanation: Useful for legacy Bluetooth projects. Commands are single characters for simplicity.
Usage example: Connect phone via Serial Bluetooth Terminal app, send '1' → LED on, receive "OK".
15. Arduino Uno with Multiple I2C Sensors
Prompt:
Write an Arduino sketch that reads a BME280 (address 0x76) and an MPU6050 (address 0x68) on the same I2C bus. Print temperature from BME280 and accelerometer X,Y,Z from MPU6050 to serial every second. Use the respective Adafruit libraries. Handle sensor initialization failures.
Explanation: Shows how to manage multiple I2C devices with distinct addresses.
Usage example output:
BME280 Temp: 24.0°C MPU6050 Accel: 0.12, 0.01, 0.98 g
Best Practices for Writing IoT Prompts
- Be explicit about hardware: Always mention board, sensor model, pin numbers, and communication protocol.
- State the expected output: Serial monitor, MQTT topic, file, web page, etc.
- Include constraints: Power budget, timing, memory limits, real-time requirements.
- Specify libraries: Many sensors have multiple libraries; naming the correct one saves time.
- Mention error handling: IoT devices often run unattended—robustness is key.
Conclusion
These 15 prompts cover the most common tasks in IoT and embedded development—from basic sensor reading to advanced OTA updates and inter-board communication. Each prompt is designed to be copy-paste ready, reducing the time from idea to working prototype. By following the structure (board, sensor, protocol, output, constraints), you can craft your own prompts for any component. The examples are tested with Arduino Uno, ESP32, and Raspberry Pi 4 as of mid-2026. Use them as a starting point, and adapt the pin numbers and thresholds to your own project.
For those looking to deepen their skills, ASI Biont supports IoT and embedded system courses with practical, text-based lessons—no video, no fluff. Explore real-world projects and automation workflows at asibiont.com/courses.
Comments