PPP Internet connection successful but can't make API calls over PPP

Problem:
Hi I am slightly confused with how to ensure that my LTE modem is used to connect my Pi to the internet instead of the Raspberry Pi’s internal Wifi module. I followed the steps in this tutorial for hardware setup, and this tutorial to establish a PPP internet connection and it was all successful (results of my ping below). However when I try to use the Python requests library to make a very light API call, it fails (I can elaborate if needed on what ‘failed’ means).

I know my Python code works because I used my Raspberry Pis internal Wifi module to try and it returned a 200 HTTP code response with the data. When I switch on my ppp0 interface and disconnect from my Wifi it doesnt work any longer. Am I supposed to keep my connection to my router on? shouldnt the LTE-M module become the router? Sorry for all the questions I am a beginner at modems and Linux. Thank you so much for any insight or help.

Things I’ve tried:

  • Changing my routing tables default route by deleting the default route (wlan0)
  • Checking signal quality (doesnt work even if signal is very strong)
  • Changing network providers from Rogers to Bell
  • Confirming I have a DNS assigned (primary is 8.8.4.4 and secondary is 8.8.8.8)

Hardware:

  • Raspberry Pi 4
  • Shield/Modem: I bought each component from this LTE-M kit except for the antenna, which I bought two of this kind of antenna but I think this is fine because I see it says suitable for LTE-M applications.

Scripts:

  • uname -a
operator@raspberrypi:~/Documents/virtuals/env $ uname -a 
Linux raspberrypi 6.1.0-rpi6-rpi-v8 #1 SMP PREEMPT Debian 1:6.1.58-1+rpt2 (2023-10-27) aarch64 GNU/Linux

  • lsusb
(env) operator@raspberrypi:~/Documents/virtuals/env $ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 005: ID 046d:c054 Logitech, Inc. Bluetooth mini-receiver
Bus 001 Device 004: ID 045e:07b6 Microsoft Corp. Comfort Curve Keyboard 3000
Bus 001 Device 006: ID 1bc7:1101 Telit Wireless Solutions ME910C1
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

  • lsusb -t
(env) operator@raspberrypi:~/Documents/virtuals/env $ lsusb -t
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/1p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
        |__ Port 1: Dev 6, If 0, Class=Vendor Specific Class, Driver=option, 480M
        |__ Port 1: Dev 6, If 1, Class=Vendor Specific Class, Driver=option, 480M
        |__ Port 1: Dev 6, If 2, Class=Vendor Specific Class, Driver=option, 480M
        |__ Port 1: Dev 6, If 3, Class=Vendor Specific Class, Driver=qmi_wwan, 480M
        |__ Port 2: Dev 4, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M
        |__ Port 2: Dev 4, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
        |__ Port 4: Dev 5, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M

  • cat /etc/os-release
(env) operator@raspberrypi:~/Documents/virtuals/env $ cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

  • ‘sudo pon’ AT commands.
(env) operator@raspberrypi:~/Documents/virtuals/env $ sudo pon
pppd options in effect:
debug		# (from /etc/ppp/peers/provider)
updetach		# (from /etc/ppp/peers/provider)
persist		# (from /etc/ppp/peers/provider)
dump		# (from /etc/ppp/peers/provider)
noauth		# (from /etc/ppp/peers/provider)
remotename 3gppp		# (from /etc/ppp/peers/provider)
/dev/ttyUSB2		# (from /etc/ppp/peers/provider)
115200		# (from /etc/ppp/peers/provider)
lock		# (from /etc/ppp/peers/provider)
connect chat -s -v -f /etc/chatscripts/chat-connect -T super		# (from /etc/ppp/peers/provider)
disconnect chat -s -v -f /etc/chatscripts/chat-disconnect		# (from /etc/ppp/peers/provider)
nocrtscts		# (from /etc/ppp/peers/provider)
modem		# (from /etc/ppp/peers/provider)
asyncmap 0		# (from /etc/ppp/options)
lcp-echo-failure 4		# (from /etc/ppp/options)
lcp-echo-interval 30		# (from /etc/ppp/options)
hide-password		# (from /etc/ppp/peers/provider)
novj		# (from /etc/ppp/peers/provider)
novjccomp		# (from /etc/ppp/peers/provider)
ipcp-accept-local		# (from /etc/ppp/peers/provider)
ipcp-accept-remote		# (from /etc/ppp/peers/provider)
ipparam 3gppp		# (from /etc/ppp/peers/provider)
noipdefault		# (from /etc/ppp/peers/provider)
ipcp-max-failure 30		# (from /etc/ppp/peers/provider)
defaultroute		# (from /etc/ppp/peers/provider)
usepeerdns		# (from /etc/ppp/peers/provider)
noccp		# (from /etc/ppp/peers/provider)
noipx		# (from /etc/ppp/options)
abort on (BUSY)
abort on (NO CARRIER)
abort on (NO DIALTONE)
abort on (ERROR)
abort on (NO ANSWER)
timeout set to 30 seconds
send (AT^M)
expect (OK)
AT^M^M
OK
 -- got it

send (ATE0^M)
expect (OK)
^M
ATE0^M^M
OK
 -- got it

send (AT+CPIN?^M)
expect (OK)
^M
^M
+CPIN: READY^M
^M
OK
 -- got it

send (AT+CSQ^M)
expect (OK)
^M
^M
+CSQ: 31,2^M
^M
OK
 -- got it

send (AT+CREG?^M)
expect (OK)
^M
^M
+CREG: 0,5^M
^M
OK
 -- got it

send (AT+CGREG?^M)
expect (OK)
^M
^M
+CGREG: 0,5^M
^M
OK
 -- got it

send (AT+COPS?^M)
expect (OK)
^M
^M
+COPS: 0,0,"Rogers Wireless",8^M
^M
OK
 -- got it

send (AT+CGDCONT=1,"IP","super",,0,0^M)
expect (OK)
^M
^M
OK
 -- got it

send (ATD*99#^M)
expect (CONNECT)
^M
^M
CONNECT
 -- got it

  • ping with ip address
root@raspberrypi:/home/operator: ping -I ppp0 -c 5 8.8.8.8
PING 8.8.8.8 (8.8.8.8) from 100.93.123.205 ppp0: 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=57 time=199 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=57 time=398 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=57 time=198 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=57 time=157 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=57 time=194 ms

--- 8.8.8.8 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4005ms
rtt min/avg/max/mdev = 156.698/229.147/397.945/85.847 ms

Hi,

It looks like your LTE modem is successfully connected to the internet, as shown by the successful results of the ping using the ppp0 interface.

Check the Default Route:
After establishing the PPP connection, make sure that the default route is set to use the ppp0 interface. You can use the ip route show command to check the routing table.

Firewall:
Ensure that there are no firewall rules blocking outgoing traffic on the ppp0 interface. Check both the Raspberry Pi’s firewall and any external firewalls.

Logs and Error Messages:
Check the logs for any error messages or warnings related to the Python code or network connections. The journalctl command can be useful for this purpose.

Thank you, I will try this and get back if there are any other questions!