Hi there,
I’ve been having a play with this ESP32-CAM and I’m quite impressed with such a cheap and small camera. I just wanted to share what changes I made to the File>>Examples>>ESP32>>Camera>>CameraWebServer example.
I changed the camera type to:
#define CAMERA_MODEL_AI_THINKER // Has PSRAM
and chose the ‘AI Thinker ESP32-Cam’ board.
I wanted a specific IP 192.168.0.151 so I added this bit of code under the SSID and PASSWORD values
// Set your Static IP address to 151
IPAddress local_IP(192, 168, 0, 151);
IPAddress gateway(192, 168, 0, 1);
IPAddress subnet(255, 255, 255, 0);
IPAddress primaryDNS(8, 8, 8, 8); //optional
IPAddress secondaryDNS(8, 8, 4, 4); //optional
I then added the following to before WiFi.begin(ssid, password); in the Setup
// Configures static IP address
if (!WiFi.config(local_IP, gateway, subnet, primaryDNS, secondaryDNS)) {
Serial.println("STA Failed to configure");
}
This will now set the IP address of the camera to 192.168.0.151.
I then wanted to only view the stream without all the controls so I can embed the stream into a bespoke webpage. I eventually found that the stream uses port 81 so I just entered http://192.168.0.151:81/stream into the web browser and I had just the stream showing which was great but the default size of image was too small. If the image size is changed using the controls, it loses the setting when the camera is powered down. So looking through the code I noticed this:
if (config.pixel_format == PIXFORMAT_JPEG) {
if (psramFound()) {
config.jpeg_quality = 10;
config.fb_count = 2;
config.grab_mode = CAMERA_GRAB_LATEST;
} else {
// Limit the frame size when PSRAM is not available
config.frame_size = FRAMESIZE_QVGA;
config.fb_location = CAMERA_FB_IN_DRAM;
}
I noticed that the QVGA(320x240) is hard coded as the default frame size (FRAMESIZE_QVGA). I wanted SVGA(800x600) so I changed one line to:
config.frame_size = FRAMESIZE_SVGA;
If you go to your camera page, mine being http://192.168.0.151, in the Resolution settings you can see a list of available sizes. I think you can just add the acronym instead of the actual frame size. i.e. FRAMESIZE_SVGA, FRAMESIZE_QVGA, FRAMESIZE_XGA etc
Well that’s all I’ve done so far and I thought I’d share some of what I’ve done with yourselves.