From Wiren Board
This is the approved revision of this page, as well as being the most recent.
Jump to navigation Jump to search
Other languages:
English • ‎русский

The Wiren Board controller is equipped with GSM/GPRS-module which can provide the following functions:

  • send/receive SMS
  • connect to the Internet via GPRS

See the module description for the full list of features:

  • 3G modem in Wiren Board 5 and Wiren Board 6: SIM5300E
  • 2G modem in Wiren Board 4, 5 and 6: SIM800 or M660A;
  • Wiren Board Smart Home 3.5, Wiren Board 4:


Getting started

Connect the antenna and insert the SIM card before starting the controller. If you have enabled the controller without a SIM card, restart the modem using the wb-gsm utility after installing it (see below).

Modem in Linux

Inside the controller, the modem is connected to the processor in one of two ways:

  • via UART port (device /dev/ttyGSM (previously: /dev/ttyAPP0)) - all modems, including 3G;
  • via USB port (devices /dev/ttyACM0-/dev/ttyACM6) - 3G only.

You can work with the modem at a low level by sending commands to the port /dev/ttyygsm or /dev/ttyACM0, respectively. For 3G-connection port UART is not suitable due to the bandwidth limitations of the UART-channel, you should use ACM-port /dev/ttyACM0.

Modem control pins PWRKEY and RESET are also connected to the processor, you can turn off or restart the modem using them. Usually you do not need to work with them directly - the reboot is performed by the wb-gsm utility (see below), but also direct access to these contacts via GPIO is implemented (read more about GPIO, look for the corresponding names in the table).

Enabling the module

By default, the modem is automatically turned on when the controller boots. Then it can be turned off and reloaded with the wb-gsm utility (the utility is included in the standard image in the wb-utils package).

$ wb-gsm on #  turn on the device
$ wb-gsm off #  turn off the device
$ wb-gsm reset #  reboot the enabled device
$ wb-gsm restart_if_broken #  enable or reboot if the modem is not responding

SIM7000E 2G/NB-IoT modems

The SIM7000E 2G/NB-IoT modem is set to select GSM and LTE networks automatically by default. However, in a network or with aSIM card without NB-IoT support, the modem is not registered in the GSM (GPRS) network. In order for the modem to be able to register in the GSM network, it is necessary to force it into 'GSM only' mode.

In the terminal mode of the modem, for example, in the minicom program (see below section #low-Level work with the module via AT-commands), you must enter the mode selection command:


Possible values:(command AT+CNMP=?): 2-Automatic,13-GSM Only,38-LTE Only,51-GSM And LTE Only

The mode is remembered and active and after power off, you need to set the mode once.

To return to IoT mode, run the following command:


Sending and receiving SMS and USSD


The easiest way to work with SMS is with the help of Gammu program (this is a fork of gnokii utility, which has ceased to be developed).

(here is a brief instruction below, see the full documentation on the project website)

  1. Create a configuration file by running gammu-config
    1. In the Port parameter, specify /dev/ttyGSM
    2. In the Connection parameter, specifyat115200
  2. Command examples
$ gammu networkinfo # view the networkand the base station which you are connected to
$ gammu geteachsms # print all SMS
$ gammu getussd '#100#' # balance request in transliteration on MTS russian GSM mobile operator 
$ gammu sendsms TEXT +79154816102 -unicode -text 'Hi' # send 'Hi' to the number

SMS and USSD in russian(if needed) or different languages

SMS and USSD in Russian in gammu still do not work always properly, so commands can be useful to switch the language of USSD and transcoding incoming and outgoing SMS into transliteration:

Operator USSD SMS
translit Russian translit Russian
МТS *100*6*2# *100*6*1# unknown unknown
Меgafon *105*0# *105*9# unknown unknown
Beeline *111*6*2# *111*6*1# unknown unknown
Тele2 *120# *120*1# unknown unknown

Internet connection

The modem must be turned on before you can access the Internet. To do this manually or in the network interface configuration file (see below), run the following command

wb-gsm restart_if_broken

Quick setup of automatic Internet access

In the standard software set of the Wiren Board controller connection settings in ppp protocol for MTS, MegaFon and Beeline mobile operators are included. If you are using one of them, run the following command to start the connection

pon mts # you can replace mts with megafon or beeline

To disable the connection, run

poff mts # you can replace mts with megafon or beeline
File /etc/network/interfaces, starts connection to MTS automatically

To start the connection automatically, open the /etc/network/interfaces file and uncomment/edit the following lines:

auto ppp0
iface ppp0 inet ppp
  provider mts #  you can replace mts with megafon or beeline

But if you want the connection to restore itself when it breaks, see the full instructions below.

Step-by-step instructions for setting up a permanent GPRS connection

  • Connect the antenna to the GSM connector
  • Insert SIM card into micro-SIM slot 1
  • Turn on the modem executing wb-gsm restart_if_broken
  • If your controller is equipped with 3G-modem, open file /etc/ppp/peers/your_provider (e.g. MTS) replace the /dev/ttyGSM with /dev/ttyACM0

In the /etc/networks/interfaces file, comment out the section associated with ppp0 and add the following lines:

auto ppp0
iface ppp0 inet ppp
provider mts
#restart modem if it's broken or frozen
pre-up wb-gsm restart_if_broken
#Then wait for it to load and find the network.
pre-up sleep 10
  • Run the ifup ppp0 command — after 15 seconds, the ppp0 interface will be available.
  • After rebooting, the interface will be automatically turning on and restore the connection after the cellular connection is lost.

Full instruction

Access to the Internet via GPRS is provided via PPP using the pppd service. For its operation, you need to create a configuration file that corresponds to the settings of your operator. Configuration files for the "big three" rusian operators are pre-installed in the standard image. The files are stored in the /etc/ppp/peers and /etc/chatscripts directories. For other operators or special APNs, create your configuration files based on standard ones. To do this, use the pppconfig utility (installed with apt-get install pppconfig) to create a connection configuration file with parameters for your operator (for example, MTS). You can also count on the instructions. Note the 115200 nocrtsct settings that must be present in the configuration files.

If you connect to the Internet via 3G, you should replace the UART port (/dev/ttyGSM (or /dev/ttyAPP0 in older controller models)) with the CDC-ACM port (/dev/ttyACM0) in the configuration file for your operator. This is necessary to ensure that the communication speed is not limited to the modem UART port bandwidth:


After creating the configuration file, start the connection by running

pon connection name

or by editing /etc/network/interfaces, as written above.

For connection to restart itself when it breaks, and to execute it an unlimited number of times, add the following lines to the connection settings (the settings file of the selected operator is in the /etc/ppp/peers directory) :

maxfail 0

if they're not written. In the latest versions of controllers, these settings are configured by default.

The usage of the ppp0 interface configuration in /etc/network/interfaces file gives the most comprehensive ability to control establishing the connection to the Internet. The most popular option is the ability to execute commands before installing and after enabling/disabling the ppp0 interface.

In the /etc/network/interfaces file, you can use the standard iface pre-up, up, post-up, down, pre-down, post-down options to configure ppp. They define the commands that will be executed on the various phases of initialization/de-initialization interface. Detailed features of their functioning are described in man interfaces, section IFACE OPTIONS .

As an example, we will give here the parameters that we recommend to use when setting up a ppp connection with mobile Internet providers.
auto ppp0
iface ppp0 inet ppp
provider mts
#restart modem if it's broken or frozen
pre-up wb-gsm restart_if_broken  
#Then wait for it to load and find the network.
pre-up sleep 10

For ppp-interfaces, there are directories, executable files from which are also run at different phases of connection establishment. But, if, for example, ethernet interfaces, these scripts must be located in the /etc/network/if-down directories.d, if-post-down.d, if-pre-up.d, if-up.d, then the corresponding directories for ppp interfaces are in /etc/ppp/ip-down.d, ip-up.d, etc. (for details on their purpose and function, see PPP HOWTO).

DNS and routing settings

Important! By default, the ppp0 interface does not add a new default route via ppp during initialization, if such a route exists and is configured, for example, via eth0. If required, you can modify the routing table through scripts in the ip-down.d, ip-up.d directories. In the simplest case, you can assign different metrics to the default gateways, so that if one falls, the second begins to be used. However, the situation, when the interface is operating normally but the traffic does not pass at the provider level, makes such a mechanism unusable. See the next section on how to use a ppp connection as a backup.

DNS server addresses are replaced with those that were received from the mobile provider. If you are using DHCP on the ethernet interfaces and the interface ppp0, the /etc/resolv.the conf changes when a connection is established through each of these interfaces according to the DNS server addresses received from the provider.

As a supplementary measure to improve reliability in the presence of two connections, we can offer the use of DNS servers that are independent of the provider, for example GoogleDNS (8.8.8, and OpenDNS (, These servers are used frequently to determine the health of the network channel on a specific interface (ping -c5 -I eth0 or ping -c5 -I ppp0

Note that when you deinitialize the ppp0 interface, all created associated with this interface routes will be automatically deleted.

Using GPRS as a backup channel

The easiest way to ensure fault tolerance is to specify two default routes with different metrics, for example: for eth0 interface, specify metric 10:

   auto eth0
   iface eth0 inet dhcp
   pre-up wb-set-mac
   hostname WirenBoard
   metric 10 

and for the interface — metric 100:

   auto ppp0
   iface ppp0 inet ppp
   ## select provider: megafon, mts or beeline below
   provider mts
   metric 100
   pre-up wb-gsm restart_if_broken
   pre-up sleep 10

In this case, if the connection via eth0 is lost (cable disconnection, switch disconnection, etc.), the route via the ppp0 interface becomes the default route.

For more complex cases where the physical connection on the eth0 interface is not lost, it is recommended to use scripts (based on the availability of any network bridging on the Internet through one of the interfaces) that switch the default route. The Internet offers many solutions to this kind of problem, you can choose one of them.

If the controller is normally connected to the Internet via Ethernet or Wi-Fi, and GPRS is to be used only in case of a main channel failure, this mode of operation is called failover. It usually works like this:

  1. Work is organized through the main channel.
  2. The availability of Internet access through the main channel is constantly checked.
  3. In case of problems, a backup connection is started and the default gateway settings are changed.
  4. The main connection is constantly checked, and if the internet access is restored through it, the system returns to work via it, changing the default gateway.

As an example, we specify two instructions for the organization of such a mode of operation:


Low-level work with the module via AT-commands

Read the instructions - Working with a serial port from Linux. Note the settings: 115200, 8N2, no hardware flow control.

For interactive mode:

  • run minicom with the following key that creats the job profile to the port (transmission speed, parity, etc.):
 $ minicom -s /dev/ttyGSM

Minicom Settings

  • Go to settings (press Ctrl+A, then O), select Serial port setup, set port /dev/ttyGSM,set speed and parity - 115200, 8N1, Hardware flow control - No, Software flow control - No
  • Save settings: Save setup as _dev_ttyGSM
  • Then run as minicom /dev/ttyGSM (all settings will be taken from the profile name /dev/ttyGSM that we previously created)
  • Your first command should be AAAAAAAAAT - the module automatically detects the communication speed (see SIM900R)
  • With the second command, simply run AT. You should get the answer OK.

Command examples

(some commands may vary for some modules, see the module documentation for details)

  • To synchronize the speed of the port (not a real command)
  • All networks list
  • Signal strength (see here)
  • Dialing +79154816102
  • Set baud rate port to a fixed value 115200
  • Request time from the built-in real-time clock (RTC) module
  • Get module IMEI-code (xxxxxx is a unique number)



Multiplexing ports

The modem supports multiplexing mode which creates virtual ports,you can simultaneously work with the modem via these ports. For example, one port can be used to open a PPP session for GPRS, another - to receive and send SMS, check the balance, etc. see CMUX for details. This mode is not supported for 2G modems.