Gemalto is now part of the Thales Group, find out more.

You are here

Thales IoT Developer Community

Make a 4G Hotspot Router via ELS61 and RaspBerryPi3

Showcase, January 4, 2017 - 6:08pm, 10154 views

Recently I got a request from one customer for a ready-to-production solution of a 4G Wi-Fi hotspot router. In fact we don't have such solution or demo kit, but create one won't be difficult. Here is how I do it.


  • a RPi3 board with SD card and loaded most recent version of Raspbian
  • a ELS61-AUS or -US EVK depending on the region applies, a Starter Kit B80 is also required to connect with ELS61 EVK, and a SIM card with enough data plan for this hotspot router
  • a proper USB cable for ELS61 EVK to connect with RPi3
  • a proper USB cable to connect RPi3 with a USB power supply adapter or USB powerbank.
  • a USB powerbank or USB power adapter to power-up the RPi3 and ELS61.
  • a working knowledge about RPi3 and Raspbian usage
  • a working knowledge about how to configure ELS61 APN and WWAN port.

Now, before doing anything, log into RPi3, no matter via a serial console or SSH. After you can access to RPi3 Raspbian shell, connectiong the ELS61 EVK with RPi3 board via USB and turn-on the EVK via pressing the IGT button on B80.

Setup the ELS61 USB Ethernet Port

When attaching ELS61 via usb to any computer, it will enumerate to two types of devices, one is USB cdc_acm ****m, another is USB cdc_ecm ethernet. We'll use one of the USB ****m port to configure ELS61 via certain AT commands, and turn on it's USB ethernet function. To talk with one of the USB ****m port, on Raspbian or ordinary PC Linux one can use a terminal emulator utility like minicom or picocom, this is good for testing, but because I have to turn these at commands into a script that allow the RPi3 to automatically apply them after the ELS61 boot, i choose to use the "chat" utility which comes from the ppp package of Raspbian OS repository.

To ensure the RPi has chat utility installed, run

$ sudo apt update
$ sudo apt install ppp 

Once plugged-in ELS61 via USB to RPi3, you can use dmesg command to check kernel messages, it will report new device nodes and ethernet devices created due to the plugged-in ELS61, in my case ttyACM0~4 and eth1~2 are created:

[26897.282805] usb 3-7: new high-speed USB device number 9 using xhci_hcd
[26897.427164] usb 3-7: New USB device found, idVendor=1e2d, idProduct=005b
[26897.427166] usb 3-7: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[26897.427167] usb 3-7: Product: ELSx
[26897.427167] usb 3-7: Manufacturer: Cinterion Wireless Modules
[26897.463968] cdc_acm 3-7:1.0: ttyACM0: USB ACM device
[26897.466575] cdc_acm 3-7:1.2: ttyACM1: USB ACM device
[26897.467131] cdc_acm 3-7:1.4: ttyACM2: USB ACM device
[26897.467601] cdc_acm 3-7:1.6: ttyACM3: USB ACM device
[26897.468015] cdc_acm 3-7:1.8: ttyACM4: USB ACM device
[26897.468405] usbcore: registered new interface driver cdc_acm
[26897.468406] cdc_acm: USB Abstract Control Model driver for USB ****ms and ISDN adapters
[26897.478162] cdc_ether 3-7:1.10 eth1: register 'cdc_ether' at usb-0000:00:14.0-7, CDC Ethernet Device, 00:00:11:12:13:14
[26897.493516] cdc_ether 3-7:1.12 eth2: register 'cdc_ether' at usb-0000:00:14.0-7, CDC Ethernet Device, 00:00:11:12:13:16
[26897.493619] usbcore: registered new interface driver cdc_ether 

I'll choose /dev/ttyACM0 as the configuration ****m port, and use eth1 as the Internet connection port for RPi3, then utilize the hostapd package to turn RPi3 into a Wi-Fi hotspot, the traffic on wlan0 will route to eth1 for Internet connection.

For testing purpose, I created two scripts for turn-on and turn-off ELS61 and stored them to "/etc/chatscripts/" and "/etc/chatscripts/".

The content of /etc/chatscripts/ is 

READY-AT\r\n-OK At+CPIN?\r\n
READY-AT+CPIN=0000\r\n-OK ""
1,0-AT+CFUN=1\r\n-OK ""
OK AT+CMEE=2\r\n
0,0-AT+COPS=0\r\n-OK-AT+COPS=0\r\n-OK ""
OK AT\^SWWAN=1,1\r\n

The content of /etc/chatscripts/ is

SAY "Turn-off Cinterion Modem"
"" AT\^SMSO\r\n

The chat utility will follow the scripts and talk to /dev/ttyACM0 via the following command, you can check the output on console to see if they work or not:

$ chat -f /etc/chatscripts/ -sv < /dev/ttyACM0 > /dev/ttyACM0 

After verified the two scripts and be happy with them, to allow the RPi3 automatically configure the USB ethernet of ELS61, add eth1 related configuration to /etc/network/interfaces file

allow-hotplug eth1
iface eth1 inet dhcp
  pre-up /usr/sbin/chat -f /etc/chatscripts/ -v  < /dev/ttyACM0 > /dev/ttyACM0
  down /usr/sbin/chat -f /etc/chatscripts/ -v < /dev/ttyACM0 > /dev/ttyACM0 

The newly added 4 lines will allow RPi3 to bring-up eth1 once you turn-on the ELS61 EVK, and shutdown ELS61 gracefully when RPi3 is shutting-down.

Setup the Wi-Fi Hotspot

Now we can turn our attention to the Wi-Fi hotspot part of the project. I have to install two more software packages: "hostapd" and "isc-dhcp-server" to constitute a proper Wi-Fi hotspot router:

$ sudo apt install hostapd isc-dhcp-server 

And configure respective setting files resides under /etc directory of Raspbian.

The first file to touch is /etc/dhcp/dhcpd.conf. Uses

$ sudo nano /etc/dhcp/dhcpd.conf 

to edit the defult config file, you should back-up a copy if you need original file after changing it.

Please Comment the following lines...

option domain-name "";
option domain-name-servers,;

#option domain-name "";
#option domain-name-servers,; 

and un-comment this line


... to:


Then scroll down at the bottom of the file and paste below text:

subnet netmask {
    option broadcast-address;
    option routers;
    default-lease-time 600;
    max-lease-time 7200;
    option domain-name "local";
    option domain-name-servers,;

Next, to specify the interface that serving DHCP requests (wlan0 in this case), run:

$ sudo nano /etc/default/isc-dhcp-server 

Let's change this line:



Now I can assign a static IP address for wlan0 via editing /etc/network/interfaces file, but first let's shut it down:

$ sudo ifdown wlan0 

then edit the network interfaces file:

$ sudo nano /etc/network/interfaces 

Changing wlan0 section into text shown below:

allow-hotplug wlan0
iface wlan0 inet static
  post-up iw dev $IFACE set power_save off 

Now close the file and assign a static IP now for testing

$ sudo ifconfig wlan0 

The next piece of puzzle is /etc/hostapd/hostapd.conf. Even when freshly installed via running apt install hostapd, there is no default configuration file exist, you'll have to create one :

$ sudo nano /etc/hostapd/hostapd.conf 

and fill-in text as listed below:


Next, let’s configure the network address translation (NAT). To achieve this task, first we have to alter one line in /etc/sysctl.conf

$ sudo nano /etc/sysctl.conf 

un-comment or add the following line to the bottom the save the file:


And activate it immediately to allow setup new NAT rules and test them:

$ sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward" 

Now we can modify the iptables to create a network translation between eth1 and the wifi port wlan0

$ sudo iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
$ sudo iptables -A FORWARD -i eth1 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
$ sudo iptables -A FORWARD -i wlan0 -o eth1 -j ACCEPT 

These changes must be saved to make this happen on next reboot by running

$ sudo sh -c "iptables-save > /etc/iptables.ipv4.nat" 

And editing /etc/network/interfaces again

$ sudo nano /etc/network/interfaces 

Please appending below line under the pre-up line of eth1 section:

 up iptables-restore < /etc/iptables.ipv4.nat 

To make the change clear to reader, the /etc/network/interfaces file will now look like this:

source-directory /etc/network/interfaces.d

auto lo

iface lo inet loopback

iface eth0 inet dhcp

allow-hotplug eth1
iface eth1 inet dhcp
  pre-up /usr/sbin/chat -f /etc/chatscripts/ -v  < /dev/ttyACM0 > /dev/ttyACM0
  up iptables-restore < /etc/iptables.ipv4.nat
  down /usr/sbin/chat -f /etc/chatscripts/ -v < /dev/ttyACM0 > /dev/ttyACM0

allow-hotplug wlan0
iface wlan0 inet static
  post-up iw dev $IFACE set power_save off 

We have to run some tests to check if Wi-Fi hotspot function working, to start with, enable DHCP server first:

$ sudo service isc-dhcp-server start 

You can check if this service is up-and-running with this command

$ sudo service isc-dhcp-server status 

If it works, you'll see output like this:

$  sudo service isc-dhcp-server status
● isc-dhcp-server.service - LSB: DHCP server
   Loaded: loaded (/etc/init.d/isc-dhcp-server)
   Active: active (running) since 三 2017-01-04 22:37:52 CST; 1h 35min ago
  Process: 551 ExecStart=/etc/init.d/isc-dhcp-server start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/isc-dhcp-server.service
           └─618 /usr/sbin/dhcpd -q -cf /etc/dhcp/dhcpd.conf -pf /var/run/ wlan0 

You can test hotspot function via running this command:

$ sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf 

If the configuration is right, you'll see output text like below:

$  sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf
Configuration file: /etc/hostapd/hostapd.conf
Failed to create interface mon.wlan0: -95 (Operation not supported)
wlan0: Could not connect to kernel driver
Using interface wlan0 with hwaddr b8:27:eb:d7:22:e2 and ssid "ELS61Pi"
random: Only 18/20 bytes of strong random data available from /dev/random
random: Not enough entropy pool available for secure operations
WPA: Not enough entropy in random pool for secure operations - update keys later when the first station connects
wlan0: interface state UNINITIALIZED->ENABLED
wlan0: AP-ENABLED 
wlan0: STA e8:ab:fa:46:dc:e6 IEEE 802.11: associated
wlan0: AP-STA-CONNECTED e8:ab:fa:46:dc:e6
wlan0: STA e8:ab:fa:46:dc:e6 RADIUS: starting accounting session 586CF8BC-00000000
wlan0: STA e8:ab:fa:46:dc:e6 WPA: pairwise key handshake completed (RSN) 

And you'll be able to see the Wi-Fi SSID you specified inside /etc/hostapd/hostapd.conf through your smartphone or Laptop PC, try to connect to it via your phone or PC. If everything works, you can press CTRL+D to terminate the hostapd.

We aren't quite done yet, because we also need to tell hostapd where to look for the config file when it starts up on boot. Open up the default configuration file with sudo nano /etc/default/hostapd and find the line #******_CONF="" and replace it with ******_CONF="/etc/hostapd/hostapd.conf".

Now we have to integrate hostapd with ELS61 setup, let it runs right after eth1 is up-and-running, via editing again /etc/network/interfaces, insert

  post-up /usr/sbin/service hostapd start 


  post-down /usr/sbin/service hostapd stop 

to the eth1 section, place them before and after the line

  down /usr/sbin/chat -f /etc/chatscripts/ -v < /dev/ttyACM0 > /dev/ttyACM0 

The final form of /etc/network/interfaces file will look like this:

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo

iface lo inet loopback

iface eth0 inet dhcp

allow-hotplug eth1
iface eth1 inet dhcp
  pre-up /usr/sbin/chat -f /etc/chatscripts/ -v  < /dev/ttyACM0 > /dev/ttyACM0
  up iptables-restore < /etc/iptables.ipv4.nat
  post-up /usr/sbin/service hostapd start
  down /usr/sbin/chat -f /etc/chatscripts/ -v < /dev/ttyACM0 > /dev/ttyACM0
  post-down /usr/sbin/service hostapd stop

allow-hotplug wlan0
iface wlan0 inet static
  post-up iw dev $IFACE set power_save off 

Let's configure DHCP daemons to start at boot time:

$ sudo update-rc.d isc-dhcp-server enable 

It's time to reboot the RPi3 and see if it still works as expected:

$ sudo reboot -h now 

Please remember to turn-on B80 manually at RPi3 boot time 

The content presented here refered to lots of open resources regarding to RPi and Wi-Fi hotspot topic, one of the page I used as my reference is Turn a RaspBerryPi 3 into a WiFi router-hotspot.

Those configuration files mentioned above are attached as file, for reader's reference.

The scripts mentioned here should apply to both PLS8 and ELS61, however there is no B80-like adaptor board for PLS8, so is not used here.

The finished set is smaller enough to fit in a shoe box.

ELS61 and RPi3 in a shoe box

Hi Antony,

Thanks for the great tutorial.  I purchased the Cinterrion Concept Board based on EHS6 ME to provide GPRS (3G) connection to Raspberry PI 3 via USB connection. Then I will connected another PLC to Raspberry PI  with ethernet cable so that PLC will connect to the internet via Raspberry PI 3 and the Concept board. So far no luck.

I followed your tutorial. But the EHS6 doesn't have AT\^SWWAN=1 command. I also can't change the PIN of sim card with AT+CPIN=0000 command.

Could you please help? I would really appreciate that!!!

Thank and Regards,e



antonyshen's picture