The ESP32 is a powerful and versatile microcontroller that integrates Wi-Fi and Bluetooth capabilities, making it an excellent choice for Internet of Things (IoT) applications. It features a dual-core processor, a wide range of GPIO pins, and support for various communication protocols. The addition of an expansion board enhances the ESP32's functionality by providing extra GPIO pins, improved power management, and additional connectivity options, making it easier to prototype and develop complex projects.
Parameter | Specification |
---|---|
Microcontroller | ESP32 Dual-Core Xtensa LX6 |
Clock Speed | Up to 240 MHz |
Flash Memory | 4 MB (varies by model) |
SRAM | 520 KB |
Wi-Fi | 802.11 b/g/n (2.4 GHz) |
Bluetooth | v4.2 BR/EDR and BLE |
Operating Voltage | 3.3V |
Input Voltage (via USB) | 5V |
GPIO Pins | 30+ (varies with expansion board) |
ADC Channels | Up to 18 |
DAC Channels | 2 |
Communication Interfaces | UART, SPI, I2C, I2S, CAN, PWM |
Power Management | Integrated with expansion board |
The ESP32 with an expansion board typically includes the following pin layout. Note that the exact configuration may vary depending on the specific expansion board model.
Pin Name | Description |
---|---|
VIN | Input voltage (5V from USB or external source) |
3V3 | 3.3V output for powering external components |
GND | Ground |
EN | Enable pin (active high to enable the ESP32) |
GPIO0 | General-purpose I/O, often used for boot mode |
GPIO2 | General-purpose I/O |
GPIO4 | General-purpose I/O |
GPIO5 | General-purpose I/O |
GPIO12 | General-purpose I/O |
GPIO13 | General-purpose I/O |
GPIO14 | General-purpose I/O |
GPIO15 | General-purpose I/O |
GPIO16 | General-purpose I/O |
GPIO17 | General-purpose I/O |
TXD0 | UART0 Transmit |
RXD0 | UART0 Receive |
SDA | I2C Data Line |
SCL | I2C Clock Line |
A0-A17 | Analog input pins (ADC channels) |
DAC1 | Digital-to-Analog Converter Channel 1 |
DAC2 | Digital-to-Analog Converter Channel 2 |
The following example demonstrates how to use the ESP32 to read data from a DHT11 temperature and humidity sensor and send the data to a serial monitor.
#include <WiFi.h>
#include <DHT.h>
// Define DHT sensor type and pin
#define DHTPIN 4 // GPIO4 is connected to the DHT sensor
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(115200); // Initialize serial communication
dht.begin(); // Initialize the DHT sensor
Serial.println("ESP32 with DHT11 Example");
}
void loop() {
// Read temperature and humidity from the DHT sensor
float humidity = dht.readHumidity();
float temperature = dht.readTemperature();
// Check if the readings are valid
if (isnan(humidity) || isnan(temperature)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// Print the readings to the serial monitor
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.print("% Temperature: ");
Serial.print(temperature);
Serial.println("°C");
delay(2000); // Wait 2 seconds before the next reading
}
ESP32 Not Detected by Computer:
Upload Fails or Timeout Errors:
Wi-Fi Connection Issues:
Unstable Operation or Random Resets:
By following this documentation, you can effectively utilize the ESP32 with an expansion board for a wide range of projects and applications.