If you’ve seen my previous post, you’ll know I was trying to get a decent backup of my Raspberry Pi which I have managed to do.
The next step was to get it to be able to stream a video over HTTP – I tried zoneminder but it’s just too much for the Pi. So instead I used mjpg_streamer, much more lightweight and from what I’ve read seems to use the GPU of the Pi.
Anyway the trickiest bit of setting up the Pi was trying to get the Wifi working on startup and getting the broadband to connect on startup. So I thought I’d share my config files for you guys to see.
For Wifi my config is as below. Although most links on the web say you need to configure a wpa_supplicant.conf, for me this caused issues (I’m unsure as to the cause) but this config worked for me. Just replace YourSSID
with your networks name and NetworkPass
with your network password.
The key thing here is the allow-hotplug
and the auto wlan0
, it tries to set it up as soon as it is available but doesn’t throw an error message.
auto lo
iface lo inet loopback
iface eth0 inet dhcp
auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-ssid "YourSSID"
wpa-psk "NetworkPass"
#wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
#iface default inet dhcp
Now onto the more tricky topic of setting up the 3G modem, mine is a Huawei E160 with USB ID 12d1:140c. First thing is first, just make sure you have usb-modeswitch installed and it is working (in newer versions of Linux this just works). And also install wvdial
:
apt-get install wvdial
Now edit the /etc/wvdial.conf
to the same the following:
[Dialer Defaults]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Stupid Mode = 1
Modem Type = Analog Modem
ISDN = 0
Phone = *99#
Username = three
Password = three
Modem = /dev/ttyUSB0
Dial Command = ATDT
Baud = 9600
check DNS = no
auto DNS = no
[Dialer three]
Init2 = ATZ
Init3 = ATE0 V1 &D2 &C1 S0=0 +IFC=2,2
Init5 = AT+CGDCONT=1,"IP","3internet"
ISDN = 0
Modem = /dev/ttyUSB0
Modem Type = Analog Modem
Baud = 460800
check DNS = no
Auto DNS = no
This important thing to note here is that there are TWO profiles setup above, the default profile and the three
profile. Note that if you use the three.co.uk as the APN you get a NAT IP address (i.e. you are part of the Three UK internal network, so don’t have a public IP – exactly like your home network where you are behind your router), but if you use the 3internet APN then you get a public IP! This important if you want to access your Pi from the outside world!
So fire up wvdial
and check it all works:
wvdial three
This is all well and good, but pointless if I wanted my Pi to be just plug and play (i.e. start mobile broadband connection, start mjpg_streamer and email me the IP address!)
The easiest way which allows me to control this is to simply have a crontask which calls three other scripts. The other three scripts are 1) start wvdial, 2) start mjpg_streamer and 3) email me the new IP address
Wrapping commands inside 3 separate until
loops meant if anything should die it tries to restart it! This is really important when you don’t have physical access to the Pi – at least you can SSH onto it! (see this stackoverflow answer here: )
I think thats about it! Drop a comment below if anything is unclear!