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

wattexi
Posts: 5
Joined: Mon Nov 25, 2019 8:21 pm

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

Postby wattexi » Mon Nov 25, 2019 8:27 pm

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.
Attachments
photo_ok.jpg
photo_ok.jpg (1.19 KiB) Viewed 8796 times

pipi61
Posts: 60
Joined: Fri Dec 23, 2016 10:58 pm

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

Postby pipi61 » Wed Nov 27, 2019 4:51 pm

Try binary compare the origin with received picture. Check different character, what special character bad or changed to other character(s)

tommeyers
Posts: 184
Joined: Tue Apr 17, 2018 1:51 pm
Location: Santiago, Dominican Republic

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

Postby tommeyers » Wed Nov 27, 2019 5:20 pm

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
IT Professional, Maker
Santiago, Dominican Republic

wattexi
Posts: 5
Joined: Mon Nov 25, 2019 8:21 pm

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

Postby wattexi » Fri Nov 29, 2019 10:28 am

thank you for your answer I look at this and I come back
special Hello for J-M-L... :shock:

MmQAgTYx
Posts: 1
Joined: Sun Jan 19, 2020 2:26 pm

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

Postby MmQAgTYx » Sun Jan 19, 2020 2:33 pm

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.

User avatar
BehicMV
Posts: 5
Joined: Fri Mar 31, 2023 11:20 am

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

Postby BehicMV » Fri Jun 16, 2023 2:31 pm

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

Who is online

Users browsing this forum: No registered users and 58 guests