Introduction
The Internet of Things (IoT) and embedded systems are the backbone of modern automation, from smart homes to industrial sensor networks. Whether you're a hobbyist tinkering with an Arduino Uno, building a weather station with an ESP32, or deploying a full edge-compute pipeline on a Raspberry Pi, the right prompts can drastically accelerate development. This article curates 15 actionable prompts across three skill levels—basic, advanced, and expert—each designed to solve real-world IoT challenges: reading sensors, publishing MQTT messages, implementing automation, and debugging hardware.
Each prompt includes a clear task, the exact prompt text you can copy-paste into an AI assistant (like ChatGPT or Claude), and a concrete example of the output. We’ve tested these on the latest stable toolchains as of July 2026. Let’s dive in.
Basic Prompts (Beginner-Friendly)
1. Read a DHT11 Temperature and Humidity Sensor on Arduino
Task: Generate a sketch that reads temperature and humidity from a DHT11 sensor and prints values to the Serial Monitor.
Prompt:
Write an Arduino sketch that reads temperature and humidity from a DHT11 sensor connected to digital pin 2. Use the DHT sensor library by Adafruit. Print the data to the Serial Monitor every 2 seconds. Include error handling if the sensor fails to read.
Example Result (abbreviated):
#include <DHT.h>
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
dht.begin();
}
void loop() {
delay(2000);
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print("Humidity: "); Serial.print(h);
Serial.print("% Temperature: "); Serial.print(t); Serial.println("°C");
}
2. Blink an LED on ESP32 with Wi-Fi Status
Task: Create a simple program that blinks the built-in LED while the ESP32 connects to Wi-Fi, then stops blinking when connected.
Prompt:
Write an ESP32 Arduino sketch that connects to Wi-Fi (SSID: MyNetwork, password: secret123) and blinks the built-in LED (GPIO2) every 500ms while connecting. Once connected, turn the LED off and print the IP address to Serial.
Example Result:
The AI outputs a sketch using WiFi.h, with digitalWrite(LED_BUILTIN, HIGH) inside the connection loop, and WiFi.localIP() after success. Perfect for verifying network setup.
3. Read a Button on Raspberry Pi GPIO
Task: Write a Python script to read a physical button connected to GPIO17 and print "Button Pressed!" when pressed.
Prompt:
Write a Python script using RPi.GPIO that sets GPIO17 as input with a pull-up resistor. When the button is pressed (GPIO goes LOW), print "Button Pressed!" to the console. Use edge detection (falling edge) for clean readings.
Example Result:
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_UP)
def callback(channel):
print("Button Pressed!")
GPIO.add_event_detect(17, GPIO.FALLING, callback=callback, bouncetime=300)
try:
while True:
pass
except KeyboardInterrupt:
GPIO.cleanup()
Advanced Prompts (Intermediate to Pro)
4. Publish Sensor Data via MQTT on ESP32
Task: Send DHT11 readings to an MQTT broker running on a Raspberry Pi.
Prompt:
Write an ESP32 Arduino sketch that connects to Wi-Fi (SSID: HomeNet, password: iot2026) and an MQTT broker at 192.168.1.100:1883. Subscribe to topic "cmd/led" to control an external LED on GPIO5 (ON/OFF). Every 10 seconds, publish temperature and humidity as JSON to topic "sensor/dht11". Use the PubSubClient library.
Example Result:
The AI generates a sketch with WiFiClient and PubSubClient, handling reconnection and JSON formatting using ArduinoJson. The output includes callback logic for the LED subscription.
5. Automate a Relay with a PIR Motion Sensor on Arduino
Task: Create a motion-activated light that turns on a relay for 30 seconds after motion is detected.
Prompt:
Write an Arduino sketch that reads a PIR motion sensor on pin 3. When motion is detected (HIGH), turn on a relay on pin 7 for 30 seconds, then turn it off. Ignore repeated triggers within 30 seconds (cooldown). Use millis() for non-blocking timing.
Example Result:
The sketch uses unsigned long variables and millis() comparison, avoiding delay() to keep the loop responsive.
6. Log Data to SD Card on Arduino
Task: Log sensor readings to an SD card module with a timestamp.
Prompt:
Write an Arduino sketch that reads an analog sensor on pin A0 and logs the value with a millis() timestamp to a file named "data.csv" on an SD card (CS pin 10). Open the file once in setup, then write a new line every 5 seconds. Ensure proper file closing on power loss.
Example Result:
Uses SD.begin(10) and File dataFile = SD.open("data.csv", FILE_WRITE), with dataFile.println(String(millis()) + "," + analogRead(A0)). Includes flush() after each write.
7. Set Up a Raspberry Pi as an MQTT Broker with Mosquitto
Task: Install and configure Mosquitto on a Raspberry Pi to accept connections from ESP32 devices.
Prompt:
Write a step-by-step shell script that installs Mosquitto MQTT broker on a Raspberry Pi running Raspberry Pi OS (Bookworm). Include commands to start the service, enable it on boot, create a password file for user 'iotuser', and allow anonymous access. Also configure the firewall (ufw) for port 1883.
Example Result:
The AI outputs a bash script with sudo apt install mosquitto mosquitto-clients, sudo mosquitto_passwd -c /etc/mosquitto/passwd iotuser, and sudo ufw allow 1883. Includes a test command: mosquitto_sub -h localhost -t test.
8. Control RGB LED via PWM on ESP32
Task: Vary the color of an RGB LED using three PWM channels.
Prompt:
Write an ESP32 Arduino sketch that controls a common-cathode RGB LED on pins 25 (red), 26 (green), and 27 (blue). Cycle through red, green, blue, and white (all on) with 1-second intervals. Use the LEDC library for PWM.
Example Result:
Sets up three LEDC channels at 5000 Hz, 8-bit resolution, and uses ledcWrite() to change duty cycles sequentially.
9. Read a Soil Moisture Sensor and Send Alert via Telegram
Task: When soil moisture drops below a threshold, send a Telegram message.
Prompt:
Write an ESP32 sketch that reads a capacitive soil moisture sensor on analog pin 34. If the value exceeds 3000 (dry), send a Telegram message via the UniversalTelegramBot library to chat ID '123456789' using bot token 'YOUR_BOT_TOKEN_HERE'. Check every 60 seconds.
Example Result:
The AI generates code with WiFiClientSecure, UniversalTelegramBot, and JSON parsing. It includes a sendMessage call with bot.sendMessage(CHAT_ID, "Soil is dry! Water the plant.", "").
ASI Biont supports connecting ESP32 devices to Telegram via its built-in API integration—learn more at asibiont.com/courses.
Expert Prompts (Production-Grade)
10. Build an Over-the-Air (OTA) Update System for ESP32
Task: Enable wireless firmware updates for remote ESP32 devices.
Prompt:
Write an ESP32 Arduino sketch that supports OTA updates using the ArduinoOTA library. Include Wi-Fi credentials, a custom hostname "sensor-node-1", and password protection for the update. Also add a fallback: if the device fails to connect to Wi-Fi within 30 seconds, start an AP mode with SSID "ESP32-Config" for configuration.
Example Result:
The sketch starts ArduinoOTA with ArduinoOTA.setHostname("sensor-node-1") and ArduinoOTA.setPassword("ota123"). The AP fallback uses WiFi.softAP("ESP32-Config") and a simple web server for entering credentials (captive portal pattern).
11. Implement a Low-Power Deep Sleep Mode on ESP32
Task: Run sensor readings every hour, deep sleep between cycles.
Prompt:
Write an ESP32 sketch that wakes from deep sleep every hour, reads a DHT22 sensor, publishes the data via MQTT, and goes back to deep sleep. Use RTC memory to store a counter of total readings. Configure the timer to wake from deep sleep using the ULP coprocessor? No, use the RTC timer.
Example Result:
Uses esp_sleep_enable_timer_wakeup(3600 * 1000000ULL) and esp_deep_sleep_start(). RTC data is stored with RTC_DATA_ATTR int bootCount = 0. The sketch prints the count after each wake.
12. Create a Multi-Threaded Data Logger on Raspberry Pi
Task: Use Python threading to read sensors and log to a database concurrently.
Prompt:
Write a Python script for Raspberry Pi that uses threading to read a BME280 sensor via I2C every 5 seconds and log temperature, humidity, pressure to a SQLite database. Use a separate thread for a Flask web server that shows the latest reading on a simple HTML page. Handle Graceful shutdown on Ctrl+C.
Example Result:
The AI generates a script with threading.Thread, schedule library, and Flask. The SQLite table is created with CREATE TABLE IF NOT EXISTS readings (timestamp TEXT, temp REAL, humidity REAL, pressure REAL). The Flask route returns JSON or an HTML table.
13. Build an Edge AI Inference Pipeline on Raspberry Pi
Task: Run a TensorFlow Lite model for image classification on a Pi Camera.
Prompt:
Write a Python script for Raspberry Pi 5 that captures an image from the Pi Camera Module 3, runs inference using a pre-trained MobileNet V2 TFLite model, and prints the top-3 predicted labels with confidence scores. Use the tflite_runtime library and the picamera2 library.
Example Result:
Loads the model with tflite.Interpreter(model_path="mobilenet_v2_1.0_224.tflite"), allocates tensors, gets input details, and runs interpreter.invoke(). Output is decoded using the labels file from ImageNet.
14. Set Up Real-Time Dashboard with Node-RED and MQTT
Task: Visualize sensor data on a web dashboard.
Prompt:
Provide a Node-RED flow JSON that subscribes to MQTT topic "sensor/+/data" (where + is a device ID), parses JSON payload, and displays temperature and humidity on a dashboard gauge and chart. Include a switch node to control an LED via topic "cmd/led".
Example Result:
The AI outputs a flow with mqtt in, json, function nodes, and ui_gauge, ui_chart from node-red-dashboard. The switch node publishes to cmd/led.
15. Implement Secure MQTT with TLS on ESP32
Task: Connect to a cloud MQTT broker (e.g., HiveMQ Cloud) using TLS certificates.
Prompt:
Write an ESP32 sketch that connects to broker.hivemq.com on port 8883 using TLS. Use the WiFiClientSecure library. Include the CA certificate as a string constant. Publish a test message to topic "test/hello" every 30 seconds. Verify the connection with a heartbeat.
Example Result:
The sketch includes const char* ca_cert = "-----BEGIN CERTIFICATE-----..." and sets wifiClient.setCACert(ca_cert). Uses PubSubClient with the secure client. The AI also includes error handling for connection failures.
Conclusion
These 15 prompts cover the entire IoT development spectrum—from blinking an LED to deploying secure, production-grade pipelines. The key is to treat AI prompts as a starting point: always review generated code for safety (e.g., never hardcode credentials in production), test on hardware, and iterate. As the embedded ecosystem evolves (ESP32-P4 boards, Raspberry Pi AI HAT+), these prompts will remain relevant because they focus on fundamental protocols—MQTT, I2C, PWM, and TLS—that stay constant.
Start with the basic prompts to build confidence, then move to advanced and expert ones as your projects grow. Happy building!
Comments