Time to send single JPG pic to gmail

Home Forums The libraries hosted on the site EMailSender send email with attachments Time to send single JPG pic to gmail

Viewing 5 reply threads
  • Author
    Posts
    • #12886
      Sailorman

        Hi Renzo,

        I am using your library on ESP8266. email sender v2.4.2.

        It takes long times for a JPG file to be sent. I set encode64 to TRUE otherwise it will not arrive properly and with many many artifacts.

        The time it takes to send over wifi is very long, for example file sizes: QVGA=5.2K, 2 min, VGA=25K, ~6-8 min , SVGA=`35K , ~20min.

        Do these long times make sense to you ? Is there any way to improve this ? If I am connected to wifi I would assume it would be much faster for such small files (single JPG).

        Thank you !

        Saillu

      • #12887
        Renzo Mischianti
        Keymaster

          Hi Saillu,
          it isn’t the wifi speed, the problem is the low power of esp8266, the encoding It’s an hard process for that processor.

          If you explain what you want to do we can try to find an alternative solution.

          Bye Renzo

          • #12892
            Sailorman

              Hi Renzo,

              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 ?

              Thank you,

              Saillu

          • #12897
            Renzo Mischianti
            Keymaster

              Hi Saillu,
              I think, to do less change as possible you can do somethimg like this.

              1. Save jpg.
              2. Use second core of esp32 to generate a file already encoded in base64.
              3. Send email with file encoded, but i must do a change to the library

              Or use esp32 for all.

              If u need help, write to the forum, and share your code.

              Bye Renzo

              • #12898
                Sailorman

                  Hi Renzo,

                  Thank again for your reply.

                  I encoded the file on ESP32 (on the ESP32-CAM). Taken from https://www.survivingwithandroid.com/esp32-cam-image-classification-machine-learning/ it is fairly simple:

                  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
                  #include base64.h
                  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.

                  Thank you,

                  Saillu.

              • #12899
                Renzo Mischianti
                Keymaster

                  Hi Saillu,
                  you can test the features on this branch of github.

                  you must add to filedescriptor this information

                  
                  fileDescriptor[0].contentTransferEncoding = "base64";
                  

                  It’s untested, give me a feedback.

                  bye Renzo

                  • #12905
                    Sailorman

                      Hi Renzo,

                      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.

                      Thank you,

                      Saillu

                       

                  • #12959
                    Renzo Mischianti
                    Keymaster

                      Hi Saillu,
                      if you find artifact on image, I think the problem is the file sended, because I don’t apply any type of manipulation with

                      
                      fileDescriptor[0].contentTransferEncoding = "base64";
                      

                      I add only header that specify that the file is in base64 to the receiver.

                      Can you attach the complete code?

                      Bye Renzo

                      • #13070
                        Sailorman

                          Hi Renzo,

                          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 :-).

                          Thanks again for an amazing library,

                          Saillu

                      • #13079
                        Renzo Mischianti
                        Keymaster

                          Hi Sailorman,
                          thanks to you for your feedback, I’m going to incorporate the features, so other can use It.
                          If you want write an article about your project we are happy to publish It.
                          Bye Renzo

                      Viewing 5 reply threads
                      • You must be logged in to reply to this topic.
                      Exit mobile version