Giter Site home page Giter Site logo

Comments (3)

ldab avatar ldab commented on May 27, 2024

Please share you full code.

Start the library with verbose mode "2" and share the serial monitor.

Since the example provided with the library works, it's likely that your code break due to the use of SD card or the EEPROM

from esp32_ftpclient.

alexw22 avatar alexw22 commented on May 27, 2024

Thanks for your reply!

After re-uploading the sketch today I unfortunately didn't manage to come as far as yesterday (the code breaks before making the connection) and indeed it seems to be related to the SD card as you said.

Here is the code below:
`/******************************************************************************

ESP32-CAM remote image access via FTP. Take pictures with ESP32 and upload it via FTP making it accessible for the outisde network.
Leonardo Bispo
July - 2019
https://github.com/ldab/ESP32_FTPClient

Distributed as-is; no warranty is given.

******************************************************************************/
#include "esp_camera.h"
#include "Arduino.h"
#include "FS.h" // SD Card ESP32
#include "SD_MMC.h" // SD Card ESP32
#include <WiFi.h>
#include <WiFiClient.h>
#include <ESP32_FTPClient.h>
// #include "octocat.h"
#include "soc/soc.h" // Disable brownour problems
#include "soc/rtc_cntl_reg.h" // Disable brownour problems
#include "driver/rtc_io.h"
#include <EEPROM.h>

#define EEPROM_SIZE 1
#define WIFI_SSID "###################"
#define WIFI_PASS "###################"

RTC_DATA_ATTR int bootCount = 0;

// Pin definition for CAMERA_MODEL_AI_THINKER
#define PWDN_GPIO_NUM 32
#define RESET_GPIO_NUM -1
#define XCLK_GPIO_NUM 0
#define SIOD_GPIO_NUM 26
#define SIOC_GPIO_NUM 27
#define Y9_GPIO_NUM 35
#define Y8_GPIO_NUM 34
#define Y7_GPIO_NUM 39
#define Y6_GPIO_NUM 36
#define Y5_GPIO_NUM 21
#define Y4_GPIO_NUM 19
#define Y3_GPIO_NUM 18
#define Y2_GPIO_NUM 5
#define VSYNC_GPIO_NUM 25
#define HREF_GPIO_NUM 23
#define PCLK_GPIO_NUM 22

char ftp_server[] = "##################";
char ftp_user[] = "##################";
char ftp_pass[] = "##################";

int pictureNumber = 0;

// you can pass a FTP timeout and debbug mode on the last 2 arguments
ESP32_FTPClient ftp (ftp_server,ftp_user,ftp_pass, 2000, 2);

void setup()
{
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //disable brownout detector
Serial.begin( 115200 );

Serial.setDebugOutput(true);

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;

pinMode(4, INPUT);
digitalWrite(4, LOW);
rtc_gpio_hold_dis(GPIO_NUM_4);

if(psramFound()){
config.frame_size = FRAMESIZE_UXGA; // FRAMESIZE_ + QVGA|CIF|VGA|SVGA|XGA|SXGA|UXGA
config.jpeg_quality = 10;
config.fb_count = 2;
} else {
config.frame_size = FRAMESIZE_SVGA;
config.jpeg_quality = 12;
config.fb_count = 1;
}

// Init Camera
esp_err_t err = esp_camera_init(&config);
if (err != ESP_OK) {
Serial.printf("Camera init failed with error 0x%x", err);
return;
}

Serial.println("Starting SD Card");

delay(500);
if(!SD_MMC.begin()){
Serial.println("SD Card Mount Failed");
//return;
}

uint8_t cardType = SD_MMC.cardType();
if(cardType == CARD_NONE){
Serial.println("No SD Card attached");
return;
}

camera_fb_t * fb = NULL;

// Take Picture with Camera
fb = esp_camera_fb_get();
if(!fb) {
Serial.println("Camera capture failed");
return;
}
// initialize EEPROM with predefined size
EEPROM.begin(EEPROM_SIZE);
pictureNumber = EEPROM.read(0) + 1;

// Path where new picture will be saved in SD Card
String path = "/picture" + String(pictureNumber) +".jpg";

fs::FS &fs = SD_MMC;
Serial.printf("Picture file name: %s\n", path.c_str());

File file = fs.open(path.c_str(), FILE_WRITE);
if(!file){
Serial.println("Failed to open file in writing mode");
}
else {
file.write(fb->buf, fb->len); // payload (image), payload length
Serial.printf("Saved file to path: %s\n", path.c_str());
EEPROM.write(0, pictureNumber);
EEPROM.commit();
}
file.close();
esp_camera_fb_return(fb);

delay(1000);

// Turns off the ESP32-CAM white on-board LED (flash) connected to GPIO 4
pinMode(4, OUTPUT);
digitalWrite(4, LOW);
rtc_gpio_hold_en(GPIO_NUM_4);

WiFi.begin( WIFI_SSID, WIFI_PASS );

Serial.println("Connecting Wifi...");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());

ftp.OpenConnection();

// Get directory content
// ftp.InitFile("Type A");
// String list[128];
// ftp.ChangeWorkDir("/");
// ftp.ContentList("", list);
// Serial.println("\nDirectory info: ");
// for(int i = 0; i < sizeof(list); i++)
// {
// if(list[i].length() > 0)
// Serial.println(list[i]);
// else
// break;
// }

// Make a new directory
// ftp.InitFile("Type A");
// ftp.MakeDir("my_new_dir");

// Create the new file and send the image
// ftp.ChangeWorkDir("my_new_dir");
ftp.InitFile("Type I");
ftp.NewFile(path.c_str());
ftp.WriteData( fb->buf, sizeof(fb->len) );
//ftp.WriteData( fb->buf, fb->len );
ftp.CloseFile();

// Create the file new and write a string into it
// ftp.InitFile("Type A");
// ftp.NewFile("hello_world.txt");
// ftp.Write("Hello World");
// ftp.CloseFile();

ftp.CloseConnection();

esp_sleep_enable_ext0_wakeup(GPIO_NUM_13, 0);

Serial.println("Going to sleep now");
delay(1000);
esp_deep_sleep_start();
Serial.println("This will never be printed");
}

void loop()
{

}`

And this is the output from the serial monitor:
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1216
ho 0 tail 12 room 4
load:0x40078000,len:9720
ho 0 tail 12 room 4
load:0x40080400,len:6352
entry 0x400806b8
Starting SD Card
Picture file name: /picture164.jpg
E (3949) sdmmc_req: sdmmc_host_wait_for_event returned 0x107
E (3949) diskio_sdmmc: sdmmc_write_blocks failed (263)
Saved file to path: /picture164.jpg
E (8954) sdmmc_req: sdmmc_host_wait_for_event returned 0x107
E (8954) sdmmc_cmd: sdmmc_write_sectors_dma: sdmmc_send_cmd returned 0x107
E (8955) diskio_sdmmc: sdmmc_write_blocks failed (263)
Guru Meditation Error: Core 0 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x400e2b60: 11992384 cee20181 00434260
Core 0 register dump:
PC : 0x400e2b67 PS : 0x00060a30 A0 : 0x800e2bde A1 : 0x3ffd9840
A2 : 0x00000014 A3 : 0x3ffbeeec A4 : 0x00000040 A5 : 0x0000000b
A6 : 0x3ffd9850 A7 : 0x3ffc60d8 A8 : 0x812022b6 A9 : 0x00000000
A10 : 0x600060f8 A11 : 0x3ffc6132 A12 : 0x00000014 A13 : 0x00000014
A14 : 0x00000006 A15 : 0x00000120 SAR : 0x00000018 EXCCAUSE: 0x00000000
EXCVADDR: 0x00000000 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0x00000000

Backtrace: 0x400e2b67:0x3ffd9840 0x400e2bdb:0x3ffd9890 0x400e0ade:0x3ffd98b0 0x400e0eec:0x3ffd98d0 0x400d80fb:0x3ffd9990 0x400d837e:0x3ffd99c0 0x400f649c:0x3ffd99f0 0x400f658c:0x3ffd9a20 0x400f688a:0x3ffd9a50 0x400f2c6e:0x3ffd9a80 0x40095d5f:0x3ffd9aa0 0x4008f365:0x3ffd9ae0

Rebooting...
ets Jun 8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1216
ho 0 tail 12 room 4
load:0x40078000,len:9720
ho 0 tail 12 room 4
load:0x40080400,len:6352
entry 0x400806b8
Starting SD Card
E (3613) sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x107
SD Card Mount Failed
No SD Card attached

from esp32_ftpclient.

ldab avatar ldab commented on May 27, 2024

I would recommend trying the example you shared on the first link sent and go from there. I'll close the issue as it does not seem to be related with this library, you're welcome to open again if you find that the library is breaking something

from esp32_ftpclient.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.