GPRS with the SM5100B Arduino GSM Shield
The SparkFun SM5100B Arduino GSM Shield is a really neat device. Unfortunately there's not a whole heap of good documentation around, more unfortunately a lot of the forum blog posts discussing it are incomplete or actually wrong. There's a bit around on SMS functionality but when it comes to GPRS support things are even worse.
Recently John Boxall from tronixstuff has done a couple of getting started tutorials for the SM5100B which contain some of the best documentation around. He hasn't (yet?) covered GPRS though.
I (Hadley) have recently been trying to help a customer work through some issues with GPRS on the SM5100B Shield and made some time after hours to look into it. I thought I'd post my findings hopefully to the benefit of others.
I'm not going to provide code at this stage as I don't have a complete working solution, just a bunch of rough hacked together debugging code to see why things aren't working. Instead I'm going to post a check list of things that you might want to look out for. It is an area (one of many) that I'm personally interested in so perhaps I'll have time to write some more code in the future, if so I'll post an update.
So without further ado, a list of things to watch out for when doing GPRS on the SM5100B GSM Shield;
- It's been said before but it needs saying again. Make sure you have enough power! You might get away with sending an SMS with a 1A supply or even USB, but doing GPRS, you'll need at least 2A. I used a 2A supply and it wasn't enough, 2.5A did it. If you don't have enough power your module will randomly reset itself you'll see various +SIND: lines scroll past and things won't work. You need to plug the power supply into a pin on the shield, either VIN if it's 12V or the 5V pin if it's a regulated 5V supply.
- You need to use a hardware UART, unfortunate but true. NewSoftSerial doesn't cut it for receiving data base enough from the SM5100B module. It seems to work fine for reading responses from AT commands so you can use it for SMS etc. When reading the response from a network socket you'll get dropped characters and missing data. Because of this, you'll either need an Arduino Mega with it's extra UARTs, or use the single UART on an Uno and have difficulty uploading code and debugging.
- Leading on from the last point, you need to increase the SM5100B UART speed from 9600 to 115200. I haven't tried speeds in between but this is what I found worked. The SM5100B module spits out data quickly, if you don't keep up it will drop it and then it's gone. Even with a hardware UART I had to up the speed to keep up. The symptom of this is making an HTTP GET request and receiving only part of the response back from the server.
- The final note on the same subject, don't mess around when data is available from the socket. If there's data there start reading it off straight away, if not you'll run into the same issue with buffers.
- When sending data with AT+SDATASEND, you need to encode the data to HEX and set the correct length - of the HEX encoded data.
- When you send CTRL-Z, don't use Serial.println() - this will send extra characters such as a line feed which will confuse the module. If you can only do something once, such as send an SMS, open a socket etc. and after that continuously get "+CME ERROR: 4" this is probably the problem. Use "Serial.print(26, BYTE);" rather than println.
So that's my list of things I learnt so far while debugging GPRS on the SM5100B. There's certainly more to learn, as I said I haven't got a complete working sketch yet. If you've got any questions or comments please feel free to say so below.