2

I have a USB modem (Huawei E1552) connected a RPi running Raspbian Stretch. It is connected at remote location that needs persistent internet. For example, for ssh or pushing code remotely.

I have managed to get it "working" using wvdial and a couple of lines in /etc/profile to get it to automatically to connect on reboot. It is very very cruel and I would like it to have some fail safe (e.g. reconnect on lost connection). The profile looks like this:

echo waiting for device to boot...
sleep 10
screen -S APN -dm sudo wvdial defaults
echo adding to route...
sleep 10
sudo route add default dev ppp0 

Can someone suggest a better method? I am not very familiar with Linux.

I have also tried the qmi method here but it did not work for me. I think the /etc/network/interface is now deprecated?

Thanks!

  • Questions: (1) Is your model EXACTLY this one: AliExpress Unlocked Huawei E1552 3G WCDMA/HSDPA/UMTS 2100MHz Wireless Modem USB Dongle Supports SMS Service - US$15 ( https://www.alibaba.com/product-detail/Unlocked-Huawei-E1552-3G-WCDMA-HSDPA_60758658423.html?spm=a2700.7724857.normalList.26.1e417715UazSns ) (2) If you software/bash shutdown and reboot, wll Rpi automatically connect? (3) If you hardware/power reset (say, manually switch off and then switch on 5V DC power, will Rpi automatically connect? – tlfong01 Jul 05 '19 at 05:23
  • 1) It does not look exactly like that one, as in it is a local carrier branded. 2) Yes 3) Yes It seems to reconnect in those situations. Maybe all I need is to call wvdial from a bash script in a while loop like https://wiki.archlinux.org/index.php/Wvdial#Auto_Reconnect suggests? – Tony Baloney Jul 05 '19 at 07:14
  • Ah the look is not important. What is important is the model number and the spec. Sometimes OEMs products have same model number might have different options or spec. Of course you can use wvdial to connect. But what can you do if your Rpi freezes for some reason, and your bash script is dead? – tlfong01 Jul 05 '19 at 07:33
  • So you need a software watchdog timer to automatically reset Rpi, in case it freezes. Or you can use a hardware realtime clock such as DS3231 RTC module to reset Rpi every 1200 midnight, (2) Or use another slave Rpi detecting master Rpi freezes, then use a GPIO pin to reset master Rpi. – tlfong01 Jul 06 '19 at 01:27
  • I actually do have a hardware switch right now! I will have a look at this more in term of some fault tolerance on the bash and wvdial side. Glad to see I am not crazy in the head! – Tony Baloney Jul 07 '19 at 04:53
  • Well, you might like to read an answer to the general question: How to automatically reboot a frozen Rpi at a remote location? ( https://raspberrypi.stackexchange.com/questions/99584/cut-power-on-a-remote-raspberry-pi-3-via-another-raspi ) – tlfong01 Jul 07 '19 at 08:29

1 Answers1

1

Try following this tutorial, it helped me bring ppp0 elegantly and it has a connection watchdog. I haven't tested that part, but it looks like it would do the trick.

Basically you can create an entry in /etc/network/interfaces or a file in /etc/network/interfaces.d setting up ppp0

Mine is as follows:

auto ppp0
iface ppp0 inet wvdial
provider vodafone #the name you configured for wvdial
pre-up /etc/ppp/wait-dialup-hardware ttyUSB0 20
pre-up /etc/ppp/wait-dialup-hardware ttyUSB1 20
pre-up /etc/ppp/wait-dialup-hardware ttyUSB2 20
pre-up sleep 30
post-up echo "3G (ppp0) is online"

You could then add another post-up action that could run another script with the command route add default dev ppp0

  • 1
    We're looking for long answers that provide some explanation and context. Don't just give a short meaningless answer, only with a link (link-only answer); explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed or you risk to get down votes. – Ingo Mar 25 '20 at 11:32