LTE Cat 1 Pi HAT internet via Cellular

Hi, I’ve recently purchased the seeed LTE hat for the raspberry Pi. I want to setup the module like the ‘Pieverywhere’ device so it automatically connects to the internet when booted.



I can’t seem to find much information for this board? I’ve managed to get the APN set and pinged google with great success. However I’m not experienced in using AT commands, so I’m unsure how to setup the LARA-R2xx module so it automatically connects to the internet?

I can configure the modem using the serial node in node-red, so I just need the list of AT commands to configure the modem to connect to the LTE network.



Any help would be greatly appreciated

Hallo there,

I have the same problem.



I’m using this seeed LTE Cat 1 Pi HAT device (LARA-R211) with Raspbian Buster Lite (2019-09-26)

I can connect the modem via serial lines and USB with minicom.

The UMTS modem is connected to network and ping and DNS request works.

But I did not get an interface ppp0 to use this connection.

How should the wvdial.conf looks like, or the pppd command.

Tanks a lot!



here the minicom log



AT+COPS?

+COPS: 0,0,“Telekom.de”,7

OK



AT+CGDCONT?

+CGDCONT: 1,“IP”,“internet.telekom.MNC001.MCC262.GPRS”,“10.47.171.209”,0,0,0,0,0,0

+CGDCONT: 8,“IP”,"",“0.0.0.0”,0,0,0,0,0,0

OK



AT+UPSD=0,1,“internet.telekom”

OK



AT+UPSDA=0,3

OK

+UUPSDA: 0,“10.158.106.255”



AT+UPING=“8.8.8.8”

OK

+UUPING: 1,32,“dns.google”,“8.8.8.8”,47,72

+UUPING: 2,32,“dns.google”,“8.8.8.8”,47,44

+UUPING: 3,32,“dns.google”,“8.8.8.8”,47,36

+UUPING: 4,32,“dns.google”,“8.8.8.8”,47,35



AT+USIMSTAT?

+USIMSTAT: 0

OK



AT+UDNSRN=0,“ftp_url”

+UDNSRN: “195.34.89.241”

OK

Same question here! After a couple of hours I now have some better understanding on how most things should work. The MT is now connected to the LTE carrier and I’m able to do things like DNS resolving and HTTP requests. But how to get an actual ethernet connection from the Raspberry Pi host?



We are using the Seeed LTE Cat.1 Pi HAT (LARA R211) on a Raspberry Pi 3 B+ (Raspbian) connected through the GPIO interface. Is it actually possible to get an ethernet connection over the GPIO interface? Or do I need to use USB for the connection? Our bandwidth requirements are very minimal. Would somebody be willing to write an example or give us some clues?



This is what I have so far to connect to the carrier (4G Vodafone in The Netherlands) and to do successful DNS resolving.

[code=python]
from ublox_lara_r2 import *

u = Ublox_lara_r2()
u.initialize()
u.reset_power()

u.debug = True

u.sendAT(‘AT+COPS=2\r\n’)
u.sendAT(‘AT+CGDCONT=1,“IP”,“internet”\r\n’)
u.sendAT(‘AT+COPS=0\r\n’)
u.sendAT(‘AT+COPS?\r\n’)
u.sendAT(‘AT+CGDCONT?\r\n’)
u.sendAT(‘AT+CGACT=1,1\r\n’)
u.sendAT(‘AT+UPSD=0,100,1\r\n’)
u.sendAT(‘AT+UPSD=0,0,0\r\n’)
u.sendAT(‘AT+UPSDA=0,3\r\n’)
u.sendAT(‘AT+UDNSRN=0,“mediaserve.nl”\r\n’)
[/code]

So how to get an ethernet connection on the Raspberry Pi host?

I’ve got it working through USB now using wvdial.



/etc/wvdial.conf
</s><i> </i>[Dialer Vodafone] Init1 = ATZ Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 Init3 = AT+COPS=2 Init4 = AT+CGDCONT=1,"IP","internet" Init5 = AT+COPS=0 Modem Type = USB Modem Stupid Mode = 1 Auto Reconnect = off Baud = 460800 New PPPD = yes Modem = /dev/ttyACM0 ISDN = 0 Phone = *99# Username = { } Password = { } <e>

/etc/ppp/peers/wvdial
</s><i> </i>noauth name wvdial usepeerdns defaultroute replacedefaultroute <e>

Then run wvdial Vodafone to create a ppp0 interface and connect with the MT. And we have a working connection!



Now I only want to know if it’s also possible without the USB cable.

So I have things working now like I want to. To start with a notice, using only the GPIO UART connection, things will get really slow. I’m getting an average of less than 100 Kbps bandwidth. For me this is acceptable because I only need it as a remote terminal connection.



I will try to explain how I got things working. But still you shouldn’t expect an easy solution. The problem we need to solve, at least in my case, is that Raspberry Pi has one UART interface on the GPIO but we need two interfaces. We need one interface to send AT commands and we need one interface for the PPP connection. We are going to need the n_gsm kernel module which is not included in Raspbian by default. Then we are going to need a multiplexer (CMUX) that will allow us to have 2 logical connections over 1 hardware UART interface.



1. Make sure your system is up to date, install dependencies and update the kernel
</s><i> </i>sudo -i apt update apt dist-upgrade apt install bc bison git build-essential rpi-update sync reboot <e>

2. Download kernel sources so we can make our own kernel module
</s><i> </i>wget -O /usr/bin/rpi-source https://raw.githubusercontent.com/notro/rpi-source/master/rpi-source chmod +x /usr/bin/rpi-source /usr/bin/rpi-source -q --tag-update rpi-source <e>

3. Build the kernel module for experimental GSM MUX line discipline support
</s><i> </i>cd /root/linux/drivers/tty/ make -C /lib/modules/$(uname -r)/build M=$(pwd) -e CONFIG_N_GSM=m modules cp /root/linux/drivers/tty/n_gsm.ko /lib/modules/`uname -r`/kernel/drivers/tty/ depmod modprobe n_gsm <e>

You may want to add the module in your /etc/modules as well if you want to load it automatically on boot.



4. Download and compile the GSM MUX driver (CMUX)
</s><i> </i>cd /usr/local/src/ git clone https://github.com/Rtone/cmux.git cd cmux <e>

Here we need to make some changes to the cmux.c source file before compiling. I’m using the LARA R211, so maybe you need to tweak this for your own environment. Please refer to the diff that I made for my own setup.

[code=diff]
diff --git a/cmux.c b/cmux.c
index 1af0f50…f13edfe 100644
— a/cmux.c
+++ b/cmux.c
@@ -29,6 +29,7 @@
#include <linux/types.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/sysmacros.h>
#include <fcntl.h>
#include <unistd.h>
#include <err.h>
@@ -50,13 +51,13 @@
#endif

/* serial port of the modem */
-#define SERIAL_PORT “/dev/ttyS1”
+#define SERIAL_PORT “/dev/ttyAMA0”

/* line speed */
#define LINE_SPEED B115200

/* maximum transfert unit (MTU), value in bytes */
-#define MTU 512
+#define MTU 1400

/**

  • whether or not to create virtual TTYs for the multiplex
    @@ -66,7 +67,7 @@
    #define CREATE_NODES 1

/* number of virtual TTYs to create (most modems can handle up to 4) */
-#define NUM_NODES 4
+#define NUM_NODES 2

/* name of the virtual TTYs to create */
#define BASENAME_NODES “/dev/ttyGSM”
@@ -313,15 +314,9 @@ int main(void) {
* to fit your modem needs.
* The following matches Quectel M95.
*/

  •   if (send_at_command(serial_fd, "AT+IFC=2,2\r") == -1)
    
  •           errx(EXIT_FAILURE, "AT+IFC=2,2: bad response"); 
    
  •   if (send_at_command(serial_fd, "AT+GMM\r") == -1)
    
  •           warnx("AT+GMM: bad response");
      if (send_at_command(serial_fd, "AT\r") == -1)
              warnx("AT: bad response");
    
  •   if (send_at_command(serial_fd, "AT+IPR=115200&w\r") == -1)
    
  •           errx(EXIT_FAILURE, "AT+IPR=115200&w: bad response");
    
  •   sprintf(atcommand, "AT+CMUX=0,0,5,%d,10,3,30,10,2\r", MTU);
    
  •   sprintf(atcommand, "AT+CMUX=0,0,0,%d,253,3,254,0,0\r", MTU);
      if (send_at_command(serial_fd, atcommand) == -1)
              errx(EXIT_FAILURE, "Cannot enable modem CMUX");
    

[/code]

After making the changes, we should be ready to compile, install and run the multiplexer.

</s><i> </i>make cp cmux /usr/bin/cmux cmux <e>

5. Using the new serial interfaces



We should now be able to use the new interfaces. Instead of using /dev/ttyAMA0 we can now use both /dev/ttyGSM1 and /dev/ttyGSM2. I’m using the first one with pppd and the second one to send AT commands simultaneously. For some reason I was unable to keep using wvdial, so I dropped that completely and started using pppd directly. For both cmux and pppd I created a systemd service that runs on boot, after each other, so at startup Raspbian is setting up the multiplexer and connecting with the internet over PPP. When the connection is live I’m sending an SMS message to report that the terminal is now online.



Good luck and let me know if anyone has any questions :smiley:



Thomas Lobker,

MediaServe international

@thomas675 impressive work! Are these steps all the same today? Have any of these steps been integrated into the latest versions of the GSM MUX driver, kernel module, etc and no longer necessary? Thanks!