Thank you for your reply. I am using an ESP8266 connected to a PIR-IR motion detector. Once motion is detected it triggers an ESP32-CAM to take a JPG picture which is stored on the ESP32-CAM SD card. This picture is then read from SD card by the ESP8266 and then sent by the ESP8266 over wifi with the email sender. I know this is a bit of an awkward way of doing things but the whole device is asleep until triggered by the PIR (works on 2xAA bats). In addition, the ESP32-CAM is very limited with the number of free GPIOs available so I have to store the pic on SD first.
I will have to rethink the whole thing. Maybe it makes more sense to connect the ESP32-CAM to WIFI and let the ESP32 do the encoding and sending over wifi, and not the ESP8266, to send the picture taken. Your thoughts ?
Add the following two lines in the ESP32 code: `
size_t size = fb->len;
String buffer = base64::encode((uint8_t *) fb->buf, fb->len);
// fb->buf holds the data and fb->len is the buffer size `
and also add
at beginning of file.
I set the encode64 in your library to “false” as the file is already encoded. As you said, you need to do a change in your library because the image received still has many artifacts.
I would imagine that if you make this change/update in your library it will serve many other users who are using your library as the file can then be transmitted already encoded and save a lot of time. Especially on battery powered devices like I use this transmission time saved is very valuable.
I used the branch version. Thank you for creating it! Everything compiles and works properly but I still get artifacts and unrecognizable image.
I looked a bit at your code at emailsender.cpp, line 99: const char* encode64_f(char* input, uint8_t len)
I forgot to mention it last time I wrote but the “buffer” I send is of type String and I think your code does not treat it as a string? I used this online tool https://www.base64decode.net/base64-image-decoder to print the base64 encoded string (image taken) and translate the string to an image to see that it is indeed encoded and can be decoded properly.
Sorry for my late reply. I finally got this to work. The issue was in my code in the way I handle the data written to file as string.
I can confirm that your code works perfectly and that the encoded file is displayed properly in Gmail. The time to transmit a pre-encoded file has been reduced significantly. For example, a 640×480 VGA frame that took before about 6 minutes now takes around 40-45 seconds. A 800×600 SVGA that took me before around 20 minutes now takes about a minute. I have not tested other resolutions.
45-60 seconds is still a lot of transmission time when on battery power but in my case I rarely transmit so it is not so bad and acceptable.
I think you can incorporate this into your main code branch so others can also enjoy this :-).
Maintaining a repository (or site or forum) is a lot like tending to a garden - it requires constant care and attention to keep it thriving. If you're a skilled gardener (or coder!) and want to help keep our repository blooming, we'd love to have you on board! We're also looking for talented writers and forum moderators to help us grow our community. Interested in joining our team? Don't hesitate to reach out and let us know how you can contribute!
Are you a fan of electronics or programming? Share your knowledge with others, write a simple tutorial or how to make a great project Contact me: firstname.lastname@example.org
The content displayed on this website is protected under a CC BY-NC-ND license. Visitors are prohibited from using, redistributing, or altering any content from this website for commercial purposes, including generating revenue through advertising. Any unauthorized use is a violation of the license terms and legal action may be taken against individuals or entities found to be in violation.
You must also provide the link to the source.