Send image over GPRS

I have question about sending an image over GPRS, I have done everything and I am trying to send a file ( in that case an image ) and I have chosen the SD Library.

My code is very simple:

sendData("st");
            if (myPhoto) {
              int count = 0;
              sendDataStart();
              Serial.println("test.txt:");
              // read from the file until there's nothing else in it:
              while (myPhoto.available()) {
              	//Serial.write(myPhoto.read());
                 cell.print(myPhoto.read());
                 count++;
                 if (count == 200) {
                   sendDataStop();
                   delay(1000);
                   sendDataStart();
                   count = 0;                     
                 }             
              }
              Serial.println("end");
               sendDataStop();
             //  delay(1000);
              // close the file:
              myPhoto.close();
            } else {
            	// if the file didn't open, print an error:
              Serial.println("error opening test.txt");
            }
            sendData("eu");

What it does is sending a package of 200 reads to a nodejs server, the problem is that I have to send it in integer otherwise I am getting some error.
The string to send a data over GPRS is: AT+SSTRSEND=1,"blabalbalba"
and what I am getting from my server is:

Get data: 2332321671836378123140204292262182175741441082101831191402109530560155571853912925261791651182502171901302142181611019814023791859816702431362065823125502145023417511515213685139118711642487410516017918488522531052033325588522331792212141011901701262081786510117220217265869350232134719068125431502332341825423113869111138141861431341081691106812209551491517918492252202163170142281162453018122710223217689622071248117713124689112217224127151262221911361742028416416916911612328211171301181336155142203616410822725460230249191241218681531292181092392122426625315092156995627127206695214720951577845112311861592482432122325422137255022610516698733110219059782417317217320777112541157854902209224112348223341331111782344415253572047925412977251671795421912567112232361151242232482377610015518920223087208669313525212295250992362101592531501541652461402182343511814126201491992545923790243164183662311392081191562492022182343114117216325501011632049665251381606728127199156220311271501791397516811519681351343123215123125422110125502261066348167202150154

I can transfer all the image without any problems but I don't know what should I do to make it visible from another computer, because what I understood is that I have all the file in binary source, am I right?
I know that I can try to encode my image in Base64 but I don't know if that is the best way, how does it work with a normal socket transmiton ?

              	//Serial.write(myPhoto.read());
                 cell.print(myPhoto.read());

Why are you using write() in one case and print() in the other? The two functions do NOT do the same thing.

the problem is that I have to send it in integer otherwise I am getting some error.

Feel free to elaborate on that error, and what "send it in integer" means.

The call "Serial.write" was a debug testing, just to make sure that the loop was doing it.

Do you have any suggestions to convert all the integers that I getting to a image file?

Do you have any suggestions to convert all the integers that I getting to a image file?

You need, if you are going to convert each byte to a string, to put delimiters between each byte, so that the stream of ints on the other end can be parsed.

It's simpler, though, to simply not convert each byte to a string. Just send the byte(s).

Ok, to make sure that I got it:

  • when I do filePhoto.read() , I am getting bytes, right?
  • I have to create a buffer like that: 10;3;4;11...
  • I have to convert my bytes to text and save it on my file
  • when I do filePhoto.read() , I am getting bytes, right?

Yes.

  • I have to create a buffer like that: 10;3;4;11...

No.

  • I have to convert my bytes to text and save it on my file

No.

The buffer I mean:

cell.print(filePhoto.read());
cell.print(";");

What was your idea? I understood like that....

What was your idea?

You commented out a call to Serial.write() and used a cell.print() statement in it's place. Why are you using cell.print() instead of cell.write() when what you want to send is binary data?

Well, I used to call print but I didn't know that there was a big difference.

I am going to use cell.write, what was your idea to "to put delimiters between each byte," ?

what was your idea to "to put delimiters between each byte," ?

When sending the data AS BYTES, you don't need to. That is NOT what cell.print() does, though. You really must read the documentation.

Ok, I got that write is sending binary data to the serial port.
I made a mistake that's all, I just need to understand it, this topic is going to be a long one instead of give me advices.

You answered me, thank you ,but if you don't want to help me, so stop it, because I need help not to ask each time something.

You could answer me something like that:

  • The print does something that you don't need, use write instead that writes binary data

You told me to create a DELIMITERS between each byte, maybe I misunderstood what you are saying .... what I can imagine is to create a buffer "10;2;2;" and then convert each byte to char on the nodejs side.

I don't have any idea how does it work with a normal socket, I know how to exchange message between two machine but I don't have any clue to send a file.

You told me to create a DELIMITERS between each byte,

No. I said that IF you were going to convert each byte to a string, which is what print() does, that you needed to put a delimiter between each string. If you use write(), instead, each byte is sent as-is, so no delimiters are needed.

Ok thanks, I got it.
I am going to try with the method Write, if everything works, I will post an example of my code + nodejs

I couldn't make it works, I tried to send only ascii number with a separation:

 cell.print((int)myPhoto.read()); cell.print("%");

My string is something like that: 178%31%9%63%237%188%147%124%167%178%0%5 , on the server side I am splitting the string and then convert every number to char.
The server created a file image that I can't open it, my understanding is where I am doing wrong, how can I send this image over a socket?

Ok I got this buffer:

71%73%70%56%57%97%50%0%50%0%247%0%0%150%140%115%102%94%69%198%187%159%123%114%90%71%71%71%138%129%101%202%193%166%201%193%172%238%234%221%200%197%188%140%135%122%211%201%171%67%59%38%235%229%209%250%250%250%229%228%226%166%157%131%134%126%103%193%180%142%228%220%198%130%130%130%225%221%209%227%221%202%228%218%188%245%241%230%38%37%37%156%145%115%248%243%228%195%185%157%211%202%180%74%66%42%209%198%162%108%98%70%234%230%219%187%179%156%219%211%187%92%84%61%241%238%230%220%218%211%231%228%220%206%194%159%248%246%242%118%108%83%252%251%249%233%225%202%23%19%9%103%77%0%248%244%232%220%211%181%243%236%214%128%116%82%253%251%246%33%29%18%176%163%125%252%252%251%220%213%192%238%236%233%187%174%138%162%148%108%109%102%84%131%127%117%181%172%145%211%

And I managed to send to have the same buffer on my NodeJS, the problem is to convert these bytes into a file, I tried to use a convert but I am able to have an exactly copy, the header is kind of the same.
The image is a GIF and I can have the same first few letters: GIF89a2

There is a special converter to recreate the file?

Hello All,

I'm hoping to do something similar with an Arduino Uno and the GPRS v2.0 shield. Please help me understand but to have an image appear on my website I will need the gprs to send the image in bytes then have my server parse the image? If so my main question is how will I parse the byte data? I have been using thingspeak, would I do something similar to the plugins provided by thingspeak?

Thank you for any help.

Also, I am unable to find out how to send an image as an SMS to another phone from the GPRS shield. :slight_smile:

To send picture by GPRS it must be encoded ..

Base 64 is the simplest but is wasteful on data alternatively encode each byte as 2 x hex asc II characters

i.e

byte 00111101 send as 3 the hex of 0011 and E the hex of 1101..