below is my code which already worked. Unfortunately now I get this error.
##############################################
CORRUPT HEAP: Bad head at 0x3f85dc2c. Expected 0xabba1234 got 0x3f9ffff4
abort() was called at PC 0x4008a41d on core 1
ELF file SHA256: 0000000000000000
Backtrace: 0x4008de14:0x3ffdca10 0x4008e08d:0x3ffdca30 0x4008a41d:0x3ffdca50 0x4008a549:0x3ffdca80 0x400fd3db:0x3ffdcaa0 0x400f8eb5:0x3ffdcd60 0x400f8dbd:0x3ffdcdb0 0x400933dd:0x3ffdcde0 0x40082746:0x3ffdce00 0x4008a315:0x3ffdce20 0x4000bec7:0x3ffdce40 0x400d1152:0x3ffdce60 0x4011b9dd:0x3ffdcf80 0x4011c535:0x3ffdcfb0 0x4011c5ed:0x3ffdd040 0x4011bc48:0x3ffdd060 0x4011acc0:0x3ffdd080 0x4011ad17:0x3ffdd0c0 0x4008fd1e:0x3ffdd0e0
Rebooting...
##############################################
- #include "esp_camera.h"
- #include <WiFi.h>
- #include "soc/soc.h"
- #include "soc/rtc_cntl_reg.h"
- #include <LITTLEFS.h>
- #include <FS.h>
- #include "esp_timer.h"
- #include "Arduino.h"
- #include "fb_gfx.h"
- #include "esp_http_server.h"
- #define led 33
- #define PART_BOUNDARY "123456789000000000000987654321"
- const char* ssid = "Mi Casa";
- const char* password = "W1xldgmnuweadWs!";
- static const char* _STREAM_CONTENT_TYPE = "multipart/x-mixed-replace;boundary=" PART_BOUNDARY;
- static const char* _STREAM_BOUNDARY = "\r\n--" PART_BOUNDARY "\r\n";
- static const char* _STREAM_PART = "Content-Type: image/jpeg\r\nContent-Length: %u\r\n\r\n";
- httpd_handle_t stream_httpd = NULL;
- static esp_err_t stream_handler(httpd_req_t *req){
- camera_fb_t * fb = NULL;
- esp_err_t res = ESP_OK;
- size_t _jpg_buf_len = 0;
- uint8_t * _jpg_buf = NULL;
- char * part_buf[64];
- res = httpd_resp_set_type(req, _STREAM_CONTENT_TYPE);
- if(res != ESP_OK){
- return res;
- }
- while(true){
- fb = esp_camera_fb_get();
- _jpg_buf_len = fb->len;
- _jpg_buf = fb->buf;
- if(res == ESP_OK){
- size_t hlen = snprintf((char *)part_buf, 64, _STREAM_PART, _jpg_buf_len);
- res = httpd_resp_send_chunk(req, (const char *)part_buf, hlen);
- }
- if(res == ESP_OK){
- res = httpd_resp_send_chunk(req, (const char *)_jpg_buf, _jpg_buf_len);
- }
- if(res == ESP_OK){
- res = httpd_resp_send_chunk(req, _STREAM_BOUNDARY, strlen(_STREAM_BOUNDARY));
- }
- esp_camera_fb_return(fb);
- fb = NULL;
- free(_jpg_buf);
- _jpg_buf = NULL;
- if(res != ESP_OK){
- break;
- }
- }
- return res;
- }
- void startCameraServer(){
- httpd_config_t config = HTTPD_DEFAULT_CONFIG();
- config.server_port = 80;
- httpd_uri_t index_uri = {
- .uri = "/",
- .method = HTTP_GET,
- .handler = stream_handler,
- .user_ctx = NULL
- };
- Serial.printf("Starting web server on port: '%d'\n", config.server_port);
- if (httpd_start(&stream_httpd, &config) == ESP_OK) {
- httpd_register_uri_handler(stream_httpd, &index_uri);
- }
- }
- void setup()
- {
- WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); // prevent brownouts by silencing them
- Serial.begin(115200);
- Serial.setDebugOutput(true);
- Serial.println();
- pinMode(led, OUTPUT);
- LITTLEFS.begin(true);
- WiFi.begin(ssid, password);
- Serial.print("WLAN Verbindungsaufbau...");
- while (WiFi.status() != WL_CONNECTED)
- {
- Serial.print(".");
- delay(200);
- }
- Serial.println();
- Serial.println("Verbunden");
- Serial.print("IP-Adresse: ");
- Serial.println(WiFi.localIP());
- camera_config_t config;
- config.ledc_channel = LEDC_CHANNEL_0;
- config.ledc_timer = LEDC_TIMER_0;
- config.pin_d0 = 5;
- config.pin_d1 = 18;
- config.pin_d2 = 19;
- config.pin_d3 = 21;
- config.pin_d4 = 36;
- config.pin_d5 = 39;
- config.pin_d6 = 34;
- config.pin_d7 = 35;
- config.pin_xclk = 0;
- config.pin_pclk = 22;
- config.pin_vsync = 25;
- config.pin_href = 23;
- config.pin_sscb_sda = 26;
- config.pin_sscb_scl = 27;
- config.pin_pwdn = 32;
- config.pin_reset = -1;
- config.xclk_freq_hz = 20000000;
- config.pixel_format = PIXFORMAT_JPEG;
- config.frame_size = FRAMESIZE_UXGA;
- config.jpeg_quality = 10;
- config.fb_count = 2;
- esp_err_t err = esp_camera_init(&config);
- if (err != ESP_OK) {
- Serial.printf("Camera init failed with error 0x%x", err);
- return;
- }
- else {
- Serial.println("Camera initialisiert.");
- }
- sensor_t * s = esp_camera_sensor_get();
- s->set_framesize(s, FRAMESIZE_UXGA);
- s->set_vflip(s, 0);
- s->set_hmirror(s, 0);
- startCameraServer();
- }
- void loop()
- {
- delay(1000);
- }