Common Interview Questions on Arduino & ESP32
ESP32 is a powerful microcontroller from Espressif, widely used in IoT, automation, robotics, and embedded systems. Here are the most commonly asked Arduino ESP32 interview questions, categorized for better understanding.
1. Basics of ESP32 & Arduino
Q1: What is ESP32?
A:
ESP32 is a low-cost, low-power, dual-core microcontroller with built-in Wi-Fi & Bluetooth capabilities. It is widely used in IoT, home automation, and industrial applications.
Q2: What are the key features of ESP32?
A:
- Dual-core Xtensa 32-bit LX6 CPU
- Built-in Wi-Fi (802.11 b/g/n) and Bluetooth (BLE 4.2/5.0)
- Operating voltage: 3.3V
- Multiple GPIOs with PWM, ADC, DAC, I2C, SPI, UART
- Deep sleep mode for ultra-low power consumption
2. ESP32 vs Other Microcontrollers
Q3: How is ESP32 different from ESP8266?
Feature | ESP8266 | ESP32 |
---|---|---|
CPU | Single-core | Dual-core |
Clock Speed | 80 MHz | 240 MHz |
Wi-Fi | Yes | Yes |
Bluetooth | No | Yes (BLE & Classic) |
GPIO Pins | ~11 | 36 |
ADC | 10-bit | 12-bit |
Power Consumption | Higher | Lower (Deep Sleep Mode) |
Q4: How does ESP32 compare with Arduino Uno?
Feature | Arduino Uno | ESP32 |
---|---|---|
CPU | 8-bit AVR | 32-bit Xtensa |
Clock Speed | 16 MHz | 240 MHz |
Wi-Fi | No | Yes |
Bluetooth | No | Yes |
GPIO Pins | 14 | 36 |
ADC | 10-bit | 12-bit |
Power Consumption | Higher | Lower |
3. Programming ESP32 with Arduino IDE
Q5: How do you program ESP32 using Arduino IDE?
A:
- Install ESP32 Board Manager in Arduino IDE.
- Select "ESP32 Dev Module" under Tools → Board.
- Connect ESP32 via USB and select the correct COM Port.
- Write and upload the code.
Q6: How do you blink an LED on ESP32 using Arduino IDE?
#define LED_PIN 2 // Built-in LED pin on ESP32
void setup() {
pinMode(LED_PIN, OUTPUT);
}
void loop() {
digitalWrite(LED_PIN, HIGH);
delay(1000);
digitalWrite(LED_PIN, LOW);
delay(1000);
}
4. Wi-Fi & IoT with ESP32
Q7: How do you connect ESP32 to Wi-Fi?
#include <WiFi.h>
const char* ssid = "YourSSID";
const char* password = "YourPassword";
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting...");
}
Serial.println("WiFi Connected!");
}
void loop() {
}
Q8: How do you create a web server on ESP32?
#include <WiFi.h>
#include <WebServer.h>
const char* ssid = "YourSSID";
const char* password = "YourPassword";
WebServer server(80);
void handleRoot() {
server.send(200, "text/html", "<h1>Hello from ESP32!</h1>");
}
void setup() {
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) delay(1000);
server.on("/", handleRoot);
server.begin();
}
void loop() {
server.handleClient();
}
5. Bluetooth & ESP32
Q9: How do you use ESP32 as a Bluetooth server?
#include "BluetoothSerial.h"
BluetoothSerial SerialBT;
void setup() {
Serial.begin(115200);
SerialBT.begin("ESP32_BT");
}
void loop() {
if (SerialBT.available()) {
char c = SerialBT.read();
Serial.write(c);
}
}
6. Sensors & Communication Protocols
Q10: How do you interface ESP32 with a DHT11 temperature sensor?
#include <DHT.h>
#define DHTPIN 4
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(115200);
dht.begin();
}
void loop() {
float temp = dht.readTemperature();
Serial.print("Temperature: ");
Serial.println(temp);
delay(2000);
}
Q11: What communication protocols does ESP32 support?
- UART – Used for serial communication.
- SPI – Used for high-speed data transfer.
- I2C – Used for interfacing sensors like OLED, MPU6050.
- CAN – Used in automotive applications.
7. Power Management & Deep Sleep
Q12: How do you put ESP32 into deep sleep mode?
void setup() {
esp_sleep_enable_timer_wakeup(5000000); // Sleep for 5 seconds
esp_deep_sleep_start();
}
void loop() {
}
- Deep sleep mode significantly reduces power consumption.
- ESP32 wakes up based on a timer, GPIO trigger, or sensor input.
8. Debugging & Troubleshooting ESP32
Q13: What are common issues faced with ESP32?
- ESP32 not detected – Check drivers, use a different USB cable.
- Upload error (Failed to connect to ESP32: Timed out) – Press BOOT while uploading.
- Wi-Fi connection issues – Check SSID & password, move closer to the router.
- ESP32 resets randomly – Check for power fluctuations, use a capacitor (100µF) across 3.3V and GND.
9. Real-Time Operating System (RTOS) in ESP32
Q14: Does ESP32 support FreeRTOS?
A: Yes, ESP32 comes with FreeRTOS pre-installed, allowing tasks to run in parallel.
Q15: How do you create a FreeRTOS task on ESP32?
void Task1(void *pvParameters) {
while (1) {
Serial.println("Task 1 Running");
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}
void setup() {
Serial.begin(115200);
xTaskCreate(Task1, "Task1", 1000, NULL, 1, NULL);
}
void loop() {
}
-
FreeRTOS allows multitasking, making ESP32 ideal for real-time IoT applications.