I am setting up my gmail account in Sim800l properly, so that I can send emails with photos as attachments over SMTP, using AT commands. The attached photos are ~38kb long, sent in 30x1280 (approx.) chunks. However, no matter if I use binary/base64 or ASCII/text “filetype”, the attached file received is ALMOST identical to the original, except that it has ASCII characters CR (0x0A) and LF (0x0D) randomly spread in various places and with random order (e.g. CR in byte 121, CR in byte 1020, LF in bye 2002 etc).
I have emailed the attachment several times and with different baud rates (suspecting noise), but there is no specific pattern for the number, distribution or order of CRs and LFs. The result in a BMP photo is that extra bytes injected as CRs and LFs between correct bytes result in shifting of pixel lines lines to the right and color distortion, as color is sent in a double-byte form and the second byte of one pixel is combined with the first byte of the next in such cases (then it is “self-corrected” in the next injection).
I use an ESP32’s software serial to “AT talk” to the SIM800l and send the bytes for the attached file. Conclusion:
- I have no problem with the AT commands. I can attach small text files and binary BMP photos.
- It cannot be noise: different baud rates have absolutely no impact in the number or order of CRs and LFs. Besides, noise should not be CRs or LFs!
- If it is not noise it means that either ESP32 sends or SIM800L receives fake LFs and CRs.
- I believe it is NOT ESP32, but I cannot be sure: I send hundreds of successful AT commands over the same serial port from ESP32 to SIM800l and I never get an error as a response. Otherwise, AT commands would also be truncated and not be understood from SIM800l.
- SO… if ESP32 serial is not to blame, is there any chance that SIM800l puts those CRs and LFs in the serial buffer for some reason when receiving specifically file bytes?
Any info, suggestions or alternative theories would be highly appreciated.