Acoptex.Com

Learn ESP32, ESP8266, Arduino, and Raspberry Pi

How to set Access Point (AP) for web server with ESP32-CAM AI-Thinker

We will learn set Access Point (AP) for web server with ESP32-CAM AI-Thinker. It is a way when you do not need to connect to a router in order to access the web server. More ESP32-CAM projects you can find here.

Tag: Project 136f How to set Access Point (AP) for web server with ESP32-CAM AI-Thinker

Project resources

  • Libraries used: None
  • Code: sketch

1. ESP32-CAM Development Board with camera 1 set

ESP32 cam

2. Arduino IDE ( you can download it from here  )

3. USB to TTL/Serial adaptor/converter 1 pc

USB to TTL/Serial adaptor/converter
USB to TTL/Serial adaptor/converter

4. Jumper cables F-F

JUMPER CABLES

5. Micro SD card and SD card adapter 1 pc

MICRO SD WITH ADAPTER

6. WiFi AntennaCompact Internal WiFi Antenna with U.FL connector and 5.9 inch cable 1 pc (optional)

WiFi Antenna, Compact Internal WiFi Antenna with U.FL connector and 5.9 inch cable

General

In our previous DIY web server projects with ESP32-CAM, we used to connect the ESP32-CAM to our wireless router and we could access the ESP32-CAM board through the local network. So, the router acts as an access point (AP) and the ESP32-CAM board is a station. In other words, you need to be connected to your router (local network) to control and access the ESP32-CAM web server.

Access Point (AP)

Sometimes it is not the best configuration if you do not have a router close to you. But if you set the ESP32-CAM as an Access Point (AP), you can connect with any device with WiFi capabilities without the need to use the connection to your router. Basically, when you set the ESP32-CAM as an AP then create its own WiFi network and nearby WiFi devices (stations) can connect to it (like your smartphone or your PC/laptop).

Access Point (AP)

The ESP32-CAM is called soft Access Point (soft AP) as it doesn’t connect further to a wired network (like your router). If you try to load libraries or use firmware from the internet (including JavaScript libraries) or if you try to make HTTP requests to services on the internet (sending an email with a photo, for example) it will not work.

Understanding the USB to TTL converter

You can read more about them here.

Understanding the ESP32-CAM Development Board with camera

You can read more about it here.

You can find the ESP32-CAM schematic here, ESP32-CAM development board specification is here, camera specification is here.

Signals and connections of the ESP32-CAM Development Board with camera

Signals and connections of the ESP32-CAM Development Board with camera

ESP32-CAM pinout:

ESP32-CAM pinout

GND – ground pin. Connected to Arduino board GND pin.

5V – external power supply pin 5VDC 2A

VCC – power supply pin. Connected to 5V pin.

3V3 – power supply pin. Connected to 3V3 pin.

U0TXD, U0RXD – Serial pins. You need these pins to upload code to your board.

GPIO 0 – pin which determines whether the ESP32 is in flashing mode or not. When GPIO 0 connected to GND, the ESP32-CAM is in flashing mode.

The following pins are internally connected to the Micro SD card reader:

  • GPIO 14: CLK
  • GPIO 15: CMD
  • GPIO 2: Data 0
  • GPIO 4: Data 1 (also connected to the on-board LED)
  • GPIO 12: Data 2
  • GPIO 13: Data 3

Wiring

ESP32-CAM WIRING

ESP32-CAM module    FTDI programmer

U0TXD (GPIO1)         RXI                  

U0RXD (GPIO3)         TX0

GND                          GND

5V                             5V

GND and GPIO0 (for flashing only)                                 

Step by Step instruction

1.Preparations

We assume that you have the latest version the Arduino IDE and ESP32 add on installed in your Arduino IDE. You can read how to do it here – Basics: Project 137 Installing the ESP32 Board in Arduino IDE (Windows, Mac OS X, Linux). You can download the latest Arduino IDE version Windows Installer here. We are using PC with Windows 7 64 bit OS.

2.Uploading the code to ESP32-CAM

1.Do wiring. Very important: GPIO 0 (IO 0) must be connected to GND otherwise you will not be able to upload code.

2. Attach WiFi antenna (optional). It will help you to increase WiFi range.

3.Attach OV2640 camera.

4.Plug your FTDI programmer into your PC USB port.

5.Open Arduino IDE.

6.Go to Tools -> Board… -> ESP32 Arduino ->and select AI Thinker ESP32-CAM. Make sure you select the right camera module. In this project we use the AI-THINKER ESP32-CAM Development Board with camera. 

ESP32-CAM webserver

7.Go to Tools -> Port and select the COM port the ESP32-CAM Development Board connected to (we have COM3).

ESP32-CAM webserver

6. Open this sketch in your Arduino IDE, modify the SSID name and a password to access the ESP32-CAM access point.

ESP32-CAM webserver AP

7.Click the upload button in Arduino IDE to upload the sketch. When you see Uploading… message press the ESP32-CAM Development Board on-board RST (RESET) button to restart your ESP32 in flashing mode.

ESP32-CAM webserver AP

9.When uploading completed disconnect GPIO 0 from GND.

10.Open the Serial Monitor of Arduino IDE (Tools -> Serial Monitor) at the baud rate of 115200. Press the ESP32-CAM Development board on-board RST (RESET) button. Your ESP32-CAM IP address is 192.168.4.1.

ESP32-CAM webserver AP

11.After uploading the code, you can connect to the ESP32-CAM access point to access the web server and you don’t need to connect to a router. Select ESP32CAM_AP wireless network connection on your PC/laptop and click on Connect button. Type in your password – 12345678 and click on OK button. You are connected to your ESP32-CAM now. The same you can do on your smartphone. Just go to Settings -> Wi-Fi ->Select ESP32CAM_AP network -> type in the password 12345678.

ESP32-CAM webserver AP
ESP32-CAM webserver AP
ESP32-CAM webserver AP

11.You can access your camera streaming server on your local network. Open any internet browser (IE,Google Chrome,..) (We used Google Chrome) and type the ESP32-CAM Development board IP address (we have http://192.168.4.1).

ESP32-CAM webserver AP
ESP32-CAM webserver

Code

You need to define an SSID name and a password to access the ESP32-CAM AP. In this example we’re using the ESP32 SSID name – ESP32CAM_AP. The password is 12345678. You can use different SSID and password.

const char* ssid = "ESP32CAM_AP";
const char* password = "12345678";

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

WiFi.softAP(ssid, password);

There are other optional parameters you can pass to the softAP() method too:

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).

Summary

We have learnt set Access Point (AP) for web server with ESP32-CAM AI-Thinker.

Check for more DIY projects on Acoptex.lt and Acoptex.com!

If you are looking for high quality PCBs PCBWay is the best choice: