ESP32-CAM: Set Access Point (AP) for Web Server (Arduino IDE)

This tutorial shows how to set your ESP32-CAM as an Access Point (AP) for your web server projects. This way, you don’t need to be connected to a router to access the web server. We’ll program the ESP32-CAM using Arduino IDE.

ESP32-CAM Set Access Point AP for Web Server Arduino IDE

Access Point vs Station

In previous ESP32-CAM web server projects, we connect the ESP32-CAM to a wireless router. In this configuration, we can access the ESP32-CAM board through the local network.

In this scenario, the router acts as an access point and the ESP32-CAM board is set as a station. So, you need to be connected to your router (local network) to control and access the ESP32-CAM web server.

ESP32-CAM Station connects to Router

In some cases, this might not be the best configuration (when you don’t have a router nearby). But if you set the ESP32-CAM boards as an access point (hotspot), you can be connected using any device with Wi-Fi capabilities without the need to connect to your router.

ESP32-CAM set as a Soft Access Point

Basically, when you set the ESP32-CAM as an access point you create its own Wi-Fi network and nearby Wi-Fi devices (stations) can connect to it (like your smartphone or your computer).

Soft Access Point

Because the ESP32-CAM doesn’t connect further to a wired network (like your router), it is called soft-AP (soft Access Point).

This means that if you try to load libraries or use firmware from the internet, it will not work (like including JavaScript libraries). It also doesn’t work if you try to make HTTP requests to services on the internet (like sending an email with a photo, for example).

ESP32-CAM Video Web Server Access Point (AP)

In this tutorial, we’ll show you how to set the ESP32 as an access point. As an example, we’ll modify the CameraWebServer project that comes with the Arduino IDE. Then, you should be able to modify any of your projects to set the ESP32-CAM as an access point.

In your Arduino IDE, go to File > Examples > ESP32 > Camera > CameraWebServer.

Then, modify the code to act as an access point as we’ll explain.

Customize the SSID and Password

You need to define an SSID name and a password to access the ESP32-CAM access point. In this example we’re setting the ESP32 SSID name to ESP32-CAM Access Point. You can modify the name to whatever you want. The password is 123456789, but you can and should also modify it.

const char* ssid = "ESP32-CAM Access Point";
const char* password = "123456789";

Setting the ESP32-CAM as an Access Point

In the setup(), remove the following lines (set the ESP32 as a station):

WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
  delay(500);
  Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");

And add the following to set the ESP32 as an access point using the softAP() method:

WiFi.softAP(ssid, password);

There are also other optional parameters you can pass to the softAP() method. Here’s all the parameters:

softAP(const char* ssid, const char* password, int channel, int ssid_hidden, int max_connection)
  • ssid (defined earlier): maximum of 63 characters;
  • password (defined earlier): minimum of 8 characters; set to NULL if you want the access point to be open
  • channel: Wi-Fi channel number (1-13)
  • ssid_hidden: (0 = broadcast SSID, 1 = hide SSID)
  • max_connection: maximum simultaneous connected clients (1-4)

This is what you need to include in your web server sketches to set the ESP32-CAM as an access point.

You can download the complete code here.

Connecting to the ESP32-CAM Access Point

After uploading the code, you can connect to the ESP32-CAM access point to access the web server. You don’t need to connect to a router.

In your smartphone open your Wi-Fi settings and tap the ESP32-CAM Access Point network:

Connect to ESP32-CAM Access Point Smartphone

Type the password you’ve defined earlier in the code.

Connect to ESP32-CAM Access Point Smartphone Insert Password

Open your web browser and type the IP address 192.168.4.1. The video streaming web server page should load:

Video Streaming Web Server ESP32-CAM Access Point


To connect to the access point on your computer, go to the Network and Internet Settings, select the “ESP32-Access-Point“ and insert the password.

Connect to ESP32-CAM Access Point Computer

And it’s done! Now, to access the ESP32-CAM web server page, you just need to type the IP address 192.168.4.1 in your browser.

Wrapping Up

In this tutorial you’ve learned how to set the ESP32-CAM as an access point in your web server sketches. When the ESP32 is set as an access point, devices with Wi Fi capabilities like your smartphone can connect directly to the ESP without the need to connect to a router.

If you like the ESP32-CAM, take a look at our resources:

Thanks for reading.



Learn how to build a home automation system and we’ll cover the following main subjects: Node-RED, Node-RED Dashboard, Raspberry Pi, ESP32, ESP8266, MQTT, and InfluxDB database DOWNLOAD »
Learn how to build a home automation system and we’ll cover the following main subjects: Node-RED, Node-RED Dashboard, Raspberry Pi, ESP32, ESP8266, MQTT, and InfluxDB database DOWNLOAD »

Recommended Resources

Build a Home Automation System from Scratch » With Raspberry Pi, ESP8266, Arduino, and Node-RED.

Home Automation using ESP8266 eBook and video course » Build IoT and home automation projects.

Arduino Step-by-Step Projects » Build 25 Arduino projects with our course, even with no prior experience!

What to Read Next…


Enjoyed this project? Stay updated by subscribing our newsletter!

90 thoughts on “ESP32-CAM: Set Access Point (AP) for Web Server (Arduino IDE)”

  1. This is a very interesting post. I can think of some agriculture projects, where distances are large and connectivity is an issue.

    Is it possible for the ESP32-CAM to detect that a new device has connected to it’s WiFi, identify the IP assigned, and then execute some code? For example, send a picture or some data to an Android device. I know this could be done the other way round, the Android device pulling information from the ESP32, but I would like to see how much can be automated.

    Congrats for all your posts!

    Reply
  2. This so much better than using a wifi router, to be able to just log into the camera directly without wifi it could be used anywhere so would love to make one. I think it is the way to go with no wifi for the door and window sensors plus other sensor boards that don’t have to rely on wifi, ESPNow is the way to go

    A very nice project well done you are a very clever person

    Thanks, Bob

    Reply
      • E (494) esp_core_dump_flash: No core dump partition found!

        Brownout detector was triggered

        ets Jul 29 2019 12:21:46

        rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
        configsip: 0, SPIWP:0xee
        clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
        mode:DIO, clock div:1
        load:0x3fff0030,len:1344
        load:0x40078000,len:13924
        ho 0 tail 12 room 4
        load:0x40080400,len:3600
        entry 0x400805f0
        E (494) esp_core_dump_f�f��� No core dump partition found!
        E (494) esp_core_dump_flash: No core dump partition found!

        Camera Ready! Use ‘http://0.0.0.0’ to connect

        Reply
          • You ask me which I have selected. Up to now, I have selected the “ESP32 DEv Module”, but your question push me to try other boards : ESP32S for instance, but there are ESP32S2 and ESP32S3 ? My board is just written as ESP32S. I will try both.

          • Your question suggested me to ry other boards thna “ESP32 Dev Module” and I did that this morning.
            Trying the” ESP32S2 Dev Module” or “ESP32S3 Dev Module” doesn’t work at all. I get the a fatal error concerning the data transfer. I have tried several times and got the same error, just on Connecting …. even when I press the reset button.
            Coming back to ESP32 Dev Module is the only way to have it working, but with allways the same error when running.
            Perhaps I can send a copy of my sketch if I have done something wrong going from website on the network to the some in AP mode.

          • Hi.
            Try selecting “ESP32 DEv Module”.
            Then, go to Tools and select the following settings:
            – Flash size: 4MB (32Mb)
            – Partition scheme: “Huge App (3MB no OTA/1MB SPIFFS)

            Let me know if this solves the issue.
            Regards,
            Sara

          • Hi, I have tried your suggestion :
            Try selecting “ESP32 DEv Module”.
            Then, go to Tools and select the following settings:
            – Flash size: 4MB (32Mb)
            – Partition scheme: “Huge App (3MB no OTA/1MB SPIFFS)
            The only change is the partition scheme, as I had already choosen “ESP32 Dev Module” and the Flash size is 4MB by default.
            I get again the same error message. I cannot any change.
            I ordered yesterday two new ESP32-CAM, as I have a lot of projects running and I will test with these new boards. Perhaps my board is simply defective …
            Thanks for your help.

          • I have tested again with ESP8266, as it was also working connected to my network, but not in AP mode.
            Now, I get ESP8266 working fine in AP mode. The SSID is not correct : I get a FaryLink_64D1A9 without any password while I have written “Jumpy” as SSID and given a password. That’s strange, but I don’t really need to protect the AP point in this project.
            I will try tomorrow this sketch with ESP32-CAM as this is my goal, but I don’t have it on my desk today.
            I had probably make a mistake on my first tests, but I cannot find what it was …
            I keep you informed.

          • I have received two new ESP32-CAM and tried them in AP mode, as it was not working with the preceding one.
            First, I think they have a new bios as I don’t need now to press the reset button when I upload. That’s very nice.
            But when running the sketch, I get again the same error code :
            Connecting to JUMPY
            assert failed: tcpip_send_msg_wait_sem IDF/components/lwip/lwip/src/api/tcpip.c:455 (Invalid mbox)

            Backtrace: 0x400837c1:0x3ffb1fc0 0x4008cb85:0x3ffb1fe0 0x400924a5:0x3ffb2000 0x400ea272:0x3ffb2130 0x400fa4cd:0x3ffb2160 0x400fa52d:0x3ffb2180 0x400e9a65:0x3ffb21d0 0x400d4a79:0x3ffb21f0 0x400d4b08:0x3ffb2240 0x400d2885:0x3ffb2260 0x400d585e:0x3ffb2290
            ELF file SHA256: 351527ba9a25fcb3

            Rebooting…
            I have tried some other boards in “Tools” but they usually not finish compiling, as they my boards are not the right ones, or they give same error result.
            Do you know if some people are succeeding to run in AP mode with ESP32-CAM ? For me, I run AP mode with ESP8266 but I cannot take pictures with it …
            Thanks for your help

          • At first, did you by the ESP32-Cam with programming board? If so, it is normal that you don’t need to press the reset button because the ESP32 has an changed layout and one of the pins is now reset so that the programming board can reboot the ESP32-Cam. But, this works only with the boards with changed layout.
            At second, yes, i’m using the ESP32-CAM in AP-Mode and if you look in one of my old answers:
            “tiff
            October 24, 2022 at 11:38 am”
            you can see my running code.
            But, in some earlyer posts from you there was a clear sign of a brownout. Whatever you do, solve this or the wifi stage of the chip will not work reliable.

          • Hi.
            What are the ESP32-CAM boards you’re using?
            What board are you selecting in Tools > Board?

            I had other readers with issues settings the board as an access point…
            Regards,
            Sara

          • Hi, the boards I have are written ESP32-CAM on a side and
            ESP32-S
            FCCID:2AHMR-ESP32S on the shield on the other side.
            I have loaded esptool.py to check the version of each board, but I cannot find out how to tell the USB port. It is not the same as in Arduino IDE, I mean it is not ttyUSB0 …
            I have ordered a USB HUB to boost the power provided to the ESP. I hope this will solve this issue.
            Thanks for your help.

          • Hi,
            I have received the powered USB HUB and tried the ESP32-CAM in AP mode and it works, at end.
            So, you are right : ESP32-CAM needs at least 4.98V to work in AP mode. Issue is not when working in WIFI, as it worked when connected to my network. Issue is only in AP mode.
            I don’t understand that, as connecting to WIFI in a mode or an other needs probably the same power !!
            Thanks for your help, and I think you can close this dicussion.

  3. Very nice project. however, I have a question. Is it possible to change the defaut SoftAP IP adress because I can see it is always 192.168.4.1.
    Thanks a lot

    Reply
    • Hi.
      You can do something like this:

      WiFi.mode(WIFI_AP);
      WiFi.softAP(ssid, password);
      delay(100);

      IPAddress Ip(192, 168, 1, 1); //your desired IP address
      IPAddress NMask(255, 255, 255, 0);
      WiFi.softAPConfig(Ip, Ip, NMask); //set the IP address

      I hope this helps.
      Regards,
      Sara

      Reply
  4. Hi,
    Great project. I got it working right away and I can access it from my cellphone ok. However, this may be obvious to you all but I always get the setup page with all the switches, which is fine, but I want to just get the picture showing (no setup switches…).
    In other words, do all the setup once, add them into the app and not show them, just the CAM screen. Thanks.
    Jacob

    Reply
  5. Hi,
    I have uploaded the file to the esp32-cam successfully however when compiling, I get the following error: ‘box_array_t {aka struct tag_box_list}’ has no member named ‘score’

    Any thoughts?
    D

    Reply
  6. Congratulation for the great tutorial. I found this very useful and easy to implement. Would you please extend the feature to save the video stream to sd card

    Thank you

    Reply
  7. The knockoff camera XRZ00D1 does in fact work with this code as is but it seems like a lot of these cameras are defective.

    Reply
  8. I had a hard time understanding where the actual html was coming from when I first started messing with the ESP32Cam boards. I spent way too long trying to understand how the hex data in “camera_index.h” was a web page so I tried an experiment that worked for me and wanted to pass it on.
    I used a program called “PsPad” installed with the hex editor option and “7zip” and since I am using Windows 7 I also used Notepad.
    What I discovered:
    As it turns out, the webpage being presented was being sent as html but it was being decoded first. This was apparent since there is no substantial html code in this example. When I opened the code and got it uploaded to my ESP32 Cam board, it worked first time and I was elated. Then I started looking for ways to customize/hack the code to suit my needs but I couldn’t find any html code. I did however find where they were sending the html. This code is currently setup to support two different cameras, the OV2640 and the OV3660. I found this in the same location within the code that I found the key to their html. Currently that is in app_httpd.cpp lines 580-589. If it gets shifted around just search this tab file for “httpd_resp_send” and it should put you in the middle of it.
    You’ll notice above this line that they send a line as a response to a webpage request that should look familiar to anyone familiar with html.
    httpd_resp_set_type(req, “text/html”);
    The “text/html” was the line that opened all the doors for me. But then I noticed the second line and I thought I was going to be stuck.
    httpd_resp_set_hdr(req, “Content-Encoding”, “gzip”);
    Gzip encoding? hmmm. Okay that’s new to me for web page presentation. As I kept reading the subsequent lines I noticed that they were basically calling a large character block of data in the form of the variable “index_ov3660_html_gz” or “index_ov2640_html_gz” with an indeterminate length (*) of “index_ov3660_html_gz_len” or “index_ov2640_html_gz_len”.
    If you look in the tab “camera_index.h” you’ll see these lines at the top of the page:
    #define index_ov2640_html_gz_len 4316
    const uint8_t index_ov2640_html_gz[] = {
    What follows however is not html (Yet). It is actually the html however it has been compressed using GNU Zip and is expanded when it is sent as a response to your html page request.
    But now I ran into the problem of seeing what that code is. In my case it was simple. I use many different editors for different things but this was where PsPad came to the rescue. I’m going to try to explain it so maybe you can use this method. Be aware that I have no idea if there is another method or an easier method but this one works for me every time.
    Decoding and formatting the Hex:
    1) In the Arduino IDE click on the camera_index.h tab and highlight ONLY the hex data BETWEEN THE BRACKETS { } of this section of code (lines 5-274).
    2) Open up a no frills editor like Notepad and paste it and save it. You don’t want an editor that is going to assume it knows what kind of file you have opened and then tries to format or change it in any way.
    3) Using Notepad press Ctrl-H and enter “0x” (zero x) without the quotes in the “Find what” line and leave the “Replace with” line blank. This will remove all occurrences of 0x from the file.
    4) Now press Ctrl-H and enter a comma in the “Find what” line and leave the “Replace with” line blank. This will remove all occurrences of “,” from the file.
    5) Save the file for good measure.
    6) Press Ctrl-A to highlight all the data in this file and then press Ctrl-C to copy it to your clipboard.
    7) Close the file.
    8) Now open this file with “PsPad(hex)”. This is a special hex editor that PsPad has as an installation option that I have honestly very rarely used or needed. When you open it in this mode it will not read the file right since it is actually text at the time so you’ll need to replace the contents of this file with what is in your clipboard. To do this:
    9) Press Ctrl-A then Ctrl-V to paste your clipped data into the file.
    10) Use “Save As” to save the file as whatever filename you choose but change the extension to “.gz”
    Now you have the html file saved in a separate file in compressed GNU Zip format.
    I used 7zip to open it but I think WinZip will read it as well. Windows “Extract” is clueless however.
    When you open the .gz file it should contain a compressed file called “index_ov2640.html”.
    Extract the file and you’ll see that it is merely an html file with a whole lot of CSS and some script which looks like it may be JavaScript. The CSS and the JavaScript are “minified” so if you want to make them more readable that is a whole different process I’m not going to go into. You now have the html decoded so from here on you are on your own.
    There is more to the “camera_index.h” file and you can do the same to the rest of it in this same manner. Just remember to only use the data BETWEEN THE BRACKETS { } as the contents of your .gz file.
    Hope this helps even though it is long winded and maybe cumbersome for some but it also works every time, so far (knock on wood).

    Reply
  9. Hello and thatk you for all the GREAT tutorials!!

    I have one issue with this (otherwise perfect) project.

    For me the meaning of this project is to be able to have a standalone camera without the need for “real internet”.

    The problem is that though the project works while the ESP is connected to the FTDI, once I disconnect it and just give it power, it fails to become an access point. So I can’t e.g. power it through my car and watch through my cellphone.

    It seems it needs the FTDI to work.. Why? Am I missing something?

    Reply
  10. Hi! Thank you for the great tutorials and for answering comments! All projects are very interesting.

    I am having an issue with this one though. It works flawlessly as long as I have the CAM connected to the FTDI and the PC.
    Once I disconnect and make it standalone with only power provided to the CAM, it fails to “emit” the Access Point. I have tried various power units with enough amperage, so I think I can rule lack of power out.

    Any ideas? Thank you in advance!

    Reply
    • Hi.
      How are you powering the ESP32-CAM?
      You’re probably not powering the ESP32-CAM correctly.
      Additionally, after powering the board, press the RST button so it starts running the code.
      Regards,
      Sara

      Reply
  11. Problem solved. I raised my buck converter Vout to 5.2Volt. Now all works normally. Be careful if you do this. You might burn stuff up.

    Reply
  12. Hi Guys, Thanks for another great project that worked for me first time.
    The only issue I have is that although I set a new SSID and password in the code when I searched on my iPhones WiFi screen the ESP32-Cams WiFi SSID came up as something completely different. It showed as ESP_F8Exxx (The x’s were numbers)
    I was then able to connect to the IP address 192.168.4.1 without needing to enter a password and my camera stream was viewable.
    I’m worried that this is completely unsecure.
    Do you know why this occurred?
    Regards

    Reply
    • Haha! I’ve just solved my own issue. I had only 6 characters in my password originally. You actually need 8 characters. When I changed my password to 8 characters the ssid came up on my list of wifi access points on my phone and it did require me to input my password to gain access to the camera. Pat on the back for me.

      Reply
  13. Thanks, Awesome tutorial!

    I have used info from several of your excellent tutorials to set up an ESP32 as an Access point. I also have 3 ESPCams in Station mode connecting to the Access point. I have the Access point set up as 192.168.4.1, when you log on to 192.168.4.1, an HTML page displays a message telling you the IP addresses of the connected cameras. The cameras are at 192.168.4.190, 195, & 200. I can access any of the cameras with a device connected to the AP. I would like to build a web page on the AP that has the ability to display all 3 cameras at once, and displays this combined view on 192.168.4.1.

    Is this possible?

    (I have watched 2 feeds at once, by bringing up 2 different web browser windows, but, it is clumsy, and easy to lose a window, but, two feeds at once seems to work fine.)

    A combined view would be preferable, and you could still view each camera seperately, if you wanted.

    Reply
    • Actually, I have now tried with all three camera feeds running through the AP, and have switched out the ESP32 Dev Board (The AP) to an ESPCAM as well (Because it is easy to connect a larger antenna to an ESPCam) The ESPCam AP seems to easily handle serving all 3 cameras, just need to find a solution to combine all 3 feeds to one web page (Web page should becCreated on the ESPCam AP, so any device with web capability can see the output?)
      Any solution?

      Reply
  14. Hi, to be honest, it is actually very easy to use the ESP32-Cam in Station and AP Mode at the same time. This has advantages and disadvantages. The biggest disadvantage is that AP and Station mode are bond together because of the very limiteted hardware. They share the same rf-part and so share the frequency what limits throughput. But that is also an advantage because of no time loss and no loss of packets. Theoretical.
    If someone is interested i can share the changes, if not, thanks for your time.

    Reply
    • I have been trying to use my ESP32-cam in station mode and AP mode at the same time with no joy. I would really appreciate if you could show me the changes I need to make to the code. Thanks

      Reply
      • I did not forget you, i had to search for the code. 🙂

        #include “esp_camera.h”
        #include <WiFi.h>

        //
        // WARNING!!! PSRAM IC required for UXGA resolution and high JPEG quality
        // Ensure ESP32 Wrover Module or other board with PSRAM is selected
        // Partial images will be transmitted if image exceeds buffer size
        //

        // Select camera model
        //#define CAMERA_MODEL_WROVER_KIT // Has PSRAM
        //#define CAMERA_MODEL_ESP_EYE // Has PSRAM
        //#define CAMERA_MODEL_M5STACK_PSRAM // Has PSRAM
        //#define CAMERA_MODEL_M5STACK_V2_PSRAM // M5Camera version B Has PSRAM
        //#define CAMERA_MODEL_M5STACK_WIDE // Has PSRAM
        //#define CAMERA_MODEL_M5STACK_ESP32CAM // No PSRAM
        #define CAMERA_MODEL_AI_THINKER // Has PSRAM
        //#define CAMERA_MODEL_TTGO_T_JOURNAL // No PSRAM

        #define Station
        //#define AP

        #include “camera_pins.h”

        //remember, wlan password and SoftAP password have to have a length of at least 8 signs
        const char* ssid = “your_own_wlan_ssid”;
        const char* password = “your_wlan_password”;
        const char *soft_ap_ssid = “ESP32Cam”;
        const char *soft_ap_password = “your_esp32_cam_softap_password”;

        //remember, they share the same frequency/channel so the speed is limited to less then the half of normal speed because of overhead and frequency usage

        void startCameraServer();

        void setup() {
        Serial.begin(115200);
        Serial.setDebugOutput(true);
        Serial.println();

        camera_config_t config;
        config.ledc_channel = LEDC_CHANNEL_0;
        config.ledc_timer = LEDC_TIMER_0;
        config.pin_d0 = Y2_GPIO_NUM;
        config.pin_d1 = Y3_GPIO_NUM;
        config.pin_d2 = Y4_GPIO_NUM;
        config.pin_d3 = Y5_GPIO_NUM;
        config.pin_d4 = Y6_GPIO_NUM;
        config.pin_d5 = Y7_GPIO_NUM;
        config.pin_d6 = Y8_GPIO_NUM;
        config.pin_d7 = Y9_GPIO_NUM;
        config.pin_xclk = XCLK_GPIO_NUM;
        config.pin_pclk = PCLK_GPIO_NUM;
        config.pin_vsync = VSYNC_GPIO_NUM;
        config.pin_href = HREF_GPIO_NUM;
        config.pin_sscb_sda = SIOD_GPIO_NUM;
        config.pin_sscb_scl = SIOC_GPIO_NUM;
        config.pin_pwdn = PWDN_GPIO_NUM;
        config.pin_reset = RESET_GPIO_NUM;
        config.xclk_freq_hz = 20000000;
        config.pixel_format = PIXFORMAT_JPEG;

        // if PSRAM IC present, init with UXGA resolution and higher JPEG quality
        // for larger pre-allocated frame buffer.
        if(psramFound()){
        config.frame_size = FRAMESIZE_UXGA;
        config.jpeg_quality = 10;
        config.fb_count = 2;
        } else {
        config.frame_size = FRAMESIZE_SVGA;
        config.jpeg_quality = 12;
        config.fb_count = 1;
        }

        #if defined(CAMERA_MODEL_ESP_EYE)
        pinMode(13, INPUT_PULLUP);
        pinMode(14, INPUT_PULLUP);
        #endif

        // camera init
        esp_err_t err = esp_camera_init(&config);
        if (err != ESP_OK) {
        Serial.printf(“Camera init failed with error 0x%x”, err);
        return;
        }

        sensor_t * s = esp_camera_sensor_get();
        // initial sensors are flipped vertically and colors are a bit saturated
        if (s->id.PID == OV3660_PID) {
        s->set_vflip(s, 1); // flip it back
        s->set_brightness(s, 1); // up the brightness just a bit
        s->set_saturation(s, -2); // lower the saturation
        }
        // drop down frame size for higher initial frame rate
        s->set_framesize(s, FRAMESIZE_QVGA);

        #if defined(CAMERA_MODEL_M5STACK_WIDE) || defined(CAMERA_MODEL_M5STACK_ESP32CAM)
        s->set_vflip(s, 1);
        s->set_hmirror(s, 1);
        #endif

        WiFi.mode(WIFI_MODE_APSTA);

        WiFi.softAP(soft_ap_ssid, soft_ap_password);
        WiFi.begin(ssid, password);

        while (WiFi.status() != WL_CONNECTED) {
        delay(500);
        Serial.print(“.”);
        }
        Serial.println(“”);
        Serial.println(“WiFi connected”);

        startCameraServer();

        Serial.print(“Camera Ready! Use ‘http://”);
        Serial.print(WiFi.localIP());
        Serial.println(“‘ to connect”);
        Serial.print(“ESP32 IP as soft AP: “);
        Serial.println(WiFi.softAPIP());
        }

        void loop() {
        // put your main code here, to run repeatedly:
        delay(10000);
        }

        Reply
        • If that does not work, i have an heavily changed cleaned up code.
          The most impotant thing is this line:

          “WiFi.mode(WIFI_MODE_APSTA);”

          which defines that both modes can be used at the same time.

          Reply
          • Thank you kindly. It worked like a dream first time. I am now able to connect to my home network LAN and watch the image on my screen, as well as when I am away with the camera and using it as an access point and seeing the image via my phone. And best of all I do not have to change anything.
            Once again thanks for your time and solution.

          • 🙂

            It’s a good starting point to understand what is going on. If you want to.

            But, there are better solutions out there. Especially if you want to control cam. If you are interested, ask me and i drop a link. When i find him.

          • Thanks for the link. It certainly looks interesting and will keep me busy for some time. Thanks again for your help.

  15. Nice project, worked oke for me. I downloaded the “”complete code” you refer to in your text and one thing was a bit strange. The output of the serial line is in my case:

    AP IP address: 192.168.4.1
    Starting web server on port: ’80’
    Starting stream server on port: ’81’
    Camera Ready! Use ‘http://0.0.0.0’ to connect

    The last line isn’t nesessary and of no use. Lines 102-104 in the code.
    Further the code works flawlessly. Thanks for that.

    Reply
  16. I cant get this going to save my life. I’ve tried the example code with changes as directed and tried your Complete Code as well and I get the same issue – the inability to connect to the web server. The IPs are a bit confusing in actual use. The Serial Monitor says us 192.168.4.1 which cannot be found via browser on phone or on PC when connected. When connected to the ESP AP Both my phone and my PC report my IP and the ESP DNS host as 192.168.12.x NOT 4.x. So did the library change for SoftAP that uses a different Host #?

    Reply
    • Hi.
      To connect to the access point, you need to go to your device Wi-Fi settings. There, you’ll find a network called “ESP32-CAM Access Point”. You must connect to that network.
      Only after that, you open the browser and type the 192.168.4.1 IP address.
      I hope this helps.
      Regards,
      Sara

      Reply
      • Of course! I can connect but can’t get to the server webpage. Did you read my point regarding the IPs?

        Browser times out. I even tried adding the ports :80 and :81 just to be sure. Nothing!

        Reply
  17. I have tryed to compile the code and I get the following error
    \CameraWebServer_Access_Point\app_httpd.cpp:22:10: fatal error: fd_forward.h: No such file or directory
    #include “fd_forward.h”
    ^~~~~~~~~~~~~~
    compilation terminated.

    exit status 1
    IA_Thinker ESP32 Arduino IDE 2.0
    It seems the libreries have been deprecated.

    Compilation error: fd_forward.h: No such file or directory

    Reply
  18. Hi, it is great!
    I have a question zbout the IP address of 192.168.4.1, is that fixed? be able to change? where it set?
    Thanks
    Summer

    Reply
    • This is Sara’s answer to that question earlier.

      Hi.
      You can do something like this:

      WiFi.mode(WIFI_AP);
      WiFi.softAP(ssid, password);
      delay(100);

      IPAddress Ip(192, 168, 1, 1); //your desired IP address
      IPAddress NMask(255, 255, 255, 0);
      WiFi.softAPConfig(Ip, Ip, NMask); //set the IP address

      I hope this helps.
      Regards,
      Sara

      Reply
      • great!
        Thank you Ivan.
        I saw that the picture above shown a ESP32CAM AP server can be connected by nearby devices, can another ESP32CAM connect to the AP as a client and stream?
        Best.

        Reply
        • Yes. Once you have set your camera up as a server, any number of ESP32CAMs can connect to it as clients as long as they all have the password. Once connected to the server they all just enter the IP address of 192.168.4.1 (default), or the IP address you have used if not the default.

          Reply
          • Great Ivan, thank you.

            I’ll test the AP server IP config later cause of it need reload ESP32 1.0.3 Version to compiling the sketch;
            I connected ESP32CAM-b as a client to ESP32CAM-a that is server, -b be signed IP: 192.168.4.2 automatically by -a.
            my question is does this IP be signed random? or can this signed IP be config?
            Best.

          • Hi, Sorry I misunderstood. I was assuming you were connecting to the ESPCAM Server via several devices such as Mobile phones or whatever in which case it would not matter what their IPs were. I have not tried it with several ESP32CAMs setup as clients trying to connect to one ESPCAM Server. I will be interested to hear what happens when you try that. Either way I would have thought you could leave their IPs set at whatever is assigned to them automatically when they are set up but I could be entirely wrong on that. If it fails it is probably worth setting them up with individual ips all different from each other and the Server and see what happens. Cheers.

  19. Thank you Ivan.
    I did ESP32CAM-b client (let’s just call so for now) log into ESP32CAM-a AP server, I got few situations:
    1. when use stream sketch from Rui Santos, both of -a/-b works fine, but the client’s IP is vary random;
    2. when I used static IP config to -b, that seems made both -a/-b server, and the phone need log into -a/-b respectively, the both do stream well;
    3. I insert the ESP32_IP_config lines from:
    https://randomnerdtutorials.com/esp32-static-fixed-ip-address-arduino-ide/
    into the stream sketch, I did get:
    WiFi connected
    Camera Stream Ready! Go to: http://192.168.1.184

    but no stream on phone now.
    Cheers.

    Reply
    • Hi Summer. You are obviously making good progress on your project and I am sorry but I am getting way out of my depth on this and could be misleading you with completely wrong information. It certainly sounds like you are almost there and I hope you get to the final stage you are looking for. If you are like me, you have probably spent hours of trial and error with more to come. Cheers and good luck.
      Ivan

      Reply
  20. Hello, I have installed a webcam on ESP32-CAM and it works fine when using it on my box but it cannot work in AP mode. It gives an error message : assert failed: tcpip_send_msg_wait_sem IDF/components/lwip/lwip/src/api/tcpip.c:455 (Invalid mbox)
    Then, I have tried with the same ESP32-CAM to run the Web Server, also from RandomnerdTutorials and I have the same result : works on the box, but not in AP mode. Then, this issue is not related to the camera.
    As I like to test completely, I have done the same thing with an ESP8266 and then it works in both situation : on the box, and in AP mode.

    I have tried lot of things from different forums, but I cannot get ESP32-CAM working in AP mode, and it is the goal to reach as there is no Wifi box where I will install the project.
    I am quite depited, as I have learned a lot on your site to control my wood boiler and other things, and I cannot connect in AP mode.
    Many thanks if you have an idea to solve this issue.

    Reply
    • Hi.
      What is the error that you get when you try to set it as access point?
      When do you get that error? Does the error mention any line of the code?
      Regards,
      Sara

      Reply
      • Thanks for your reply. I copy there the complete message sent by ESP32. Actually, it reboots and rebbots again and again with this same message :
        Backtrace: 0x4008393d:0x3ffb1ec0 0x4008d8d1:0x3ffb1ee0 0x40093a7d:0x3ffb1f00 0x400ea36a:0x3ffb2030 0x400f90ad:0x3ffb2060 0x400f910d:0x3ffb2080 0x400e9b5d:0x3ffb20d0 0x400fd534:0x3ffb20f0 0x400d3590:0x3ffb2170 0x400d36a4:0x3ffb21f0 0x400d5572:0x3ffb2290

        ELF file SHA256: 1402afea7cdaaa35

        Rebooting…
        ets Jun 8 2016 00:22:57

        rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
        configsip: 0, SPIWP:0xee
        clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
        mode:DIO, clock div:1
        load:0x3fff0030,len:1344
        load:0x40078000,len:13924
        ho 0 tail 12 room 4
        load:0x40080400,len:3600
        entry 0x400805f0
        Connexion en AP
        Access Point actif

        assert failed: tcpip_send_msg_wait_sem IDF/components/lwip/lwip/src/api/tcpip.c:455 (Invalid mbox)

        Backtrace: 0x4008393d:0x3ffb1ec0 0x4008d8d1:0x3ffb1ee0 0x40093a7d:0x3ffb1f00 0x400ea36a:0x3ffb2030 0x400f90ad:0x3ffb2060 0x400f910d:0x3ffb2080 0x400e9b5d:0x3ffb20d0 0x400fd534:0x3ffb20f0 0x400d3590:0x3ffb2170 0x400d36a4:0x3ffb21f0 0x400d5572:0x3ffb2290

        I have put twice the Backtrace as you can see the reboot …
        I have added in the sketch the two sentences :
        “Connexion en AP
        Access Point actif”

        to control if it is hanging before or after the AP connexion and it shows that connxexion is OK. The error is just after that.
        The sketch used is coming from RNT, just modified as explained to work in AP mode.

        Waiting for your comments, many thanks.

        Reply
        • Hi.
          Try adding the following line before setting the access point:
          WiFi.disconnect();

          Let me know if anything changes.
          Regards,
          Sara

          Reply
          • Hi, I have modified the end of the sketch as suggested :
            // Wi-Fi connection
            Serial.println(“Déconnexion du WIFI”);
            WiFi.disconnect();
            WiFi.softAP(ssid, password);
            Serial.println(“Access Point actif”);

            // Start streaming web server
            delay(1000);
            startCameraServer();
            Serial.print(“serveur démarré\n”);
            }
            but tke error is still the same. Only the backtrace changes but is it possible to know what it means ?
            I had also added the delay(1000) to be sure that the WIFI is activated when the camera server starts.

  21. Hello community,
    I would like to address the ESP32 cam via a web server (AP mode) using an ESP32 client (also AP mode, but without internet/existing WLAN).
    A video front door camera that works on several floors/apartments would be used. That’s why I don’t want to use STA mode.
    Unfortunately, I haven’t found anything in my internet searches that could help me.
    Do you have an idea how I could do that? Is that possible?

    Many thanks for your ideas!
    greeting

    Reply
    • Hi, do you want that ALL ESP32-CAMs/ESP32 are in AP Mode?
      You want to build an separate WiFi Network for the ESPs only?
      That’s easy but you need at least, or better exactly, one AP and all others have to be in STA or, if you can configure so, at least in AP-STA mode if you want to use them as relay/bridge/repeater but that has massive side effects.
      How many devices do you want to connect?

      Reply
      • “You want to build an separate WiFi Network for the ESPs only?”
        Yes, that’s the idea!
        I do have a ESP32-cam running as AP-server, outside at the main door.
        That works fine. Access to the (live)pictures via old mobile phones works fine also.
        Unfortunately, the range is too small, it only extends to the 1st floor.
        We do have 3 floors with different families.
        So I would like to build a “range extender” with ESP32 in AP mode to get to the 3rd floor.
        All together don’t use internet.

        Reply
  22. rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
    configsip: 0, SPIWP:0xee
    clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
    mode:DIO, clock div:1
    load:0x3fff0030,len:1344
    load:0x40078000,len:13964
    load:0x40080400,len:3600
    entry 0x400805f0

    Camera Ready! Use ‘http://0.0.0.0’ to connect
    T-T how to correct please. I downloaded the code from the link you pasted. and check the board including ports and huge app and flash when uploading code It shows up to connect to wifi. But it denies access. Please tell me how to solve it.

    Reply

Leave a Comment

Download Our Free eBooks and Resources

Get instant access to our FREE eBooks, Resources, and Exclusive Electronics Projects by entering your email address below.