Page 1 of 1

Send picture over gprs, smtp, softwareSerial, received damaged!!?

Posted: Mon Nov 25, 2019 8:27 pm
by wattexi
ello everyone, I have a problem:
I am trying to send an email attachment with a gsm sim800l module.
I use the AT command, the gmail SMTP server and the softwareSerial lib.
everything is ok, I can send emails, sms, read an html page, send emails with a .txt file as an attachment...
but when I want to send a picture as an attachment, it arrives but degrade : the half of the photo is in good condition but the rest is broken.
the photo is stored in SPIFFS memory, its weight: 1220 bytes, but after transferring his weight: 1235 bytes:

the doc of the sim module says: "AT + SMTPFILE"
first parameter: 2 = binary file
second parameter: <fileName>
third parameter: 1 = "base64"

Code: Select all

...
sim800l.print("AT+SMTPFILE=2,\"photo.jpg\",1\r");
...
AT+SMTPFT=1220\r"
...

File file = SPIFFS.open(path_file_attachment);
if(!file)
{
	Serial.println("// failed to open file for reading");
	
}

Serial.println("// read file from spiffs and send...");

while(file.available()>0)
{
	sim800l.write(file.read());
	
}

file.close();

sim800l.print("\"");
...
I'm stuck, I tried a lot of different things but the picture is still broken ...
I think the problem is maybe the way to send bytes, but I can not do it?
thank you in advance to all those who can help me.

Re: Send picture over gprs, smtp, softwareSerial, received damaged!!?

Posted: Wed Nov 27, 2019 4:51 pm
by pipi61
Try binary compare the origin with received picture. Check different character, what special character bad or changed to other character(s)

Re: Send picture over gprs, smtp, softwareSerial, received damaged!!?

Posted: Wed Nov 27, 2019 5:20 pm
by tommeyers
I saw one posting:
"Hi, i am trying to send an email with a jpg picture using sim800L. I can send everything but i cant read the received picture. after analyzing the original one i found that the received picture always has before a 0x0A byte, a 0x0D byte.

Example:
original byte sequence:
0x0A, 0xB3, 0xB4

Received sequence:
0x0D, 0x0A, 0xB3, 0xB4

i found that the 0D0A corresponds to the \r\n (CR, carriage return and LF, line feed) so when the original picture as a LF byte the received one will add a CR byte before the LF.

I think the problem is in gsm module but i cant find how to solve that."

You may find something similar when you pick through the data byte by byte.

Tom Meyers

Re: Send picture over gprs, smtp, softwareSerial, received damaged!!?

Posted: Fri Nov 29, 2019 10:28 am
by wattexi
thank you for your answer I look at this and I come back
special Hello for J-M-L... :shock:

Re: Send picture over gprs, smtp, softwareSerial, received damaged!!?

Posted: Sun Jan 19, 2020 2:33 pm
by MmQAgTYx
Need to set fileType to binary (see AT+SMTPFILE description) and then send file in base64 encoding.


Please provide the full code i need some imagination vor my project. Thank you.

Re: Send picture over gprs, smtp, softwareSerial, received damaged!!?

Posted: Fri Jun 16, 2023 2:31 pm
by BehicMV
Hi,
I was facing with the similiar problems. Could you help me in this thread?

https://forum.arduino.cc/t/sending-an-i ... 0l/1138658
https://stackoverflow.com/questions/764 ... ending-e-m
http://www.embeddedadvice.com/t/sim-800 ... error/2961

thank you for your attention...