Let's say you have a Raspberry Pi 4G/LTE Cellular Modem Kit and an available cellular connection. If you need to create a second Wi-Fi network in addition to your primary LTE network, the easiest solution is to create a called hotspot, an access point where the other devices you can control can connect to access the internet.
Let’s start with setting up the LTE hotspot.
📖 Note
This method applies to Raspberry Pi OS versions prior to Debian Bookworm. For the latest Raspberry Pi OS, it's recommended to use nmcli. Raspberry Pi official hotspot documentations
Hardware
All the hardware needed to create our LTE hotspot is already included in the Raspberry Pi 4G/LTE Cellular Modem Kit. To set up the hardware please follow: Raspberry Pi 4G/LTE Cellular Modem Kit > Getting Started > Hardware Setup.
Preparation
Update / Upgrade Raspberry Pi OS packages.
sudo apt update && sudo apt upgrade -yReboot the system.
sudo rebootInstall requirements.
sudo apt install hostapd dnsmasq -yStop services to configure them.
sudo systemctl stop hostapd dnsmasqCellular Internet
Set up cellular internet connection. Please follow the instructions below to establish the cellular internet connection using ECM mode.
- Internet Connection with Quectel EC25 using ECM Mode
- Internet Connection with Telit LE910Cx module using ECM Mode
Configuration
❗️ Attention
Please note the cellular interface name. In this tutorial, the cellular interface is usb0. If your cellular interface is different, change all usb0 interface names.
Configure a static IP for the wlan0 interface.
sudo nano /etc/dhcpcd.confAdd the following lines at the end open file.
Configure the DHCP server (dnsmasq). Save the old configuration file and start configuring the clean configuration file.
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
sudo nano /etc/dnsmasq.confAdd these lines to file and save.
Configure Access Point
We can now configure the access point details. We will set up a password-protected network so that only people with the password can connect.
Create a new file with the following command
sudo nano /etc/hostapd/hostapd.confAdd these lines to the file and save. Change "NETWORK" and "PASSWORD" with yours.
Make sure each line has no extra spaces or tabs at the end or beginning.
Now we will tell the Pi where to find this configuration file.
sudo nano /etc/default/hostapdFind #DAEMON_CONF="" line and change as below. Then save.
Forward internet connection by using bridge. First, install bridge-utils.
sudo apt-get install bridge-utils -yCreate bridge and forward.
sudo brctl addbr br0
sudo brctl addif br0 usb0Configure bridge.
sudo nano /etc/network/interfacesAdd following line at the end of the file and save.
Check the hostapd service is masked. If service is masked, unmask the service.
sudo systemctl unmask hostapd
sudo systemctl enable hostapdand then reboot.
sudo rebootFinishing up!
Restart the Raspberry Pi and everything should now work as it should!
