Hey guys
I finally bought the 4G sim hat! I’ll try keep this as brief as possible. You guys sent me a link, which doesn’t cover all my questions, and when I remove my 4g sim from my current Optus modem router I’ll have zero internet until I get the 4G hat up and running, so I’m gathering as much info as I can for offline referencing.
My only question for now is what interface name and protocols do I give the pi Ethernet port so that a switch can connect to it?
Ethernet interfaces are typically labelled as “ethX” from the Pi, e.g. eth0, eth1, etc.
If your ethernet interface is not listed, add one. If your network switch is capable of providing an IP via DHCP, set the protocol to “DHCP Client”. Alternatively, configure the switch with a static IP.
Hey Zach
Thanks for the reply. I actually wrote down the product code (SKU) in the title. CE07826. That’s the one I purchased.
And your advice, Ok yea, that makes sense thanks. I attached a screenshot to make sure. I’ll assign the pi eth0 port as “Ethernet adapter eth0 LAN”, which I can then connect a switch to it?
Dan actually sent me another link, looks exactly what I need, so I’ll have that offline as well to follow.
I know I’m being pedantic, but I don’t have any other internet connection and once I start I’d like as much info as possible to get me up and running. I’ll get started in about an hour or so
quick update. I had to enable uart and spi, i2c etc for the usb connection to be seen to the 4G sim hat. I wasn’t familiar with vim and so I removed the sd card and used another raspberry pi os to edit it and add those entries in /boot/config.txt. (raspi-config isn’t installed in openwrt)
Also Openwrt doesn’t have the waveshare 7600 4g sim drivers installed. When I go to choose “create an interface” and choose a device, I should be able to see usb0 (connected to the 4G hat), but it’s not showing.
Chicken and egg problem, as I foresaw. All good though, I don’t mind learning, just hope it works.
I need to “wget” that waveshare file (which Tim does in the yt vid) and then sudo make install etc. but I have no internet. So I removed the sim from the 4g hat, put it back in my Optus router and tried connecting the pi (openwrt) to my wifi. It connected, but I couldn’t ping anything, so still no internet.
I was hoping to be able to do a fresh install of raspberry pi os and then install waveshare drivers, and then wget openwrt, but openwrt only comes as prebaked images.
Next, I’m going to try a direct Ethernet connection from my Optus 4g modem to the pi. (I know it’ll mess up my router settings, but no other options, all good again)
So it’s done. 4g hat up and running.
I have another problem now, I am only getting 3G speeds, or very slow 4g speeds.
would attaching a larger antenna help?
QMI does not work, it keeps searching for device even though I’ve installed all necessary drivers and dependencies, I have only been able to get it working with the modem manager protocol option
Also this would be more openwrt based questions, is there anyone at core electronics who has actually installed tested and ran it on a pi?
Here’s a short…(it was supposed to be) tutorial for setting this up. Using raspberry pi 4b 1gb ram.
*Note, THIS applies for Australian users, with an activated Optus 4G sim using the APN name “connect” or “yesinternet”, and using the MBIM protocol… it may be slightly different if you are in another country.
** Don’t install the hat…yet
If the 4g SIM card is your only form of internet (like it was for me), then you will need to connect your pi running openwrt to some form of internet to install necessary drivers to get the hat running. Leave the SIM card in your isp provided modem/router for now.
*** If you do have internet (other than the 4g sim) that’s fine, but still don’t attach the hat yet.
DO NOT EXPAND OR RESIZE PARTITIONS after flashing. If you’re curious and check them (using df -h or gparted) you’ll notice 4mb of unallocated space before and after the 64mb boot partition.
It is due to partition alignment to match the typical 4MB erase segment size. It is normal and not a security issue. Don’t remove it
openwrt runs off ram, and I don’t use more than 90mb ram under any load. (At most 18 Ethernet connected devices and a few wifi iPads etc). So this is just a heads up, don’t go pre buy a 1tb ssd or m.2 thinking it’s going to improve performance, just get a larger micro sd and make a backup. The image takes literally less than 1min to flash and approx 5min to set up and running (this tutorial).
If you are going to install docker or other services / packages that require more than the 104mb of root partition space, that’s fine, as you will be extending that partition forward into the rest of the unallocated space, (which if your using a 32gb sd card, you’ll have approx. over 28gb of unallocated space).
Plug in a laptop or PC into your raspberry pi onboard Ethernet port, - you automatically receive an IP address, give it a moment. DHCP does it’s thing. (Make sure you don’t connect any form of internet to the your laptop or pc… we don’t want to mix subnets).
Go to 192.168.1.1 log in with root / password (yes password is the default password)
Change password (which gives you automatically gives access to ssh) save and apply.
Set local time, go to System>System (down the bottom change Timezone),…save and apply.
Change DNS on your LAN interface. Go to Network>interfaces and on the top interface (LAN) click edit. Click on advanced settings tab, and enter dns for google, cloudflare (8.8.8.8, 1.1.1.1) or whatever you want, click the + button to add it,.save and apply.
Connect to home wifi so you can update and install packages.Go to Network>Wireless and hit the scan button on the radio0 interface. (The top one). When it finds your wifi, connect, enter password. Always…save and apply
You should now have internet access. you can log in via ssh to check using
root / ( new password you created before). Ping google and say hi. It’s also easier to copy paste the commands in ssh, as Luci (the web gui for openwrt) only allows installing one package at a time.
For the MBIM protocol, openwrt already has the packages in its repo which makes it really simple to install. Openwrt uses opkg package manager (as opposed to apt in Debian).
Add any other tools you may need like htop curl make etc… I wasn’t familiar with vim, (pre installed) hence nano in my list above, and you’ll need a text editor. Modeswitch might be needed later on, and you need picocom to talk to the modem.
Depending on what else you want to do with your hat, you might need to enable a few other things, using nano…
nano /boot/config.txt
#here you can paste the following at the bottom, (use down arrow key to move direction)
So now we have all the drivers installed and config files edited accordingly.
The last few steps before we shutdown is to firstly add the shutdown feature to the Luci web interface. This makes it easier if you’re always in the web interface, rather than opening an ssh session (which you should disable after setting up for security reasons). Note if you are in ssh, to shutdown you need to use the command
poweroff
The shutdown command commonly used is not installed, and doesn’t work. Eg.
shutdown -h now
When you’re in an ssh session, you’re always root, so no need for “sudo” and be careful not to mess files up, (even though it doesn’t take long to do all this again, and you probably will😉)
Now before you poweroff, you need to change your IP address settings of the LAN interface and delete the wifi interface you created (to connect and give you internet).
You won’t be needing to connect back to your wifi anymore. I found that by releasing /deleting the interface the numbering system for assigning interfaces didn’t get too cluttered (this was a debugging thing, so you can just disable it if you really want and keep it there, but remember this wants to connect to the internet and you will now be providing the internet (with the hat you will soon install), so don’t mess things up.,make sure it’s disabled or delete the interface to be sure you followed my exact steps).
*Note: You are currently on the 192.168.1.1 subnet. If you have devices on your network, eg. Network cameras, raspberry pi’s, pc’s, NAS, that were configured with a static IP on your original, “DIFFERENT” subnet, you are going to need to change your IP on your openwrt raspberry pi to that subnet. Your raspberry pi openwrt is now ready to be the boss, the router, and modem of the family.
So for e.g. Your previous local subnet was 192.168.3.0/24, you now need to change your LAN interface static IP to 192.168.3.1
In Luci web, go to Network>Interfaces and the top one, LAN (which you changed the DNS back in step 5.) click edit and on the “general settings” tab you’ll see your current IP address below, ie. 192.168.1.1
Change this to whatever you HOME network subnet is, or as in the example above, 192.168.3.1…save and apply.
Poweroff the pi
Install the hat, as shown in this video by Tim from core-electronics
BIG NOTE:bangbang:
You don’t need to install any of the drivers in that video for this to work with openwrt. I tried it for you all… it can lead to issues lol, but if you know what you’re doing and want to swap between using openwrt and an actual phone/sms than please feel free to add any instructions!
Once the hat is installed, power it on. You can plug your pc, or laptop back in and wait for dhcp to assign you an address. You should now be on the newly created subnet, (the one you have always been on, but the one which your Optus modem/router used to control….). One final step is to make sure your modem is in the correct mode.
—Forgive me if I sound like a noob, but I’ve only recently learnt all this in the past week or so, and using picocom and the AT commands was a whole other level.
From what I gathered, you can put the modem into a number of modes.
QMI, MBIM, or modemmanager (mm) being the ones we are working with here.
but I have not been able to find the actual difference in using mm over MBIM.
I have however been able to get this working with mm, (modemmanager), it’s pretty much the same tutorial as above but with a few different steps to get the mm protocol running. Both mm and MBIM give you 1 day of uptime. This is the other small quirk, instead of having 24/7 uptime, (like previously with my Optus modem/router, which I could go for months to years without rebooting, unless a power outage or Optus hack lol) , openwrt for some reason loses connection around the 24hour uptime mark. This can vary, others have 12hours, so I don’t want to complaint, but if it’s at all possible I’d like to know why. Possibly as I have a dynamic public IP from my isp, (rarhter than a static one?), is it maybe the Optus modem/router sends special pings back to Optus saying, “yes…I’m living in the correct device”, and when the device says, “im now living life in a pi”, Optus cuts signal and the only way to restore connection is with a reboot?
We can automate the reboot procedure later with watchcat, but for now we want to create the mbim interface and finish this install. (If your device doesn’t show in the steps below, read further on for what to do next).
In the Luci web interface go to Network>interfaces then at bottom click on the green “add new interface” button.
Fill out these fields in the general settings tab, and leave everything else as default.
Name: SIM7600, Protocol: MBIM Cellular, Device: add the /dev/cdc one, like this
Then go to the firewall tab and add this interface to wan.
Save, then save and apply (on the main page).
Reboot the device.
When it powers back on you should be connected to the internet. All up and running.
If for any reason your device didn’t show in setting up the interface, try unplugging the usb from the pi and plugging it back in again. Sounds trivial, but don’t ask me how many hours passed before I tried that. If that fails, we need to check the modem and which protocol it’s running.
Type the following
picocom /dev/ttyUSB2
You are now in the picocom session which requires special commands.
Here is a link to my post on openwrt forum
where Andrew was kind enough to help me with the actual AT commands. To try wrap this up, the mbim protocol for the waveshare hat requires the 9003 parameter to be set like this in the picocom terminal.
AT+CUSBPIDSWITCH=9003,1,1
You exit the picocom session with ctrl-a and ctrl-x, [C-a] [C-x]
The forum link above shows the steps to release the usb if it’s not showing, and other steps I took along this journey. Feel free to ask for help on openwrt, they really are as good as the core electronics team.
If everything is all good, and you’re up and running, the last thing to do is set watchcat to reboot your device once you lose connection.
In Luci web interface, go to System>software and click the green coloured “update lists” button. Then in the search bar type in watchcat.
Install it. Refresh your browser. You now have a new tab. Go to Services>watchcat
Change the time it goes without signal from the default 6h to something more practical. Here’s my exact config
Open browser and check a site. Check speed test and please anyone who has one of these hats tell me the speeds you are getting. The best I’ve got is 47mb down and 18up. My original Optus router could get up to 200mbs. I’ve tried a more powerful antenna and that made the signal worse (incoming eBay feedback)… so that’s something I’m going to debug by taking the actual pi to my friends house who lives next to a 4G tower.
Thanks for putting together that write up, it is extremely detailed and hopefully it helps out someone in the future looking to do the same as what you have done!