Tag: esp32 arduino guide

  • ESP32 With Fingerprint Sensor: Master Complete Beginner-to-Advanced Guide (2026)

    Learn how to use an ESP32 with fingerprint sensor in this beginner-friendly guide. Setup, wiring, code, FAQs & troubleshooting for secure IoT projects.

    If you want to build a secure, fast, and modern IoT project, connecting an ESP32 with a fingerprint sensor is one of the best ways to learn authentication, embedded development, and smart security systems. Whether you’re planning a smart door lock, attendance system, or portable identity device, this guide gives you everything you need from basics to advanced integration .

    What Makes ESP32 Perfect for Fingerprint Applications?

    Before connecting a sensor, it helps to know why developers love working with ESP32.

    Here are the ESP32 features that make it great for biometric authentication:

    Wi-Fi + Bluetooth

    This allows your fingerprint system to upload logs, send alerts, or interact with apps.

    Dual-core processor

    Fast enough to process fingerprint templates quickly.

    Large memory & storage support

    Great for handling fingerprint libraries.

    Plenty of interfaces

    UART, I2C, SPI, touch pins, ADC, and more. Perfect for sensors.

    Built-in security

    Features like Secure Boot, Flash Encryption, and encrypted communication help you build safer systems.

    These esp32 security features matter a lot when you’re working with identity data.

    If you’re wondering does ESP32 have temperature sensor?
    Yes, the older ESP32 includes an internal temperature sensor, but it is inaccurate and not meant for real measurement. For accurate temperature, use an external sensor.

    Fingerprint Sensors Compatible With ESP32

    There are multiple fingerprint sensors that work smoothly with ESP32. To make your project rank on Google and to give you clarity, here is a natural explanation of each:

    a) R307 Fingerprint Sensor With ESP32

    This is one of the most popular modules. It works on UART and has good accuracy.
    Terms you’ll also find online include:

    All these refer to versions of the same module.

    b) AS608 Fingerprint Sensor With ESP32

    This one is compact, cheaper, and also UART-based.
    You may see like:

    Both are fully supported.

    c) R503 Fingerprint Sensor With ESP32

    This gives faster matching and higher accuracy.
    Often used in access control systems.

    Searchers often type:

    d) SFM Series (High-end sensors)

    Industrial-grade fingerprint modules used in biometric locks.

    You may see:

    • esp32 with sfm fingerprint sensor

    Works the same way through serial communication.

    ESP32 Interface With Fingerprint Sensor (How It Actually Works)

    Most fingerprint sensors communicate through UART (RX/TX pins).
    Here’s the simple way to think about it:

    • ESP32 sends a command → Sensor scans fingerprint
    • Sensor processes template → Returns match/no-match
    • ESP32 executes an action (open lock, record attendance, send message)

    Almost all sensors listed above follow this same logic.

    Wiring ESP32 With Fingerprint Sensors

    All modules connect almost identically:

    Fingerprint Sensor PinESP32 Pin
    VCC5V (or 3.3V depending on model)
    GNDGND
    TXRX (GPIO 16 or 17 usually)
    RXTX (GPIO 17 or 16)

    If you are using UART2 on ESP32:

    TX2 = GPIO 17  
    RX2 = GPIO 16
    

    This avoids conflict with the default USB UART.

    ESP32 Fingerprint Code

    Below is a simple ESP32 code snippet (clean and readable):

    #include <HardwareSerial.h>
    HardwareSerial Finger(2);
    
    void setup() {
      Serial.begin(115200);
      Finger.begin(57600, SERIAL_8N1, 16, 17);
      Serial.println("Fingerprint Sensor Test");
    }
    
    void loop() {
      Serial.println("Place finger...");
      delay(2000);
    }
    

    This is just a template. When using specific sensors like AS608, R503, or R307, you use their library commands for:

    • enrolling fingerprint
    • storing fingerprint
    • deleting template
    • matching pattern

    ESP32 Fingerprint Sensor Attendance System

    One of the most Googled uses is attendance tracking, so let’s explain it clearly.

    A typical esp32 fingerprint sensor attendance project includes:

    1. ESP32 + Fingerprint module
    2. Wi-Fi connection
    3. Cloud database / Google Sheet / local server
    4. OLED or esp32 7 segment display for real-time status
    5. Logs stored with timestamps

    Flow:

    1. User places finger
    2. ESP32 matches fingerprint
    3. Wi-Fi uploads attendance
    4. Data appears on your app or dashboard

    You can also connect multiple sensors in large setups because esp32 with sensors works exceptionally well thanks to its flexible GPIOs.

    ESP32 With Wi-Fi: Smarter Security Systems

    Fingerprint sensors are just one part. When paired with ESP32’s Wi-Fi capability, you unlock:

    • Remote unlock
    • Alert notifications
    • OTP verification
    • Logging to cloud
    • Integration with app UI
    • Multi-factor authentication

    In short: ESP32 lets your fingerprint system behave like a modern IoT device, not a simple hardware lock.

    Choosing the Right Fingerprint Module for ESP32

    Here’s a clean comparison to help beginners:

    SensorSpeedAccuracyCostBest For
    AS608FastGoodLowBeginners, hobby
    R307 / R307SGoodHighMediumSmart locks
    R503Very FastVery HighHigherCommercial products
    SFM SeriesIndustrialVery HighExpensiveEnterprise-grade

    Whichever you choose, all are esp32 compatible sensors.

    ESP32 Touch Sensor Example (Extra Security Layer)

    The ESP32 includes touch-sensitive pins.

    You can use a touch sensor as:

    • Wakeup trigger
    • Second authentication step
    • Mode switch (admin mode vs user mode)

    Example:

    int touchValue = touchRead(4);
    if(touchValue < 40){
      Serial.println("Touched!");
    }
    

    Combining ESP32 touch sensor + fingerprint sensor improves security.

    Adding Displays: ESP32 7 Segment Display and OLED

    If you want a simple UI without LCD screens, a 7 segment display works well.

    Use it to show:

    • Success (01)
    • Failure (00)
    • User ID (03)
    • Admin mode (99)

    ESP32-S2, ESP32-S3, Flipper Zero & Advanced Hacks

    Many advanced learners ask about esp32-s2 flipper zero.
    Quick explanation:

    • The ESP32-S2 is used in some projects related to emulation or NFC tools.
    • Flipper Zero community sometimes uses ESP boards as companion devices.
    • For fingerprint projects, ESP32-S2 can work fine, but ESP32 or ESP32-S3 is faster.

    Common Issues of ESP32 With Fingerprint Sensor

    Here are the issues beginners face and simple fixes:

    1. Sensor not responding

    • Check TX/RX reversed
    • Power sensor with 5V

    2. “No finger detected” error

    • Clean the sensor glass
    • Reduce brightness around sensor

    3. Failed to enroll fingerprints

    • Keep finger stable
    • Try different angle once

    4. ESP32 resets on fingerprint scan

    • Power supply is weak
    • Use separate 5V supply

    5. Wi-Fi disconnects during matching

    • Use dual-core tasks
    • Move fingerprint logic to a separate task

    Real-World Projects You Can Build

    Here are project ideas beginners can actually complete:

    Smart Door Lock

    ESP32 + R307 sensor + Servo + Wi-Fi alerts

    IoT Attendance System

    ESP32 + AS608 + Cloud dashboard

    Biometric Safe

    ESP32 + R503 + Solenoid

    Two-Factor Locker

    Fingerprint + ESP32 touch sensor

    Wi-Fi Enabled Access System

    Scan → Send data → Mobile app

    Each project uses the natural combination of esp32 with sensors.

    For a complete understanding of location-based IoT systems, you can also check out our in-depth GPS integration guide here: ESP32 with GPS Module
    This resource explains how to interface the ESP32 with GPS modules, optimize signal accuracy, handle real-time tracking, and build advanced navigation-based IoT projects making it a perfect companion to your fingerprint sensor project.

    Common Questions Beginners Ask

    What is an esp fingerprint sensor?

    It just means using a fingerprint sensor with ESP microcontrollers like ESP32.

    Is ESP32 fast enough for biometric systems?

    Yes. Dual-core + Wi-Fi makes it great for security projects.

    Which sensor is best for ESP32?

    For beginners: AS608
    For accuracy: R503
    For balance: R307

    Can I store fingerprints on cloud?

    Yes, but only store encrypted templates. Do not upload raw images.

    How many fingerprints can these sensors store?

    Typically 120 to 300 templates, depending on the module.

    Best Practices for High Security

    To keep your fingerprint system safe:

    • Enable HTTPS on server
    • Use ESP32 Flash Encryption
    • Use Secure Boot
    • Avoid storing raw biometric images
    • Use WPA3 Wi-Fi when possible

    These esp32 security features protect your device from basic attacks.

    Problems You Might Face With a Fingerprint Sensor

    1. Problem: Sensor Does Not Power On or LED Does Not Glow

    This is the most common issue when connecting R307 fingerprint sensor with esp32, AS608 fingerprint sensor with esp32, or even r503 fingerprint sensor with esp32.

    What Causes It

    • Not enough power from ESP32’s 3.3V pin
    • Incorrect wiring
    • Loose jumper wires
    • Faulty breadboard rails

    How to Fix It

    1. Power the sensor from 5V, not 3.3V.
    2. Connect GND firmly to ESP32 GND.
    3. Use short wires; long wires cause voltage drop.
    4. If the LED is still dead, check with a multimeter.

    Quick Tip

    Many beginners assume ESP32’s 3.3V can power everything. It cannot. High-current sensors like r307s fingerprint sensor with esp32 need stable 5V.

    2. Problem: “Sensor Not Found” or “Communication Error”

    If your serial monitor keeps printing “fingerprint sensor not responding”, your UART connection is the culprit.

    This happens with:

    • esp32 fingerprint sensor AS608
    • esp32 r503
    • esp fingerprint sensor modules

    What Causes It

    • Reversed TX and RX
    • Wrong UART baud rate
    • Using GPIO pins not compatible with UART2
    • ESP32 boot mode affected by GPIO 0/2/15 misuse

    How to Fix It

    Use this working pin setup:

    SensorESP32
    TXGPIO 16
    RXGPIO 17
    VCC5V
    GNDGND

    In code:

    Finger.begin(57600, SERIAL_8N1, 16, 17);
    

    Advanced Tip

    Using an ESP32-S2, Flipper Zero setup, or a custom DevKit?
    UART pin numbering and peripheral mapping can vary across boards.
    Always double-check your board’s datasheet to avoid mismatched connections and communication failures.

    3. Problem: ESP32 Keeps Restarting When Fingerprint Is Scanned

    Many developers face this with esp32 with r307 fingerprint sensor and as608 fingerprint sensor with esp32.

    What Causes It

    • Sudden current spike
    • Weak USB port power
    • Sensor backlight draws extra current during scan
    • Brownout detector triggered

    How to Fix It

    • Use a separate 5V power supply for the sensor
    • Connect grounds together
    • Disable brownout detector (only if safe)
    • Avoid powering ESP32 from laptop USB 2.0

    Why This Matters

    The esp32 features include strong dual-core performance, but it is sensitive to power fluctuation. Clean power = stable fingerprint matching.

    4. Problem: Fingerprint Enrollment Fails or Takes Too Long

    This happens in almost every esp32 fingerprint sensor code tutorial.

    What Causes It

    • Dirty sensor surface
    • Too bright room lighting reflecting into sensor
    • Dry fingers
    • Finger not placed consistently
    • Low-quality USB wires causing data noise

    How to Fix It

    1. Clean the sensor with microfiber cloth
    2. Ask user to wash and dry hands
    3. Shade the sensor with hand during scan
    4. Use stable 57600 baud rate
    5. Keep finger steady for 3 seconds

    For R503 and SFM Sensors

    These modules have higher DPI. They work best when fingers are placed softly, not pressed too hard.

    5. Problem: Fingerprint Matches are Inaccurate or Random

    This appears mostly with esp32 fingerprint attendance systems.

    What Causes It

    • Fingerprint template saved poorly
    • Template storage memory is corrupt
    • Using multiple sensors with one ESP32
    • ESP32 UART noise
    • Weak power supply affecting scan LED brightness

    How to Fix It

    • Delete and re-enroll templates
    • Use shielded wires
    • Move sensor away from Wi-Fi antenna
    • Keep wires below 25 cm
    • Use a good USB cable

    Pro Tip

    If building esp32 fingerprint sensor attendance, define clear instructions for end users. Most errors are due to inconsistent finger placement.

    6. Problem: “Packet Receive Error” or “Timeout”

    Seen often with:

    • esp32 interface with fingerprint sensor
    • esp32 with sensors
    • esp fingerprint sensor codes

    What Causes It

    • Incorrect baud rate
    • Damaged sensor cable
    • Weak signal level
    • Overclocking or large Wi-Fi tasks interrupting UART

    How to Fix It

    1. Use 57600 baud
    2. Avoid long Wi-Fi tasks in loop()
    3. Put fingerprint logic on Core 1
    4. Keep Wi-Fi tasks on Core 0

    Example:

    xTaskCreatePinnedToCore(fingerprintTask, "FP", 4096, NULL, 1, NULL, 1);
    

    This prevents Wi-Fi from disturbing fingerprint communication.

    7. Problem: Wi-Fi Crashes During Fingerprint Scan

    This is common in esp32 wifi sensor projects, especially when combining biometrics + internet upload.

    Why It Happens

    • Both Wi-Fi and fingerprint code compete for CPU time
    • Heap memory fragmentation
    • Using delays instead of non-blocking code

    Fix It

    • Use FreeRTOS tasks
    • Use async Wi-Fi libraries
    • Avoid delay(2000) during scanning
    • Increase stack size of fingerprint task

    Extra Tip

    Avoid excessive JSON parsing on the same core. Use lightweight byte buffers.

    8. Problem: Fingerprint Sensor Works Alone but Fails With Display

    Some people use esp32 7 segment display or OLED along with fingerprint sensors.

    What Causes It

    • I2C and UART ground loop noise
    • Power drop caused by display LED
    • Wrong I2C pull-up resistors
    • Using same pin accidentally for UART/Display

    How to Fix It

    • Keep display on I2C pins 21 and 22
    • Dedicate UART pins for the sensor
    • Use 5V for display and sensor separately
    • Combine grounds correctly

    Why It Matters

    When building a complete access system, these conflicts are extremely common.

    9. Problem: ESP32 Touch Sensor Interferes With Fingerprint Module

    If you are using an esp32 touch sensor example to add extra authentication:

    What Goes Wrong

    • Touch sensor triggers continuously
    • Sensor value changes when fingerprint LED lights up
    • Capacitive noise from power rail

    Fix It

    • Use Touch Pins 4 or 15 (stable ones)
    • Add 100nF capacitor to ground
    • Run touch code at a different sampling rate

    This helps create stable multi-factor systems.

    Q&A Troubleshooting Section

    Q1: Why does ESP32 not detect my AS608 sensor?

    Because TX/RX is reversed or you used wrong UART pins. Always use 16/17.

    Q2: Why does my R307 fingerprint sensor show “image too messy”?

    The finger is too dry or oily. Clean the sensor and try again.

    Q3: Why does the fingerprint match even when using a different finger?

    Template memory is corrupt. Delete all templates and re-enroll.

    Q4: Why does ESP32 lose Wi-Fi after fingerprint scan?

    Both tasks compete for CPU. Put fingerprint logic on Core 1.

    Q5: Why does my SFM sensor reboot ESP32?

    It draws high current. Use external 5V supply.

    Q6: Can I combine fingerprint + display + Wi-Fi + touch sensor?

    Yes. ESP32 supports many peripherals because esp32 features include multiple hardware interfaces.

    Q7: Why does R503 fingerprint sensor fail to enroll?

    Very high sensitivity. Ask user to place finger softly.

    Q8: Is ESP32 secure enough for biometric data?

    Yes, especially with esp32 security features like secure boot and flash encryption.

    Q9: Can ESP32 upload fingerprints to cloud?

    Never upload raw fingerprints. Upload only encrypted template IDs.

    Q10: Does using esp32-s2 flipper zero affect fingerprint projects?

    Not directly. But ensure compatible UART pins.

    Conclusion

    Working with esp32 with fingerprint sensor is one of the most enjoyable and practical IoT projects you can build, especially because it blends:

    • Embedded hardware
    • Security
    • Wi-Fi networking
    • Real-world use cases

    Whether you’re using R307, AS608, R503, or SFM, the process remains simple and friendly for beginners.

    And once you understand it, you can easily create advanced systems like:

    • IoT smart locks
    • Wireless attendance platforms
    • Secure access devices
    • Multi-factor authentication projects

    If you’re serious about embedded learning or planning to create your own product, this combination is one of the best ways to level up.

    FAQ: ESP32 With Fingerprint Sensor

    1. What is the easiest way to connect an ESP32 with a fingerprint sensor?

    The easiest way is to use UART pins (GPIO 16 and 17) and connect VCC to 5V. Most modules like the R307 fingerprint sensor, AS608, and R503 work immediately using the default 57600 baud rate. Good wiring and stable power solve 90% of beginner issues.

    2. Which fingerprint sensors are compatible with ESP32?

    ESP32 works with a wide range of modules, including:

    • R307 fingerprint sensor with ESP32
    • AS608 fingerprint sensor with ESP32
    • R503 fingerprint sensor with ESP32
    • SFM series fingerprint sensor

    These sensors communicate through UART, making them reliable for ESP32 projects.

    3. Why is my ESP32 not detecting the fingerprint sensor?

    This happens when TX/RX are reversed or when you use UART pins that affect the ESP32 boot mode. Always use UART2 pins (GPIO 16 for RX, GPIO 17 for TX). Ensure proper ground and a stable 5V supply.

    4. Do I need a 5V or 3.3V supply for my fingerprint module?

    Most sensors—including AS608, R307, and R503—require 5V for stable operation. Supplying 3.3V often leads to “sensor not found” errors or brownouts. ESP32’s 3.3V pin cannot provide enough current.

    5. How do I fix “Enrollment Failed” on ESP32 fingerprint sensor?

    Enrollment fails when the finger is placed too quickly, too hard, or inconsistently. Clean the sensor, ask the user to place the finger softly, and retry. Also confirm your esp32 fingerprint sensor code is using the correct baud rate (57600).

    6. Why does my ESP32 reboot when scanning a fingerprint?

    This is a classic power issue. Fingerprint sensors draw extra current when illuminating their LED. Use a strong 5V supply or a separate power source. Many developers face this with r307s fingerprint sensor with esp32 and esp32 with r307 setups.

    7. Can I build an attendance system using ESP32 and a fingerprint sensor?

    Absolutely. Many beginners create esp32 fingerprint sensor attendance systems. You can save fingerprint IDs in sensor memory and send attendance logs to the cloud using ESP32 Wi-Fi. FreeRTOS tasks help keep Wi-Fi stable during fingerprint scanning.

    8. Does ESP32 have built-in security for fingerprint projects?

    Yes. ESP32 security features like secure boot, encrypted flash, and Wi-Fi WPA2 make it suitable for biometric applications. You should still avoid uploading raw fingerprint images—only send template IDs.

    9. What libraries can I use for ESP32 fingerprint projects?

    The most common choice is the Adafruit Fingerprint library. It works with R307, AS608, and R503. For advanced SFM modules, use a UART-based custom parser. Any esp32 fingerprint code using HardwareSerial works well.

    10. Why does my fingerprint match different fingers?

    This happens when templates are saved incorrectly or when noisy wiring corrupts data. Delete all templates, use short wires, and re-enroll fingerprints. Keeping sensor wires away from Wi-Fi antenna improves accuracy.

    11. How can I improve the match accuracy of ESP32 with fingerprint sensor?

    You can improve accuracy by:

    • Re-enrolling with cleaner finger placement
    • Keeping fingers steady during capture
    • Using short, high-quality wires
    • Avoiding harsh lighting
    • Powering the sensor from 5V

    The AS608 fingerprint sensor with esp32 tends to have higher match accuracy at consistent finger pressure.

    12. Why does my ESP32 Wi-Fi lag when scanning fingerprints?

    Fingerprint scanning blocks the CPU if run inside the loop(). Fix it by running fingerprint logic on a separate FreeRTOS task. This helps avoid Wi-Fi drops when using esp32 wifi sensor features.

    13. Can I use ESP32 with a fingerprint sensor and a display together?

    Yes. You can pair it with OLED, TFT, or even an esp32 7 segment display. Keep the fingerprint sensor on UART pins and the display on I2C or SPI. Power both from 5V for stable brightness and sensor performance.

    14. Is the ESP32-S2 suitable for fingerprint sensor projects?

    Yes. But verify UART pins because esp32-s2 flipper zero and S2 dev kits route pins differently. As long as the sensor gets 5V and correct UART wiring, it works fine.

    15. Can I combine ESP32 touch sensor with fingerprint sensor for extra security?

    Yes. Many people build multi-factor authentication systems using an esp32 touch sensor example plus fingerprint scanning. Just keep touch sensing on a separate task to avoid false triggers from sensor LED noise.

    16. What is the best baud rate for fingerprint sensors on ESP32?

    Use 57600. Higher baud rates cause packet loss, especially when ESP32 Wi-Fi is active. This applies to:

    • esp32 fingerprint
    • esp fingerprint sensor
    • r503 fingerprint sensor with esp32

    17. How many fingerprints can ESP32 store?

    ESP32 itself does not store fingerprints. The fingerprint module stores templates internally.
    Typical storage:

    • R307: ~1000 templates
    • AS608: 120–150 templates
    • R503: ~200 templates

    ESP32 only stores IDs, timestamps, or cloud logs.

    18. Why does my fingerprint sensor heat up?

    Heat indicates overcurrent or shorted wiring. Double-check wiring and never power modules from ESP32’s 3.3V pin. Use the 5V VIN pin or an external supply.

  • ESP32 Static IP: 7 Powerful Ways to Easily Set a Stable IP Address

    Learn how to set ESP32 static IP easily with step-by-step tutorials. Fix ESP32 static IP issues, set WiFi and Ethernet IP, and master ESP32 networking.

    If you’re working with the ESP32 for home automation, IoT dashboards, security cameras, or any smart system, at some point you will face one annoying problem: the ESP32 keeps changing its IP address. One day your ESP32 is working fine, and the next day Home Assistant cannot reach it. Your mobile app cannot connect. Your web server breaks. Your automation fails silently.

    This happens because, by default, the ESP32 uses DHCP, where your router dynamically assigns an IP address. That means the IP might change anytime the device reboots, reconnects, or the router resets.

    The solution is simple: set a static IP.

    In this tutorial, you’ll learn everything about configuring an ESP32 static IP, regardless of the platform you use. Whether you’re working with the Arduino IDE, ESP-IDF, MicroPython, ESPHome, or Home Assistant, I will walk you through it step by step.

    We’ll also cover esp32 static ip not working issues, Ethernet static IP, AP mode fixed IP, and real examples such as esp32 cam static ip address.

    What Is a Static IP on ESP32?

    A static IP is a permanent IP address that you manually assign to the ESP32. This ensures that your device always uses the same IP every time it connects to your WiFi or Ethernet network.

    Why does this matter?

    Because many projects depend on stable communication:

    • Home Assistant dashboards
    • Local web servers
    • ESP32 security camera streaming
    • MQTT brokers
    • REST API endpoints
    • ESP32 remote sensors
    • IoT automations

    If the IP changes, you lose connection. Not fun.

    That’s why setting an esp32 static fixed IP address is almost a must for any serious project. And if you are also exploring WiFi-related setups, you can check this helpful guide on ESP32 WiFi scanning here: ESP32 WiFi Scan Tutorials
    It fits perfectly with learning how your ESP32 behaves on the network before assigning a stable IP.

    Where You Should Use a Static IP Address

    Here are the most common real-world cases:

    1. Home Assistant ESP32 Static IP

    If you add your ESP32 to Home Assistant and its IP changes, HA will show it as offline. So you must use a home assistant esp32 static ip setup to keep your sensors and ESPHome devices stable.

    2. ESPHome ESP32 Static IP

    ESPHome YAML configurations often use manual_ip: to ensure the device stays reachable.

    3. ESP32 WiFi Server

    If you host:

    • Web server
    • REST API
    • Camera feed
    • Control dashboard

    Then you must use esp32 server static ip or clients will lose access.

    4. ESP32 Websocket Server

    Websocket connections break if the IP changes.

    5. ESP32 MQTT

    MQTT brokers rely on stable client addresses.

    6. ESP32 Ethernet Projects

    If you use LAN8720 or W5500, setting esp32 ethernet static ip example is required for stability.

    Choosing the Right IP for Your ESP32

    Before jumping into code, you need to pick the correct IP address.

    Rule of thumb: choose an IP outside the DHCP range.

    Example:

    • Router DHCP range: 192.168.1.100 – 192.168.1.200
    • Good static IP choices:
      • 192.168.1.50
      • 192.168.1.60
      • 192.168.1.90

    Subnet mask:
    255.255.255.0

    Gateway:
    Your router IP (usually 192.168.1.1 or 192.168.0.1).

    DNS:
    Prefer Google DNS: 8.8.8.8 (optional but reliable)

    ESP32 Static IP Using Arduino

    Let’s start with the most common environment: Arduino IDE.

    Here is the simplest arduino esp32 set static ip code:

    #include <WiFi.h>
    
    const char* ssid = "YourWiFi";
    const char* password = "YourPassword";
    
    // Static IP configuration
    IPAddress local_IP(192.168.1.60);
    IPAddress gateway(192.168.1.1);
    IPAddress subnet(255.255.255.0);
    IPAddress dns(8.8.8.8);
    
    void setup() {
      Serial.begin(115200);
    
      if (!WiFi.config(local_IP, gateway, subnet, dns)) {
        Serial.println("Static IP failed");
      }
    
      WiFi.begin(ssid, password);
    
      Serial.print("Connecting");
      while (WiFi.status() != WL_CONNECTED) {
        delay(500);
        Serial.print(".");
      }
    
      Serial.println();
      Serial.println("Connected!");
      Serial.print("IP Address: ");
      Serial.println(WiFi.localIP());
    }
    
    void loop() {
    
    }
    

    This covers:

    • esp32 static ip address
    • esp32 wifi static ip address
    • esp32 set static ip address
    • esp32 wifi begin static ip

    Once uploaded, your ESP32 will always get 192.168.1.60.

    ESP32 Static IP Not Working? Fix It

    The most common reason esp32 static ip not working happens is incorrect configuration.

    Here are the real causes beginners face:

    1. IP Already in Use

    Use:
    arp -a
    to check connected devices.

    2. Wrong Gateway

    If your router uses 192.168.0.1, you must match it.

    3. Router Blocking Manual IP

    Some routers force devices to use DHCP.

    Fix:
    Enable Static Lease / IP Reservation in router settings.

    4. Wrong Subnet Mask

    Should be:
    255.255.255.0 for most home networks.

    5. WiFi.config() Called After WiFi.begin()

    Static IP won’t apply.

    ESP32 AP Mode Static IP

    If your ESP32 is working as a hotspot (Access Point), you can use esp32 ap mode static ip.

    WiFi.softAPConfig(
      IPAddress(192.168.4.1),
      IPAddress(192.168.4.1),
      IPAddress(255.255.255.0)
    );
    WiFi.softAP("ESP32_AP", "12345678");
    

    The default AP IP is 192.168.4.1, but you can change it.

    ESP32 CAM Static IP Address

    ESP32-CAM becomes more stable with a static IP because the camera stream breaks if DHCP changes the IP.

    WiFi.config(local_IP, gateway, subnet, dns);
    WiFi.begin(ssid, password);
    

    Most people use:
    192.168.1.200 or 192.168.1.210

    ESP32 Static IP with ESPHome + Home Assistant

    For Home Assistant users, ESPHome is common.

    Here is esp32 static ip yaml:

    wifi:
      ssid: "MyWiFi"
      password: "MyPassword"
    
      manual_ip:
        static_ip: 192.168.1.90
        gateway: 192.168.1.1
        subnet: 255.255.255.0
        dns1: 8.8.8.8
    

    This covers:

    • esphome esp32 static ip
    • home assistant esp32 static ip

    ESP32 Static IP Using MicroPython

    If you’re coding in MicroPython, here’s a simple esp32 micropython static ip example:

    import network
    
    station = network.WLAN(network.STA_IF)
    station.active(True)
    
    station.ifconfig((
      '192.168.1.80',  # static IP 
      '255.255.255.0',  # subnet
      '192.168.1.1',  # gateway
      '8.8.8.8'       # DNS
    ))
    
    station.connect("MyWiFi", "MyPassword")
    
    print(station.ifconfig())
    

    MicroPython makes IP setting straightforward.

    ESP32 Static IP in ESP-IDF

    ESP-IDF gives full control. This is the esp32 static ip idf approach:

    Key steps:

    1. Stop DHCP client
    2. Set IP info
    3. Start WiFi

    Snippet:

    tcpip_adapter_dhcpc_stop(TCPIP_ADAPTER_IF_STA);
    
    tcpip_adapter_ip_info_t ipInfo;
    IP4_ADDR(&ipInfo.ip, 192,168,1,70);
    IP4_ADDR(&ipInfo.gw, 192,168,1,1);
    IP4_ADDR(&ipInfo.netmask, 255,255,255,0);
    
    tcpip_adapter_set_ip_info(TCPIP_ADAPTER_IF_STA, &ipInfo);
    

    This is for WiFi. Ethernet uses similar logic.

    ESP32 Ethernet Static IP Example (LAN8720 / W5500)

    If you’re using Ethernet instead of WiFi, here’s an esp32 ethernet static ip example in Arduino:

    ETH.begin(1);
    ETH.config(
      IPAddress(192.168.1.55),
      IPAddress(192.168.1.1),
      IPAddress(255.255.255.0),
      IPAddress(8.8.8.8)
    );
    

    Same concept, just using Ethernet instead of WiFi.

    ESP32 Get IP Addres

    At any time, you can check your current IP:

    Serial.println(WiFi.localIP());
    

    This is handy when testing DHCP vs static IP.

    Assign Static IP to ESP32 via Router

    Some people prefer setting a MAC-based static lease in their router instead of writing code.

    This is called:

    • dhcp reservation
    • ip lease
    • assign static ip to esp32

    Steps:

    1. Log in to router
    2. Find ESP32 MAC address
    3. Reserve an IP

    Why Static IP Matters for Real Projects

    If you’ve ever built a project like:

    • Smart home sensor
    • ESP32 cam streaming live feed
    • Home security dashboard
    • MQTT-based automation
    • ESP32 web server or API
    • Home Assistant integration

    Then you already know that IP changes are your biggest enemy.

    Imagine hosting an ESP32 server at /temperature that your automation reads every minute. If the IP changes from 192.168.1.150 to 192.168.1.181, everything breaks—Home Assistant shows errors, your app becomes unreachable, and debugging becomes a headache.

    That’s why using a esp32 set static ip address or assigning static IP via your router is almost a requirement for any real world IoT deployment.

    DHCP vs Static IP – The Real Difference

    Let’s break it down in simple terms.

    DHCP (Dynamic Host Configuration Protocol)

    • Router assigns IP automatically
    • IP can change anytime
    • ESP32 doesn’t control its address
    • Great for casual use
    • Bad for servers and automation

    Static IP (Manual IP)

    • You choose a fixed IP
    • ESP32 uses it forever
    • Perfect for servers, APIs, HA, dashboards
    • Zero breakage in automation
    • More reliable

    So, if you want long-term stability, static IP is the way.

    Two Ways to Use Static IP on ESP32

    A lot of beginners get confused here. There are only two reliable methods:

    1. Set static IP inside ESP32 code

    Examples:

    • Arduino
    • MicroPython
    • ESP-IDF
    • ESPHome YAML

    This is what you did earlier.

    2. Assign static IP from Router (Static Lease)

    This is sometimes better.

    You map ESP32’s MAC address → fixed IP.

    Advantages:

    • IP never changes
    • No need to modify code
    • Works with firmware updates
    • Router handles all IP logic

    Search your router admin page for:

    • “Static IP assignment”
    • “Address reservation”
    • “DHCP reservation”
    • “Bind IP + MAC”

    Both methods work. You can choose whichever fits your setup.

    Deep Dive: ESP32 in Server Mode with Static IP

    When ESP32 acts as a server, you absolutely must use a static IP.

    Why?

    Because clients rely on the address. A web browser, mobile app, or Home Assistant all connect to the same endpoint.

    Example request:
    http://192.168.1.90/data

    If the IP changes, the entire system breaks.

    This is why you should always configure esp32 server static ip whenever you serve:

    • HTML pages
    • JSON data
    • REST API endpoints
    • WebSockets
    • Live video streams

    A stable IP makes everything predictable.

    ESP32 Static IP with Web Server Example (Arduino)

    Here’s a friendly and clean example for a web server using static IP:

    #include <WiFi.h>
    #include <WebServer.h>
    
    const char* ssid = "MyWiFi";
    const char* password = "MyPassword";
    
    IPAddress local_IP(192.168.1.60);
    IPAddress gateway(192.168.1.1);
    IPAddress subnet(255.255.255.0);
    
    WebServer server(80);
    
    void handleRoot() {
      server.send(200, "text/plain", "Hello from ESP32");
    }
    
    void setup() {
      Serial.begin(115200);
      WiFi.config(local_IP, gateway, subnet);
      WiFi.begin(ssid, password);
    
      while (WiFi.status() != WL_CONNECTED) {
        delay(500);
      }
    
      server.on("/", handleRoot);
      server.begin();
    }
    
    void loop() {
      server.handleClient();
    }
    

    This ensures your server always lives at 192.168.1.60.

    ESP32 Static IP Ethernet Setup (Deep Explanation)

    Earlier we saw a quick esp32 ethernet static ip example. Now let’s go deeper.

    You may use:

    • LAN8720 Ethernet PHY
    • W5500 SPI Ethernet module
    • Built-in ESP32-Ethernet (in ESP32-S3, ESP32-S2, some modules)

    Ethernet is far more stable than WiFi for industrial IoT.

    The logic is:

    1. Initialize Ethernet
    2. Disable DHCP
    3. Set static IP
    4. Start Ethernet

    Full example:

    #include <ETH.h>
    
    static bool eth_connected = false;
    
    void setup() {
      Serial.begin(115200);
    
      ETH.begin(
        1,       // Address
        0,       // Power pin
        23,      // MDC pin
        18       // MDIO pin
      );
    
      ETH.config(
        IPAddress(192.168.1.55),
        IPAddress(192.168.1.1),
        IPAddress(255.255.255.0),
        IPAddress(8.8.8.8)
      );
    }
    
    void loop() {
      if (ETH.linkUp()) {
        if (!eth_connected) {
          Serial.println("Ethernet Connected");
          eth_connected = true;
        }
      }
    }
    

    This example ensures Ethernet always stays at a known IP.

    ESP32 Fix IP Address Using Router Only

    Many professional developers actually prefer handling static IP at the router level.

    Why?

    • Cleaner firmware
    • Less risk of conflicts
    • Works across reboots
    • Easier maintenance

    You usually find this in router UI under “LAN Settings”.

    Here’s the required information:

    ESP32 MAC Address

    You can print it in Arduino:

    Serial.println(WiFi.macAddress());
    

    Then assign an IP like 192.168.1.77 to that MAC.

    This is known as:

    • assign static ip to esp32
    • reserved IP lease
    • static DHCP

    This method also helps when your esp32 static ip not working in code.

    ESP32 Static IP in ESP-IDF (Advanced Users)

    The ESP-IDF method gives you full control.

    Newer IDF versions use:

    esp_netif_dhcpc_stop(netif);
    esp_netif_set_ip_info(netif, &ipInfo);
    

    The older method uses:

    tcpip_adapter_dhcpc_stop()
    

    You also need to use:

    esp_netif_create_default_wifi_sta();
    esp_wifi_connect();
    

    A complete ESP-IDF static IP setup includes:

    • Creating network interface
    • Stopping DHCP
    • Configuring IP
    • Applying DNS
    • Connecting

    It feels a bit heavy for beginners, but it’s the most reliable method in professional systems.

    Why ESP32 Static IP Sometimes Fails

    Let’s break down real reasons behind esp32 static ip not working. Most people blame the code, but the issue is usually the network.

    Here’s the complete truth.

    Reason 1: IP Already Taken

    Two devices cannot share the same IP. This is the most common beginner mistake.

    Check devices on your network using:

    • Router admin
    • arp -a command
    • Network scanner apps

    Reason 2: Wrong Gateway

    If router is 192.168.0.1, but you enter 192.168.1.1, nothing will work.

    Gateways must match your network.

    Reason 3: Wrong Subnet Mask

    Most networks use:
    255.255.255.0

    But some fiber routers use:
    255.255.254.0

    Mismatch = no connection.

    Reason 4: WiFi.config() Used After WiFi.begin()

    Order matters.

    Wrong order:

    WiFi.begin();
    WiFi.config();
    

    Correct order:

    WiFi.config();
    WiFi.begin();
    

    Reason 5: Router Blocking Manual IP

    Some routers require IP reservations for manual IPs.
    Simple fix: add ESP32 MAC in Router → DHCP Reservation.

    Reason 6: DNS Missing

    If DNS is not set, internet requests fail.

    Fix:

    WiFi.config(localIP, gateway, subnet, dns);
    

    Use Google DNS: 8.8.8.8.

    Reason 7: Using IP Outside Network Range

    Example mistake:
    Router is 192.168.0.x but you assign 192.168.1.50.

    Different network = no chance of connecting.

    ESP32 AP Mode Static IP (More Details)

    The AP mode (Access Point mode) turns your ESP32 into a hotspot.

    Default AP IP is:
    192.168.4.1

    You can update it like this:

    WiFi.softAPConfig(
      IPAddress(192.168.10.1),
      IPAddress(192.168.10.1),
      IPAddress(255.255.255.0)
    );
    WiFi.softAP("ESP32_AP", "12345678");
    

    Why use AP mode static IP?

    • Offline control system
    • Robot control
    • Local WiFi mesh
    • Direct ESP32 device access without router

    It guarantees predictable access.

    ESP32 CAM Static IP: Stability Boost

    The esp32 cam static ip address setup makes your camera:

    • load faster
    • stream reliably
    • reconnect without losing IP
    • work perfectly with Home Assistant

    A recommended IP range for cameras:
    192.168.1.200–220

    Camera streams can be sensitive. If the IP changes, your RTSP or HTTP stream breaks instantly, so using a fixed IP is a common practice.

    ESPHome ESP32 Static IP: More Examples

    Here’s an advanced esp32 static ip yaml configuration:

    wifi:
      ssid: "HomeWiFi"
      password: "Password123"
    
      manual_ip:
        static_ip: 192.168.1.91
        gateway: 192.168.1.1
        subnet: 255.255.255.0
        dns1: 8.8.8.8
        dns2: 1.1.1.1
    
    api:
    ota:
    logger:
    

    Why ESPHome + static IP is powerful:

    • Works perfectly with Home Assistant
    • ESPHome devices reboot often
    • DHCP can break sensors
    • YAML is simple and human-readable
    • You control everything

    This solves home assistant esp32 static ip issues permanently.

    ESP32 Get IP Address, Gateway, and More

    You can print full IP info:

    Serial.println(WiFi.localIP());
    Serial.println(WiFi.gatewayIP());
    Serial.println(WiFi.subnetMask());
    

    Useful while testing static vs dynamic IP.

    Full Troubleshooting Guide for ESP32 Static IP

    Even experienced developers face issues with static IP. Networks vary, routers behave differently, and DHCP servers sometimes interfere. So let’s look at real-world problems and solutions.

    Problem 1: ESP32 won’t connect when static IP is used

    Possible causes:

    • Wrong gateway
    • Wrong subnet
    • IP conflict
    • DHCP still active
    • Wrong order of WiFi calls

    Fix

    Double-check:

    WiFi.config(localIP, gateway, subnet);
    WiFi.begin(ssid, password);
    

    If you reverse the order, it fails.

    Problem 2: ESP32 Static IP Not Working After Reboot

    This is very common.

    Reason:
    Your router forces DHCP for unknown devices.

    Fix

    Add ESP32 MAC address to your router’s DHCP reservation.

    Search your router page for:

    • Reserved IP
    • DHCP static lease
    • Bind IP to MAC

    This is the best long-term method to assign static ip to esp32.

    Problem 3: ESP32 connects but has no internet

    This happens when:

    • DNS not set
    • Gateway wrong
    • Router blocks manual DNS

    Fix

    WiFi.config(localIP, gateway, subnet, dns1, dns2);
    

    Use Google DNS:
    8.8.8.8
    1.1.1.1

    Problem 4: ESP32 Ethernet Static IP Not Working

    Reasons:

    • PHY not initialized
    • Wrong wiring (MDIO/MDC)
    • Static IP outside LAN
    • DHCP not disabled

    Fix

    Use this flow:

    ETH.begin();
    ETH.config(ip, gateway, subnet, dns);
    

    Check link status:

    if (ETH.linkUp()) {
        Serial.println("Ethernet Connected");
    }
    

    Problem 5: ESP32 AP Mode Static IP Not Responding

    When using esp32 ap mode static ip, clients must use the same network range.

    Example:
    If AP IP is 192.168.10.1, your phone might automatically use:

    192.168.10.x

    If not, AP will not respond.

    Fix

    Use this:

    WiFi.softAPConfig(AP_ip, AP_gateway, AP_subnet);
    

    Problem 6: ESP32 Camera Freezes Without Static IP

    The ESP32-CAM is sensitive. When IP changes, the stream drops.

    Fix

    Use a high-range stable IP like:

    192.168.1.210

    And configure static IP in router.

    Best Practices for ESP32 Static IP

    If you want your IoT system to run for years without touching it, follow these golden rules.

    1. Use Router Assigned Static IP (Recommended)

    When possible, always reserve IP from router.

    Advantages:

    • No code changes
    • Works even after firmware update
    • Prevents IP conflicts
    • Plays well with Home Assistant

    Search for:
    “DHCP Reservation” OR “Static Lease”.

    This solves nearly all esp32 static ip not working problems.

    2. Choose IPs Above DHCP Range

    Most routers assign IPs between:

    192.168.1.2 — 192.168.1.150

    So use something like:

    192.168.1.180
    192.168.1.200
    192.168.1.240

    This avoids conflicts.

    3. Use DNS from Google or Cloudflare

    This ensures stable internet.

    Good choices:

    • Google DNS: 8.8.8.8
    • Cloudflare DNS: 1.1.1.1

    4. Keep IP Settings the Same Across All ESP32 Boards

    If you deploy multiple ESP32 devices:

    • Keep subnet same
    • Keep gateway same
    • Only change last octet of IP

    Example:

    192.168.1.91  
    192.168.1.92  
    192.168.1.93  
    

    5. Print IP and Network Info During Boot

    Add:

    Serial.println(WiFi.localIP());
    Serial.println(WiFi.gatewayIP());
    Serial.println(WiFi.subnetMask());
    

    This makes debugging easy.

    6. For Home Assistant Users: Always Prefer Static IP

    If you integrate ESP32 with Home Assistant:

    • ESPHome
    • MQTT
    • HTTP sensors
    • ESP32 camera

    Then static IP is absolutely necessary.

    This solves issues with home assistant esp32 static ip always losing connection.

    7. Document Your IP Plan

    Keep a small note:

    Sensor 1: 192.168.1.90  
    Sensor 2: 192.168.1.91  
    Camera 1: 192.168.1.200  
    

    You’ll thank yourself later.

    Additional Examples

    Let’s cover a few scenarios beginners often ask about.

    ESP32 Static IP with mDNS Enabled

    You can use both static IP + mDNS.

    #include <ESPmDNS.h>
    MDNS.begin("esp32device");
    

    Then you can use:

    http://esp32device.local

    This helps when IP changes accidentally.

    ESP32 WiFi Begin Static IP Example

    Some boards behave better using:

    WiFi.begin(ssid, password, channel, bssid);
    

    If your router has bssid-locking, this improves stability.

    ESP32 Micropython Static IP Example (Simplified)

    import network
    
    sta = network.WLAN(network.STA_IF)
    sta.active(True)
    sta.ifconfig((
        '192.168.1.52',
        '255.255.255.0',
        '192.168.1.1',
        '8.8.8.8'
    ))
    sta.connect("WiFi", "Password")
    

    ESP32 Server Static IP Example (Advanced)

    If you’re hosting multiple endpoints:

    server.on("/json", handleJSON);
    server.on("/status", getStatus);
    server.on("/sensor", getSensorData);
    

    This setup requires a fixed IP so clients can always find the server.

    FAQ : ESP32 Static IP

    1. How to set static IP for ESP32?

    Use:

    WiFi.config(localIP, gateway, subnet);
    

    Then call:

    WiFi.begin(ssid, password);
    

    This sets an esp32 static ip address manually.

    2. Why is my esp32 static ip not working?

    Common reasons:

    • IP conflict
    • Wrong gateway
    • Wrong subnet
    • DNS missing
    • Wrong order of WiFi calls

    Fixing these resolves 99% of issues.

    3. How do I assign static IP to ESP32 from router?

    Go to router → DHCP Reservation → Add ESP32 MAC address → Assign IP.

    This is the safest way to assign static ip to esp32.

    4. How do I set esp32 wifi static ip address?

    Use:

    WiFi.config(localIP, gateway, subnet, dns);
    

    You can also use router-based static IP.

    5. Does ENC28J60 or LAN8720 support esp32 ethernet static ip example?

    Yes. After initializing Ethernet, use:

    ETH.config(ip, gateway, subnet);
    

    Works for both modules.

    6. Can ESP32 CAM use static IP?

    Yes. Setting esp32 cam static ip address improves video stability and prevents stream drops.

    7. What is esp32 ap mode static ip?

    In AP mode, ESP32 becomes WiFi hotspot. You can change default 192.168.4.1 to your own:

    WiFi.softAPConfig(AP_ip, AP_gw, AP_subnet);
    

    8. Can ESP32 static IP work in ESPHome?

    Yes. Use:

    manual_ip:
    

    This is the recommended esphome esp32 static ip method.

    9. How to write esp32 static ip yaml for Home Assistant?

    Example:

    manual_ip:
      static_ip: 192.168.1.91
    

    Perfect for home assistant esp32 static ip integration.

    10. How do I get ESP32 IP address?

    Use:

    WiFi.localIP();
    

    This returns the current IP.

    11. Can I use esp32 static ip idf in production?

    Yes. ESP-IDF allows low-level control for industrial IoT.

    12. What is the best way to fix esp32 static fixed ip address conflicts?

    Use an IP above the DHCP pool, like:

    192.168.1.200.

    13. Does esp32 server static ip improve reliability?

    Yes. A server must have a fixed IP so clients always know where to connect.

    14. Can ESP32 use static IP with MQTT?

    Absolutely. MQTT dashboards work better with a esp32 use static ip setup.