So after many frustrating hours of coding I decided to seek some help.
I have my ArduCam 2MP Mini connected to my ESP8266 as follows :
![Image](http://i.imgur.com/zYRPucT.png)
![Image](http://i.imgur.com/TgYTFOK.jpg)
What I like to do is taking a picture and saving it as a JPG image without creating any local server/html script.
Just take a picture and save it to the internal storage of the ESP.
Then I like to load the picture so I can send it over the network (via Telegram-messenger).
Can someone explain me how this can be achieved?
I already did a lot of research and checked out the examples I found online - they work, but they all are either
streaming video or using a local server to display the image.
I simply want to take snap and save the raw data of the jpg image.
The code I am currently trying to get running somehow :
void myCAMSaveToSPIFFS() {
SPIFFS.begin();
delay(10);
myCAM.set_format(JPEG);
myCAM.InitCAM();
setCamResolution(resolution);
// as file space is used, capturing images will get slower. At a certain point, the images will become distored
// or they will not save at all due to lack of space. To avoid this we set a limit and allow some free space to remain
if ((fileTotalKB - fileUsedKB) < fileSpaceOffset)
{
String maxStr = "====== Maximum Data Storage Reached =========";
Serial.println(maxStr);
HomeBot.sendMessage(HomeBot.message[1][4], EncodeURL("Data storage is full! Failed to take picture!") , "");
errMsg = maxStr;
return;
}
String str;
byte buf[256];
static int i = 0;
static int n = 0;
uint8_t temp, temp_last;
// File file;
//Flush the FIFO
myCAM.flush_fifo();
//Clear the capture done flag
myCAM.clear_fifo_flag();
//Start capture
myCAM.start_capture();
while (!myCAM.get_bit(ARDUCHIP_TRIG , CAP_DONE_MASK));
Serial.println("File Capture Done!");
fileCount++;
str = "/pics/" + String(fileCount) + ".jpg";
File f = SPIFFS.open(str, "w");
if (!f) {
Serial.println("prop file open failed");
}
else
{
Serial.println(str);
}
i = 0;
myCAM.CS_LOW();
myCAM.set_fifo_burst();
#if !(defined (ARDUCAM_SHIELD_V2) && defined (OV2640_CAM))
SPI.transfer(0xFF);
#endif
//Read JPEG data from FIFO
while ( (temp != 0xD9) | (temp_last != 0xFF)) {
temp_last = temp;
temp = SPI.transfer(0x00);
//Write image data to buffer if not full
if ( i < 256)
buf[i++] = temp;
else {
//Write 256 bytes image data to file
myCAM.CS_HIGH();
f.write(buf , 256);
i = 0;
buf[i++] = temp;
myCAM.CS_LOW();
myCAM.set_fifo_burst();
}
//delay(0);
}
//Write the remain bytes in the buffer
if (i > 0) {
myCAM.CS_HIGH();
f.write(buf, i);
}
//Close the file
f.close();
Serial.println("CAM Save Done!");
}
I received the storage is full warning when executing the function, which makes very little sense since
there should be more then enough free space available on the ESP for a low res picture.
Can someone help me out? :/