I'm succesfully using rcswich with a RF receiver and ESP32-cam but when i just try to merge the receiver demo with an esp cam server code it cause a endless reboot of my esp with an error message.
The esp cam server code is working well before merging and it starts rebooting with a error message as soon as i add this part :
Serial.print("Ready to receive.");
mySwitch.enableReceive(RXD2);
delay(1000);
Interpretation of the error with Exception Decoder :
PC: 0x401584a3: esp_intr_get_cpu at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/intr_alloc.c line 780
EXCVADDR: 0x00000000
Decoding stack results
0x401584a3: esp_intr_get_cpu at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/intr_alloc.c line 780
0x401362bc: gpio_isr_handler_add at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/driver/gpio.c line 389
0x40138020: camera_init at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/components/esp32-camera/driver/camera.c line 1205
0x4013819f: esp_camera_init at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/components/esp32-camera/driver/camera.c line 1268
0x400d2482: setup() at /Users/admin/Downloads/Code_Security_Camera_ESP32CAM_Blynk_02/Code_Security_Camera_ESP32CAM_Blynk_02.ino line 116
0x400d585b: loopTask(void*) at /Users/admin/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/cores/esp32/main.cpp line 14
0x4008bc19: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143
Here is the complete code:
#define CAMERA_MODEL_AI_THINKER // Has PSRAM
#include "camera_pins.h"
#define BTN 13
#define PHOTO 14
#define LED 4
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
#define RXD2 2
#include "config.h"
const char* ssid = secret_ssid;
const char* password = secret_pwd;
char auth[] = secret_auth; //sent by Blynk
String local_IP;
void startCameraServer();
void takePhoto()
{
digitalWrite(LED, HIGH);
delay(200);
uint32_t randomNum = random(50000);
Serial.println("http://" + local_IP + "/capture?_cb=" + (String)randomNum);
Blynk.setProperty(V1, "urls", "http://" + local_IP + "/capture?_cb=" + (String)randomNum);
digitalWrite(LED, LOW);
delay(1000);
}
void setup() {
Serial.begin(115200);
pinMode(RXD2, INPUT);
pinMode(LED, OUTPUT);
pinMode(BTN, INPUT_PULLUP);
Serial.setDebugOutput(true);
Serial.println();
delay(1000);
Serial.print("Ready to receive.");
mySwitch.enableReceive(RXD2);
delay(1000);
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;
}
// 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);
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());
local_IP = WiFi.localIP().toString();
Serial.println("' to connect");
Blynk.begin(auth, ssid, password);
}
void loop() {
Serial.println(BTN);
// put your main code here, to run repeatedly:
Blynk.run();
if (digitalRead(BTN) == LOW) {
Serial.println("Send Notification");
Blynk.notify("Il y a une personne à la porte!");
Serial.println("Capture Photo");
Serial.println(BTN);
takePhoto();
delay(3000);
} else if (digitalRead(BTN) == HIGH) { };
/*
if (mySwitch.available()) {
Serial.print(mySwitch.getReceivedValue());
unsigned long int num = mySwitch.getReceivedValue();
Serial.println(num);
mySwitch.resetAvailable();
}
*/
}
Had this kind of issue with ESP's turns out it was the boot loader being triggered with serial port, did not happen when port was changed to none boot loader ports.
I'm succesfully using rcswich with a RF receiver and ESP32-cam but when i just try to merge the receiver demo with an esp cam server code it cause a endless reboot of my esp with an error message. The esp cam server code is working well before merging and it starts rebooting with a error message as soon as i add this part :
The error message
Interpretation of the error with Exception Decoder :
Here is the complete code: