Usage

If you've followed the guide this far you should be at a point where you're ready to enable the GPRS connection. Just to recap, make sure you've connected FONA to your Raspberry Pi or BeagleBone Black, that you've verified FONA can communicate with your serial connection, and that you've installed the PPPD software and configured it. If you've missed any of these steps make sure to go back to the previous pages and complete them.

Before you test the GPRS connection, first disconnect any wired or wireless networking connections you might already have with your hardware and restart the device. This will help ensure there are no issues or confusion over accessing the PPP interface vs. other network interfaces. You might need to connect a monitor and keyboard to your hardware to access it when all the network connections are disconnected (however on a BeagleBone Black you can connect the USB connection to a computer and access it through its private network connection I found in my testing).

To bring up the FONA GPRS connection and setup a PPP connection, run the following command:
sudo pon fona
The command should exit with no response. Don't worry, behind the scenes PPPD should be setting up the connection. You can check the system log file to see what PPPD is doing and if it hit any errors. Execute the following command to show the log for PPPD:
cat /var/log/syslog | grep pppd
If the PPP connection was successfully created you should see something like this at the end of the log file:
Jul  8 03:47:40 raspberrypi pppd[2321]: pppd 2.4.5 started by root, uid 0
Jul  8 03:47:40 raspberrypi pppd[2321]: Serial connection established.
Jul  8 03:47:40 raspberrypi pppd[2321]: Using interface ppp0
Jul  8 03:47:40 raspberrypi pppd[2321]: Connect: ppp0 <--> /dev/ttyAMA0
Jul  8 03:47:41 raspberrypi pppd[2321]: PAP authentication succeeded
Jul  8 03:47:42 raspberrypi pppd[2321]: Could not determine remote IP address: defaulting to 10.64.64.64
Jul  8 03:47:42 raspberrypi pppd[2321]: local  IP address 21.144.145.193
Jul  8 03:47:42 raspberrypi pppd[2321]: remote IP address 10.64.64.64
Jul  8 03:47:42 raspberrypi pppd[2321]: primary   DNS address 10.177.0.34
Jul  8 03:47:42 raspberrypi pppd[2321]: secondary DNS address 10.168.185.116
You might need to wait a few seconds for the PPP connection to be setup before checking the PPPD log.

One thing to look for is the flashing of the red LED on FONA--if the GPRS connection is established the red LED will flash quickly (about twice a second).

If you see an error in the PPPD log then there was likely a problem setting up the GPRS connection. You can examine the raw serial communication with FONA by looking at the chat command log. Execute the following to view the chat log:
cat /var/log/syslog | grep chat
The most recent lines will be at the end of the file. Look for any kind of error message that might indicate something unexpected has happened, like a PIN being required, APN being incorrect, etc. For reference here's what I see when a PPP connection is successfully setup with my cell provider:
Jul  8 03:47:40 raspberrypi chat[2323]: abort on (BUSY)
Jul  8 03:47:40 raspberrypi chat[2323]: abort on (VOICE)
Jul  8 03:47:40 raspberrypi chat[2323]: abort on (NO CARRIER)
Jul  8 03:47:40 raspberrypi chat[2323]: abort on (NO DIALTONE)
Jul  8 03:47:40 raspberrypi chat[2323]: abort on (NO DIAL TONE)
Jul  8 03:47:40 raspberrypi chat[2323]: abort on (NO ANSWER)
Jul  8 03:47:40 raspberrypi chat[2323]: abort on (DELAYED)
Jul  8 03:47:40 raspberrypi chat[2323]: abort on (ERROR)
Jul  8 03:47:40 raspberrypi chat[2323]: abort on (+CGATT: 0)
Jul  8 03:47:40 raspberrypi chat[2323]: send (AT^M)
Jul  8 03:47:40 raspberrypi chat[2323]: timeout set to 12 seconds
Jul  8 03:47:40 raspberrypi chat[2323]: expect (OK)
Jul  8 03:47:40 raspberrypi chat[2323]: AT^M^M
Jul  8 03:47:40 raspberrypi chat[2323]: OK
Jul  8 03:47:40 raspberrypi chat[2323]:  -- got it
Jul  8 03:47:40 raspberrypi chat[2323]: send (ATH^M)
Jul  8 03:47:40 raspberrypi chat[2323]: expect (OK)
Jul  8 03:47:40 raspberrypi chat[2323]: ^M
Jul  8 03:47:40 raspberrypi chat[2323]: ATH^M^M
Jul  8 03:47:40 raspberrypi chat[2323]: OK
Jul  8 03:47:40 raspberrypi chat[2323]:  -- got it
Jul  8 03:47:40 raspberrypi chat[2323]: send (ATE1^M)
Jul  8 03:47:40 raspberrypi chat[2323]: expect (OK)
Jul  8 03:47:40 raspberrypi chat[2323]: ^M
Jul  8 03:47:40 raspberrypi chat[2323]: ATE1^M^M
Jul  8 03:47:40 raspberrypi chat[2323]: OK
Jul  8 03:47:40 raspberrypi chat[2323]:  -- got it
Jul  8 03:47:40 raspberrypi chat[2323]: send (AT+CGDCONT=1,"IP","web.omwtoday.com","",0,0^M)
Jul  8 03:47:40 raspberrypi chat[2323]: expect (OK)
Jul  8 03:47:40 raspberrypi chat[2323]: ^M
Jul  8 03:47:40 raspberrypi chat[2323]: AT+CGDCONT=1,"IP","web.omwtoday.com","",0,0^M^M
Jul  8 03:47:40 raspberrypi chat[2323]: OK
Jul  8 03:47:40 raspberrypi chat[2323]:  -- got it
Jul  8 03:47:40 raspberrypi chat[2323]: send (ATD*99#^M)
Jul  8 03:47:40 raspberrypi chat[2323]: timeout set to 22 seconds
Jul  8 03:47:40 raspberrypi chat[2323]: expect (CONNECT)
Jul  8 03:47:40 raspberrypi chat[2323]: ^M
Jul  8 03:47:40 raspberrypi chat[2323]: ATD*99#^M^M
Jul  8 03:47:40 raspberrypi chat[2323]: CONNECT
Jul  8 03:47:40 raspberrypi chat[2323]:  -- got it
Jul  8 03:47:40 raspberrypi chat[2323]: send (^M)
You can see the log roughly mirrors the commands to send and expect in the /etc/chatscripts/gprs configuration. Notice my network's APN, 'web.omwtoday.com', is sent in the AT+CGDCONT command--you should see your APN on that line.

Unfortunately cellular providers might have specific restriction or requirements for setting up a GPRS connection so it's difficult to troubleshoot all possible failures in this guide. If you're running into errors try to search the web for details on configuring PPP with your provider.

If you don't see any errors in the PPPD or chat logs, congratulations your FONA's GPRS connection should be tethered to your Raspberry Pi/BeagleBone Black! To check that there is a new ppp network interface run the following command:
ifconfig
You should see a few interfaces, but in particular there should be a 'ppp0' interface. For example I see:
ppp0      Link encap:Point-to-Point Protocol  
          inet addr:21.144.145.193  P-t-P:10.64.64.64  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3 
          RX bytes:72 (72.0 B)  TX bytes:111 (111.0 B)
If you don't see a ppp0 interface, carefully check the PPPD and chat logs above to make sure there isn't some error setting up the GPRS connection.

Now test pinging adafruit.com with the GPRS connection by executing:
ping adafruit.com
Make sure you disconnected all other network connections before attempting the ping command or else you might actually be sending the ping through your wired/wireless network connection!

If the ping is successfull you should see a result like:
PING adafruit.com (207.58.139.247) from 21.144.145.193 ppp0: 56(84) bytes of data.
64 bytes from vps3.ladyada.net (207.58.139.247): icmp_req=1 ttl=45 time=316 ms
64 bytes from vps3.ladyada.net (207.58.139.247): icmp_req=2 ttl=45 time=275 ms
64 bytes from vps3.ladyada.net (207.58.139.247): icmp_req=3 ttl=45 time=773 ms
64 bytes from vps3.ladyada.net (207.58.139.247): icmp_req=4 ttl=45 time=293 ms
Press Ctrl-C to stop the ping command.

If you receive an error like 'unknown host adafruit.com' then your cell provider didn't provide a DNS configuration. Try manually adding OpenDNS servers to your resolve.conf by following these steps.

If you receive no response with the ping command, check that your SIM and cellular provider allows you to access the internet. If possible, try using the SIM in a GSM phone with access to data to check it can access the internet.

If the ping command succeeded, now try accessing adafruit.com in a text-based web browser. Execute the following command:
elinks http://www.adafruit.com/
The elinks text-based web browser should open and load adafruit.com. Note that because the browser is text-based you will see a stripped down and minimal version of Adafruit's web site.

Notice the maximum speed of the internet connection is quite slow. Over a 2G GPRS connection you will only see about 5-10 kilobytes/second of download speed! This connection is far too slow to transfer large amounts of data, however it's perfect for talking to web services, sending emails, tweets, running a simple server, etc.

Press q and enter to close elinks.

Once you've verified you can ping and access adafruit.com then your FONA GPRS connection should be ready to use however you desire!

Remember, your cell phone provider might put limits or extra charges on your data usage so be careful before heavily using the GPRS connection! Also be extra careful if your provider charges extra for international or roaming data access--don't be the next person to rack up a $20,000+ cell phone bill!


When you're done with the GPRS connection it's easy to stop it by executing:
sudo poff fona
Again no response will be written to the output, but you can confirm PPPD has stopped by checking its log file and running ifconfig to confirm the ppp0 interface is gone.

Automatic PPP Connection On Boot

If you'd like to configure your device to automatically bring up the PPP connection with FONA on boot, it's easy to do so by updating the network configuration. First make sure you've verified you can manually bring up the PPP connection in the previous steps. Also be sure you've disabled the kernel serial console on the Raspberry Pi, or updated uEnv.txt with the BB-UART4 device tree overlay on the BeagleBone Black--skipping either of those steps will fail to bring up the PPP connection on boot!

Edit the /etc/network/interfaces file by executing:
sudo nano /etc/network/interfaces
At the bottom of the file add a new interface configuration with the following text:
auto fona
iface fona inet ppp
	provider fona
This configuration will tell your device to bring up the FONA PPP peer automatically on boot. The configuration in /etc/ppp/peers/fona will be used to set up the PPP connection.

Save the file, exit the editor, and reboot your device. As the device boots up, watch the FONA LEDs to see that the red LED starts flashing quickly to indicate a GPRS connection is activated. Once the device has finished booting, log in and check the ppp0 interface is up by running ifconfig. You can also check the PPPD and chat logs with the commands from earlier in the setup. If there are errors, check the logs to see what issues might be occuring.

If there are no errors, congratulations your device is now configured to automatically connect to the internet through FONA's GPRS connection! Enjoy accessing the internet from anywhere there is a 2G GPRS cellular connection!
Last updated on 2015-08-18 at 01.28.19 PM Published on 2014-07-08 at 03.16.08 PM