-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Description
Board
ESP32 CAM
Device Description
The camera live streaming and the network are not working properly after 3.3.x update.
Connected WiFi IP frequently show RTO, and live streaming is almost stopped.
Please fix it
It is working properly with 3.1.x versions
Hardware Configuration
// Setup camera
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_sccb_sda = SIOD_GPIO_NUM;
config.pin_sccb_scl = SIOC_GPIO_NUM;
config.pin_pwdn = PWDN_GPIO_NUM;
config.pin_reset = RESET_GPIO_NUM;
config.xclk_freq_hz = 20000000;
config.frame_size = FRAMESIZE_UXGA;
config.pixel_format = PIXFORMAT_JPEG;
config.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
config.fb_location = CAMERA_FB_IN_PSRAM;
config.jpeg_quality = 12;
config.fb_count = 1;
Version
v3.3.0
Type
Bug
IDE Name
Arduino IDE
Operating System
Windows 11
Flash frequency
20 MHz
PSRAM enabled
yes
Upload speed
115200
Description
Wifi and live streaming are not working after uploading the code, but it is working if I upload the code with the older version 3.1.x
Sketch
#include "esp_camera.h"
#include <WiFi.h>
#include <WebServer.h>
#define CAMERA_MODEL_AI_THINKER
#include "camera_pins.h"
// ================== WIFI CONFIG ==================
const char* ssid = "Guest";
const char* password = "Guest@12345";
// Static IP configuration
IPAddress local_IP(192, 168, 1, 20);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);
// Flashlight Control
#define FLASH_LED_PIN 4
// Car Control Pins
#define IN1 12
#define IN2 13
#define IN3 14
#define IN4 15
// Web server for RC controls (port 82)
WebServer control_server(82); // Renamed to avoid conflict
// Car movement functions
void stop_car() { // Renamed to avoid conflict
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, LOW);
}
void move_forward() { // Renamed to avoid conflict
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
}
void move_backward() { // Renamed to avoid conflict
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
}
void turn_left() { // Renamed to avoid conflict
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
}
void turn_right() { // Renamed to avoid conflict
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
}
// Toggle flash
void handleFlash() {
digitalWrite(FLASH_LED_PIN, !digitalRead(FLASH_LED_PIN));
control_server.send(200, "text/plain", digitalRead(FLASH_LED_PIN) ? "Flash ON" : "Flash OFF");
}
void startCameraServer();
void setupLedFlash(int pin);
void init_car() {
Serial.begin(115200);
Serial.setDebugOutput(true);
Serial.println();
// Initialize motor and flash pins
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);
pinMode(FLASH_LED_PIN, OUTPUT);
digitalWrite(FLASH_LED_PIN, LOW);
stop_car();
// Setup camera
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_sccb_sda = SIOD_GPIO_NUM;
config.pin_sccb_scl = SIOC_GPIO_NUM;
config.pin_pwdn = PWDN_GPIO_NUM;
config.pin_reset = RESET_GPIO_NUM;
config.xclk_freq_hz = 20000000;
config.frame_size = FRAMESIZE_UXGA;
config.pixel_format = PIXFORMAT_JPEG;
config.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
config.fb_location = CAMERA_FB_IN_PSRAM;
config.jpeg_quality = 12;
config.fb_count = 1;
// Optimize for PSRAM
if (config.pixel_format == PIXFORMAT_JPEG) {
if (psramFound()) {
config.jpeg_quality = 10;
config.fb_count = 2;
config.grab_mode = CAMERA_GRAB_LATEST;
} else {
config.frame_size = FRAMESIZE_SVGA;
config.fb_location = CAMERA_FB_IN_DRAM;
}
} else {
config.frame_size = FRAMESIZE_240X240;
#if CONFIG_IDF_TARGET_ESP32S3
config.fb_count = 2;
#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();
if (s->id.PID == OV3660_PID) {
s->set_vflip(s, 1);
s->set_brightness(s, 1);
s->set_saturation(s, -2);
}
if (config.pixel_format == PIXFORMAT_JPEG) {
s->set_framesize(s, FRAMESIZE_QVGA);
}
// Setup LED flash
#if defined(LED_GPIO_NUM)
setupLedFlash(LED_GPIO_NUM);
#endif
// Configure static IP
if (!WiFi.config(local_IP, gateway, subnet)) {
Serial.println("Static IP configuration failed");
}
// Connect to WiFi
WiFi.begin(ssid, password);
WiFi.setSleep(false);
WiFi.setTxPower(WIFI_POWER_19_5dBm);
Serial.print("WiFi connecting");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
// Add custom RC car routes
control_server.on("/", HTTP_GET, []() {
control_server.send(200, "text/html", R"rawliteral(
<html>
<body>
<h1>ESP32-CAM RC Control</h1>
<img src="http://192.168.1.20:81/stream" width="320"><br><br>
<button onclick="fetch('/forward')">Forward</button>
<button onclick="fetch('/backward')">Backward</button>
<button onclick="fetch('/left')">Left</button>
<button onclick="fetch('/right')">Right</button>
<button onclick="fetch('/stop')">Stop</button>
<button onclick="fetch('/flash')">Toggle Flash</button>
<br><br>
<a href="http://192.168.1.20/capture">Capture Photo</a>
</body>
</html>
)rawliteral");
});
control_server.on("/forward", HTTP_GET, []() { move_forward(); control_server.send(200, "text/plain", "OK"); });
control_server.on("/backward", HTTP_GET, []() { move_backward(); control_server.send(200, "text/plain", "OK"); });
control_server.on("/left", HTTP_GET, []() { turn_left(); control_server.send(200, "text/plain", "OK"); });
control_server.on("/right", HTTP_GET, []() { turn_right(); control_server.send(200, "text/plain", "OK"); });
control_server.on("/stop", HTTP_GET, []() { stop_car(); control_server.send(200, "text/plain", "OK"); });
control_server.on("/flash", HTTP_GET, handleFlash);
// Start custom server
control_server.begin();
Serial.println("RC control server started on port 82");
// Start camera server
startCameraServer();
Serial.print("Camera Ready! Use 'http://");
Serial.print(WiFi.localIP());
Serial.println(":82' to control RC bot");
Serial.println("Stream at 'http://192.168.1.20:81/stream'");
Serial.println("Capture at 'http://192.168.1.20/capture'");
}
void run_car() {
control_server.handleClient();
yield();
delay(10);
}
void setup() {
init_car(); // Call your initialization code
}
void loop() {
run_car(); // Keep handling requests
}
Debug Message
xxxx
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
- I confirm I have checked existing issues, online documentation and Troubleshooting guide.