Skip to content

Raspberry Pi

Timothy Woo edited this page Jul 1, 2019 · 5 revisions

Update by @cellphonedude (6/30/19): As a prerequisite for Raspbian buster, run sudo apt-get install libperl-dev libgtk2.0-dev libgudev-1.0-dev

The following information was posted by @bliteknight in issue #15 (but may be edited from the original text) and explains how to use the Botletics SIM7000 shield with Raspberry Pi:

Using with Raspberry Pi

Before you beign, you'll need the following:

  • A LiPo battery as stated in the wiki - I used a 3.7V 1800mAH LiPo
  • A micro USB male-to-male connector - I spliced two cables to make one, power is not needed, just the data cables (white & green)

The reason for the LiPo battery is to supply enough current so the board can function without turning off the Pi. The reason for the micro USB cable is because we are going to use this board as a QMI modem and not mess with any of the AT commands stuff. It is still supported but I'd rather just have a internet connection and my choice of communication protocol to use.

Step 1: Install the latest stretch image I'm using 2019-04-08-raspbian-stretch-lite and once you've gotten your configuration setup the way you want via raspi-config (ssh, timezone, locale etc) you are ready to begin the setup.

Step 2: Power the device The Pi zero has a 5V out which can be connected to the 5V in on the board (the one close to the two ground points); Just wire / solder / the 5V to 5V and the pi ground to ground. The battery full light should come on and say on when it has power. If the LTE (blue led) is not blinking, hold down the power on switch for a couple seconds to turn it on. Once both lights are active plug in the device via the micro USB male-to-male cable.

Step 3: Check for device detection Run this command ls -al /dev/ttyUSB* you should see ttyUSB0 ttyUSB1 ttyUSB2 ttyUSB3 ttyUSB04

Also, if you run ifconfig You should see a wwan0 device listed If you don't see this then you might need to install the drivers like mentioned above, but going off a fresh image for the Pi zero I did not encounter this issue. To test AT commands, I would install gammu sudo apt install gammu then create a config file at this location ~/.gammurc

[gammu]
device = /dev/ttyUSB2
connection = at

The AT port will be ttyUSB2 and to validate your device run this command sudo gammu identify This should spit out the device information.

Step 4: QMI Modem Setup Alot of the information I got here is based on the documentation here: http://www.embeddedpi.com/documentation/3g-4g-modems/raspberry-pi-sierra-wireless-mc7455-modem-raw-ip-qmi-interface-setup But there are some bits missing that I had to search countless forums to find a solution - install the latest libqmi-utils

apt remove libqmi-utils
wget http://www.freedesktop.org/software/libqmi/libqmi-1.22.4.tar.xz
tar -vxf libqmi-1.22.4.tar.xz
cd libqmi-1.22.4
./configure --prefix=/usr --disable-static
make && sudo make install

This will take a long time on the Pi zero w, about 30 mins to complete. If you have a Pi3 I would do it on there and run make -j 4 && sudo make install to speed things up

Once that is done, it's time to fix a bug in the qmi code: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=845979 Edit this file: /usr/bin/qmi-network find this string: START_NETWORK_ARGS="apn='$APN'" and change it to: START_NETWORK_ARGS="'apn=$APN'"

Or if you would rather do it from the terminal, run this command sudo sed -i "s/apn='/'apn=/g" /usr/bin/qmi-network

Once that's done, install udhcpc sudo apt install -y udhcpc

As this modem only works in raw-ip mode (- not fully clear what that is); even if you connect to a carrier you will not be assigned an IP until you request one, which is what udhcpc does.

Next, create a file to store your APN information sudo nano /etc/qmi-network.conf I'm using a thingsmobile SIM card so my info looks like this APN=TM,ip-type=4 save the file, and now it's time to test the connection.

Step 5: Internet Please? First, try to ping google.com via the wwan0 interface for 4 tries: ping -c 4 -I wwan0 www.google.com you should see 100 packet loss, now it's time to tell the modem to connect to the carrier via:

qmicli -d /dev/cdc-wdm0 --device-open-"net=net-raw-ip|net-no-qos-header" --wds-start-network="apn=TM,ip-type=4" --client-no-release-cid
  
ip link set dev wwan0 down

echo Y > /sys/class/net/wwan0/qmi/raw_ip

ip link set dev wwan0 up

The first command is the connect command, you might not need the --wds-start-network parameter, but I put it in there to make sure it used the correct APN values. The next three commands put the modem in raw-ip mode (more info about that from the URL in Step 4) Once that command completes, it's time to get an IP address udhcpc -i wwan0 You should see a sending discover output in the terminal a handful of times, before getting an IP with a lease time. Once you have that and can verify your IP is that same via ifconfig you can test pinging google again ping -c 4 -I wwan0 www.google.com This time you should have a 0% packet loss.

Hopefully this will help anyone who wants to use this board with a raspberry pi and also doesn't want to be limited to using AT commands.

I was able to have it up and running using nodejs + socket.io to do bi-directional communication from the pi and my server, sending data from an attached sensor every second in real time for 3+ days with no issue.