You are here

Using Connect Shield with Raspberry Pi

Tutorial, February 16, 2017 - 12:32pm, 488 views

Just recieved the Cinterion® Connect Shield today. I found it provides "ON/OFF" pin so it's possible to control ELS61 boot from a embedded system. This inspires me to test it on a Raspberry Pi (RPi).

Cinterion® Connect Shield

The hardward part is easy, just use a male-to-female jumper leads to connect the "ON/OFF" pin on the Connect Shield to a GPIO on RPi, and an USB cable to connect with each other. I choose GPIO25 for toggling the "ON/OFF" pin.

The finished product will look like this, but still need some minor scripting to configure/setup the Connect Shield.

RPi with Connect Shield

Here I utilize my previous work for a Wi-Fi Hotspot router project, I copied the chat script used to configure ELS61 WAN port, and stored them to "/etc/chatscripts/els61-eth-on.chat" and "/etc/chatscripts/els61-off.chat".

The content of /etc/chatscripts/els61-eth-on.chat is 

TIMEOUT 60
READY-AT\r\n-OK At+CPIN?\r\n
READY-AT+CPIN=0000\r\n-OK ""
OK AT+CGDCONT?\r\n
IP-AT+CGDCONT=1,"IP","INTERNET"\r\n-OK ""
OK AT+CFUN?\r\n
1,0-AT+CFUN=1\r\n-OK ""
OK AT+CMEE=2\r\n
OK AT+COPS?\r\n
0,0-AT+COPS=0\r\n-OK-AT+COPS=0\r\n-OK ""
OK AT+CSQ\r\n
OK AT\^SWWAN=1,1\r\n
OK AT+CGPADDR\r\n
OK 

The content of /etc/chatscripts/els61-off.chat is

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

And the setup for corresponding WAN port interface for Raspbian is

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

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

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

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

To turn-on the Connect Shield, one can use a simple python script to toggle the GPIO 25. Here is how I do it and you can store this script in /usr/local/bin/els61_on.py on the RPi

#!/usr/bin/python

from gpiozero import LED
from time import sleep

els61 = LED(25)

print "Turn-on ELS61..."
els61.on()
sleep(1)
els61.off() 

Please remember to use "sudo chmod +x /usr/local/bin/els61_on.py" to mark it as runnable.

You can then put a line on the /etc/rc.local to to call this script and trigger ELS61 booting up with the RPi, or add a service file to Raspbian's /etc/systemd/system/ directory to autorun the python script on boot using systemd. Here is the content of my /etc/systemd/system/els61-on.service

[Unit]
Description=Turn On ELS61
After=multi-user.target

[Service]
Type=simple
ExecStart=/usr/local/bin/els61_on.py
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target 

The permission of the file needs to be set to 644:

sudo chmod 644 /lib/systemd/system/els61-on.service 

Now you can configure the systemd to start it during the boot sequence:

sudo systemctl daemon-reload
sudo systemctl enable els61-on.service 

Reboot the Pi and your custom service should run :

sudo reboot -h now 

After RPi booted up, you can check the status of your service using :

sudo systemctl status els61-on.service 

Or checking the LED on Connect Shield, if it gives off max brightness, it's booted-up.

You can use ifconfig to check if eth1 get an IP or not, if everything is OK, you should see similar result:

eth1      Link encap:Ethernet  HWaddr 00:00:11:12:13:14  
          inet addr:10.35.106.133  Bcast:10.255.255.255  Mask:255.0.0.0
          inet6 addr: fe80::2c06:6943:11d5:c018/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2955 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5658 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:813771 (794.6 KiB)  TX bytes:503643 (491.8 KiB) 

Now your RPi 4G CAT1 connection is ready to use.

RPi with 4G CAT1 connection

mikkelnielsen's picture
mikkelnielsen

Hi,

How did you receive it when it is not available on Gemalto webstore?

Regards, -Mikkel

antonyshen's picture
antonyshen

The ordering code for Connect Shield is : L30960-N5200-A100

You can contact local Gemalto sales with this order code to buy it.

Best Regards,
Antony Shen

mikkelnielsen's picture
mikkelnielsen

Hi Anthony,

I have received a connect shield today. The first step is to download installation package from developer.gemalto.com but I can't find any link? Can you help :-) Looking forward to share my work with the community.

Regards, -Mikkel

antonyshen's picture
antonyshen

Hi Mikkel,

Because I used it on Raspberry Pi, which is running Linux, and is capable enough to drive the ELS61, so I didn't try to download the installation package.

Best Regards,
Antony Shen

antonyshen