OC
OceanRemote
Low-code IoT platform
← Back to Tutorials
← Previous Next →

Tutorial 06: Adding ESP32 Board Support

📖 What You'll Learn in This Tutorial:
  • ✓ Adding ESP32 support to Arduino IDE
  • ✓ Understanding ESP32 variants (ESP32, ESP32-S2, ESP32-S3, ESP32-C3)
  • ✓ Selecting the correct board for your ESP32 device
  • ✓ Configuring upload settings for ESP32
  • ✓ Troubleshooting common ESP32 issues

Introduction to the ESP32

The ESP32 is the more powerful successor to the ESP8266. Released by Espressif in 2016, it added Bluetooth, dual-core processing, more GPIO pins, and better analog-to-digital converters. Today, it's the go-to choice for advanced IoT projects.

🏆 ESP32 vs ESP8266:
Feature ESP8266 ESP32
Processor Single-core 80/160 MHz Dual-core 240 MHz
Bluetooth No Yes (BLE + Classic)
GPIO Pins 16 34+
Analog Inputs 1 (10-bit) 18 (12-bit)
RAM 80 KB 520 KB
Flash 4 MB (external) 4-16 MB (external)

ESP32 Board Variants

OceanRemote supports the most popular ESP32 development boards:

  • ESP32 Dev Module - The standard development board with 30 or 36 pins. Most common variant.
  • ESP32-WROOM-32 - The original ESP32 module with 4MB flash.
  • ESP32-WROVER - Includes 4MB PSRAM for larger applications.
  • ESP32-S2/S3/C3 - Newer variants with different features (USB-OTG, better security, etc.)
  • LOLIN D32 - Popular board from WEMOS.
  • NodeMCU-32S - NodeMCU-style ESP32 board.
ðŸ’Ą Recommendation:

For most projects, get a standard ESP32 Dev Module (30-pin) or ESP32-WROOM-32. They're widely available ($8-12) and fully compatible with OceanRemote.

Step 1: Add ESP32 to Arduino IDE

If you haven't already done this in Tutorial 04, here's a detailed walkthrough:

  1. Open Arduino IDE
  2. Go to File → Preferences (Windows/Linux) or Arduino IDE → Settings (Mac)
  3. In the "Additional Boards Manager URLs" field, add the ESP32 URL:
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

If you already have the ESP8266 URL, separate them with a comma:

https://raw.githubusercontent.com/esp8266/Arduino/master/package_esp8266com_index.json,https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
  1. Click OK
  2. Go to Tools → Board → Boards Manager
  3. Search for "esp32"
  4. Find "esp32 by Espressif Systems" and click Install
  5. Wait for installation to complete (5-10 minutes - the package is large ~500MB)
⚠ïļ Large Download:

The ESP32 package is about 500MB and can take 5-10 minutes to download on slower connections. Be patient!

Step 2: Selecting Your ESP32 Board

After installation, you'll see many ESP32 board options. Here's what to select for OceanRemote:

For Generic ESP32 Dev Module (Most Common)

  • Go to Tools → Board → ESP32 Arduino
  • Select "ESP32 Dev Module"
  • This works with 95% of generic ESP32 boards

For ESP32-WROOM-32

  • Select "ESP32-WROOM-32 Module"

For NodeMCU-32S

  • Select "NodeMCU-32S"

For LOLIN D32

  • Select "LOLIN D32"
🔧 Which board to choose?

If you're unsure, select "ESP32 Dev Module". It works with almost all ESP32 boards. The main difference between options is the default flash size and partition layout.

Step 3: Configuring Board Settings

Once you've selected your board, configure these settings:

  • Upload Speed: 921600 (or 115200 for better reliability)
  • CPU Frequency: 240 MHz (WiFi/BT) - Full speed with radio
  • Flash Size: 4MB (32Mb) or match your board's flash
  • Partition Scheme: Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS)
  • Core Debug Level: None
  • PSRAM: Disabled (unless your board has PSRAM, then enable)
  • Arduino Runs On: Core 1 (leaves Core 0 for WiFi stack)
  • Events Run On: Core 1
  • Erase All Flash Before Sketch Upload: Disabled (only enable if you need to clear everything)
  • Port: Select your COM port (Windows) or /dev/cu.usbserial-* (Mac) or /dev/ttyUSB0 (Linux)
ðŸ’Ą Pro Tip:

If you're using a board with PSRAM (like ESP32-WROVER), set PSRAM: Enabled. This gives you extra memory for large applications.

Step 4: Installing Required Libraries for ESP32

OceanRemote firmware requires these libraries for ESP32:

  1. Go to Sketch → Include Library → Manage Libraries
  2. Search for and install each library:
  • ArduinoJson by Benoit Blanchon (version 6.x) - Required for all devices
  • DHT sensor library by Adafruit - Required only if using DHT22 sensor
  • Adafruit Unified Sensor - Dependency for DHT library
  • OneWire by Jim Studt - Required only if using DS18B20 sensor
  • DallasTemperature by Miles Burton - Required only if using DS18B20 sensor
📚 Library Notes:

The ESP32 has built-in support for the DHT library. No special configuration needed.

Step 5: Testing Your ESP32

Before flashing OceanRemote firmware, test your setup with a simple blink sketch:

// ESP32 Blink Test
// The built-in LED is usually on GPIO2

void setup() {
  pinMode(2, OUTPUT);
  Serial.begin(115200);
  Serial.println("ESP32 is alive!");
}

void loop() {
  digitalWrite(2, HIGH);   // LED ON (on many boards)
  delay(1000);
  digitalWrite(2, LOW);    // LED OFF
  delay(1000);
}
  1. Copy the code above into Arduino IDE
  2. Select your board (Tools → Board → ESP32 Arduino → ESP32 Dev Module)
  3. Select your port (Tools → Port)
  4. Click Verify (checkmark) to compile
  5. Click Upload (right arrow)
  6. Open Serial Monitor (Tools → Serial Monitor) at 115200 baud
  7. You should see "ESP32 is alive!" and the LED blinking
⚠ïļ Troubleshooting ESP32 Upload Issues:
  • "Failed to connect to ESP32: Timed out" - Hold the BOOT button on your board while uploading, then press EN/RST after upload starts
  • "A fatal error occurred: Failed to connect to ESP32" - Check your port selection and USB cable
  • "Invalid head of packet" - Lower upload speed to 115200
  • "Uploading stub... Failed to write to target RAM" - Press and hold BOOT button until you see "Connecting..." then release
  • Board not recognized - Install CP2102/CH340/FTDI drivers (Windows only)

ESP32 Pin Reference for OceanRemote

When generating firmware, OceanRemote uses these default pin mappings for ESP32:

Relay GPIO Pin Notes
Relay 1 GPIO2 Built-in LED on many boards
Relay 2 GPIO4 Safe to use
Relay 3 GPIO5 Safe to use
Relay 4 GPIO12 Safe to use
Relay 5 GPIO13 Safe to use
Sensor (DHT/DS18B20) GPIO15 Connect data pin here
NTC Thermistor GPIO34 (ADC1_CH6) Analog input pin
🔌 Important ESP32 Pin Notes:
  • GPIO0, GPIO2, GPIO5, GPIO12, GPIO15 - Have pull-up/down resistors at boot, use with caution
  • GPIO34, 35, 36, 39 - Input only pins (no output)
  • GPIO6-11 - Connected to internal flash, avoid using
  • GPIO16, 17 - Used for PSRAM if enabled
ðŸ’Ą Best GPIOs for Relays:

For reliable operation, use GPIO2, GPIO4, GPIO5, GPIO12, GPIO13, GPIO14, GPIO15, GPIO18, GPIO19, GPIO21, GPIO22, GPIO23, GPIO25, GPIO26, GPIO27, GPIO32, GPIO33.

ESP32 Special Features

The ESP32 has several advanced features that OceanRemote takes advantage of:

  • Dual-Core Processing - The ESP32 has two cores. OceanRemote runs WiFi on Core 0 and your application on Core 1 for better performance.
  • Bluetooth - Future OceanRemote versions may support Bluetooth control.
  • Deep Sleep - For battery-powered projects, the ESP32 can go into deep sleep (ΞA range) and wake on timer or external trigger.
  • Touch Sensors - The ESP32 has built-in capacitive touch sensors on several pins.
  • Hall Effect Sensor - Built-in magnetic field sensor.

Next Steps

Now that your ESP32 is ready, continue with:

  • Tutorial 07: Setting Up Raspberry Pi Pico W
  • Tutorial 08: Installing Required Libraries (detailed)
  • Tutorial 09: Configuring Board Settings (detailed)
  • Tutorial 12: ESP32 Pinout and Wiring Guide
ðŸŽŊ You're Ready!

Your ESP32 is now configured. Return to Tutorial 02 to generate and flash your first OceanRemote firmware!