In compliance with high industry standards

Browse our Blog. You will find multiple applications, solutions, code examples. Navigate using the tag cloud or search using specific criteria

How to work with Raspberry Pi GPRS module

How to configure the first steps to work with industrial GPRS Raspberry Pi PLC


In this blog you will learn how to configure the GPRS module in your industrial Raspberry PLC. By reading this post, you will understand how the module is implemented and how to set up the configurations.

 Previous readings

We recommend you to read the following posts to understand the program in this blog. They can also be useful to get you started with your brand new industrial Raspberry Pi PLC:

  • How to access the Raspberry Pi PLC Read >>

  • How to change the IP in Windows and Linux Read >>


In order to work with the GPRS module, you will need any of our industrial GPRS family Raspberry Pi based PLC for industrial automation. On this example, we will be working with the Raspberry Pi PLC & GPRS 21 IOs:


The SIM800L module is the main component of the Adafruit FONA 800 cards so you can use the library made for these cards with the cheap modules that assemble the SIM800L.

In this tutorial we focus on setting up the environment for using the Raspberry Pi industrial PLC GPRS module, but we will also show you how to test the module sending AT commands by the serial monitor.


The connections between the Raspberry and the GPRS module can be seen on the following image. The serials are crossed for being able to send data properly.



GPRS Connection

Inserting the SIM card

We are going to proceed to insert the SIM card correctly into the PLC. To do this, you must first locate the SIM card inlet of the PLC, which is located on the top cover of the device. You will be able to see the SIM card symbol on the screen printing; the entrance is just below. To insert the card, you must so as shown in the following pictures:

Inserting the SIM card
Inserting the SIM card


In order to work with the Raspberry PLC GPRS module, you have to enable the hardware serial while the console must be disabled. To do this, you should run the raspi-config interface.

> sudo raspi-config

This will open a new window with different Raspberry configuration options. Once there, you will have to choose the option interfacing options and then the P6 option, serial to enable or disable the serial connection. Then you will be asked if you want a login shell, which you will have to reject, choosing to not work with it. After it, a new question regarding about enabling the serial port hardware will be displayed. You must accept it.

If you have done the steps succesfully, a message will be displayed saying that the serial login shell is disabled and the serial interface is enabled. 

Hardware Test

This step is a pre-test to check the hardware connection to the SIM800L and can be skipped. 

After setting the first configuration, you will have to install the Minicom terminal emulator. SIM800L works with the ttyS0 port and for this example you will be using a 115200 baud rate. You will execute the following command to open the serial communication with the minicom:

> sudo minicom -D /dev/ttyS0 -b 115200

Once inside, type AT and press enter and the GPRS module will return an OK message. AT is the simplest of the AT commands, used for testing the module.

Interface configuration

After testing the module with the AT command, you will enable an interface to work more comfortably in future uses. In order to do this, you will working using the PPP (Point-to-Point) link layer protocol. By default, the Raspberry Pi PLC controller will have the tool and its dependencies preinstalled, otherwise install ppp and the newest libcap0 version using the apt-get install command.

To make the first configurations with the GPRS module, you will have to modify the following files located on their corresponding directories. You can download the requiered files here:

  • ppp-secrets: /etc/ppp/pap-secrets

  • gprs-connect: /etc/ppp/gprs-connect

  • gprs-disconnect: /etc/ppp/gprs-disconnect

  • gprs: /etc/ppp/peers/gprs

  • ppp0: /etc/network/interfaces.d/ppp0

The files GPRS-connect and GPRS-disconnect will be tests used to do the basics of communications, getting an IP for a future use. As you can see in them, on the left side of the lines there is the response that GPRS will send after getting the command specified on the right side of the line. For example, AT+CGDCONT=1,"IP","YOUR-APN-HERE","",0,0 will expect an OK.

The file that would be running the whole process is the GPRS. On this example, the GPRS file is called the gprs-connect, if you want to implement different functions, you have to configure them there.

In some of these files you must apply some changes to be able to work with the SIM. The files have some sections where you can find the option “YOUR-USER-HERE”, “YOUR-PASSWORD-HERE” or “YOUR-APN-HERE”,  where the user must configure his username, password and the APN he is using. Some of the files will require modification with the sudo superuser option. The options you will need top modify are:

  • /etc/ppp/pap-secrets: User and Password

  • /etc/ppp/gprs-connect: APN

  • /etc/ppp/peers/gprs: User

After setting this configuration, a reboot of the module must be set in order to apply the changes.

> sudo reboot

If there are any problems during the process, doing a manual reset to the GPRS module should solve the issue. To do the reboot, execute the following commands:

echo 16 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio16/direction
echo 1 > /sys/class/gpio/gpio16/value
echo 0 > /sys/class/gpio/gpio16/value
echo 1 > /sys/class/gpio/gpio16/value
echo 16 > /sys/class/gpio/unexport

Want to know more?

Follow our blog for technical questions and programming TIPs.

Do you want more information?

Just fill the form!

Tell me more!