Using Raspberry Pi as a Carputer and WiFi / 4G Hotspot

Introduction

Well I’ve been quiet for a while. The end of last year became a bit hectic with my wife in hospital, an unplanned house move in the new year and playing catch-up ever since. I thought I’d get back in to writing a blog by filling in some details on my latest project – adding some tech to my car.

I’ve played about with Carputers on and off for some years. In 2013 I started work on adding network connectivity to my car with a 3G dongle and a Raspberry Pi controlling the AT commands running some .Net code on Mono. That was fun but it didn’t get much beyond a lot of fun. The PPP daemon ate a lot of resources and I found it a little unstable. This was twinned with really huge variations in support for AT commands and dodgy, cheap 3G modems that failed for no reason. I did, however, have some fun and integrate the ability to view signal details, read and send text messages and connect to the internet through a RESTful API.

In 2014 I worked on an in car audio system that used an iPad as the display in the dash. The Pi just had some USB ports, very rapidly indexed the MP3s (under a minute for 8GB) and then gave a nice pretty interface to chose what music to play. It worked reasonably well but I never finished it or used it regularly due to terrible iPad mount I had.  I housed it in a lego case at the time – that didn’t work out too well in the car either.

This Easter I decided I’d finally put those two concepts together and get something fully working in my car.

The key goals I wanted were:

  1. In-car WiFi with 3G/4G connection to the internet
  2. Ability to play MP3s more gracefully than an AUX cable from my iPhone
  3. A way to put video content (MKV, AVI, etc) on the rear entertainment screens to entertain my daughter on longer drives

The Car

I’ve got a 2007 Range Rover Supercharged.  It’s a great car with lots of gadgets, but the in car entertainment system doesn’t have a USB input meaning I’m limited to AUX input.  It does have a wide array of other inputs though to support this project.  It’s got built in digital TV, a selection of cameras that can go to the screens, wireless headphones with different audio channels and rear headrest entertainment.  The car has, in addition to the AUX audio input, two sets of AV inputs for video and audio.  The rear screens can display either AV1, AV2, DVD or TV whilst the front can only do DVD, TV or cameras and only cameras whilst driving.  The speakers in the car and each of the headsets can be one of AUX, AV1, AV2, TV, DVD, Radio, CD.  This gives quite a few options to play with and makes it a great car to work with.  The only downside is I cannot get AV1 or AV2 in the front so I’ll not be able to use the existing screen to control my new Carputer.

If your car doesn’t have this you can still do everything in this project for very little extra money. You can buy a pair of rear-headrests with the AV inputs for under £150 from Amazon (http://www.amazon.co.uk/dp/B00O0U25TA) and if your car doesn’t have AUX input then you can buy a 3.5mm jack to FM transmitter to use on the Raspberry Pi from Amazon for £10 (http://www.amazon.co.uk/dp/B00EWDV1K4) and you will be good to go.

High-Level Overview

I decided Raspberry Pis were going to be my best bet to get something done quickly. I only had a couple of days so needed to rely heavily on existing packages to get this done swiftly. I love the Pi and have used them for projects ranging from home automation to bespoke CCTV systems. In this case I decided I’d use two. One Raspberry Pi would be the internet router and wireless hotspot whilst the other would provide media to the cars existing system – both video and audio inputs to both the AUX and AV1 channels.

Raspberry Pi 1 – Router and Wireless Access Point

The first thing to do was setup the WiFi network. I use a Raspberry Pi 2 for my router with a Huawei E392 4G modem and a Realtek RT5370 USB wireless card. Since the Pi can provide a maximum of 500MAh of power I also purchased a “Y-Splitter” for the USB cable – one end goes to a power source, the other goes to the device. This means it draws no power at all from the Pi. On your desk a powered USB hub will work but in the car that’s more tricky – I’ll give more details of setting this up in the car itself later but I use this cable: http://www.amazon.co.uk/gp/product/B009EAF0RU

The first step for the Wireless Access Point is to follow the instructions here – http://elinux.org/RPI-Wireless-Hotspot – this will get you a basic WAP setup with you Pi directing all traffic over the ethernet port. Whilst I won’t be using the ethernet port in car, it’s a useful way to start testing inside the home. Reboot your Pi after following the instructions and you should be able to connect over WiFi and get an IP.

The next step is to get the Huawei E392 up and running. In initially presents itself as a CD-ROM drive. The device also supports a couple of other operating modes an “old-school” AT-command style modem which I’ve previously worked with on a Pi using wvdial and other scripts – or “QMI” mode. QMI is a custom binary protocol for Qualcomm modems. The Linux kernel (and the latest Pi one) includes a driver for this out of the box. In QMI mode the E392 presents itself as “wwan0” network interface. Since I’d not used QMI before and the AT commands can be very frustrating to work with and poorly documented once you start some custom coding I opted for QMI mode. A good primer on QMI can be found on this blog https://sigquit.wordpress.com/2012/08/20/an-introduction-to-libqmi/.

The first challenge is getting the modem in to QMI mode. To do this you need to get the usb_modeswitch package for your device and instruct it to switch the E392 in to a network adapter. First download the usb-modeswitch packages.

sudo apt-get install usb-modeswitch usb-modeswitch-data

Next you need to create a file detailing how the device should mode switch. Create a folder to store the config and then save the file:

sudo mkdir /etc/usb_modeswitch.d
sudo nano -w /etc/usb_modeswitch.d/12d1\:1505

In the file put the contents below then press CTRL+X, “Y” to confirm saving and then enter. This will write the file to disk.

DefaultVendor= 0x12d1
DefaultProduct=0x1505
TargetVendor=  0x12d1
TargetProductList="140b,1506,150f"
MessageContent="55534243123456780000000000000011062000000100000000000000000000"

This file tells usb_modeswitch what data to send the device in order to enter QMI mode.

First to test this run “lsusb” – your device should show as a 12d1:1505 (CD-ROM mode):

guytp@GTP-RRSC-RTB-01:~$ lsusb
… chopped …
Bus 001 Device 004: ID 12d1:1505 Huawei Technologies Co., Ltd. E398 LTE/UMTS/GSM Modem/Networkcard
… chopped …

Next run the following command to run usb_modeswitch:

usb_modeswitch -c /etc/usb_modeswitch.d/12d1\:1505

If we now re-run it we will see it appearing as 12d1:1506:

guytp@GTP-RRSC-RTB-01:~$ lsusb
… chopped …
Bus 001 Device 004: ID 12d1:1506 Huawei Technologies Co., Ltd. E398 LTE/UMTS/GSM Modem/Networkcard
… chopped …

And if we check ifconfig we’ll also see wwan0:

guytp@GTP-RRSC-RTB-01:~$ ifconfig
… chopped …
wwan0     Link encap:Ethernet  HWaddr 3a:62:1f:dc:13:19  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:194 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:66348 (64.7 KiB)

You’ll want this command to run on boot every time but we’ll cover that later.

Unless you’re a lot more lucky than me at this point you’ll have an interface with no IP address and a blue or green LED flashing every 2 seconds on your modem indicating it is trying to connect to a network. In this case it just doesn’t know what to do.

You need to compile libqmi to gain access to the various management tools that a QMI interface supports. Since there’s no package for this on the Pi you need to compile. Rather than messing around cross compiling what is a pretty simple library I decided to just compile it on my Pi2 – it took under ten minutes without overclocking. You first need all the tools to run the build:

sudo apt-get install build-essential automake libglib-2.0-dev gtk-doc-tools git
sudo ldconfig

Press “Y” and enter to confirm the install and wait a bit. Once it’s all done you need to download the libqmi source code and compile it:

cd ~
mkdir libqmi
cd libqmi
git clone git://anongit.freedesktop.org/libqmi
cd libqmi
./autogen.sh
./configure
make
sudo make install

At this point everything should be working. You can test by running the following and seeing if you get some basic stats about your connection:

guytp@GTP-RRSC-RTB-01:~/libqmi/libqmi$qmicli -d /dev/cdc-wdm0  --nas-get-signal-strength
[/dev/cdc-wdm0] Successfully got signal strength
Current:
	Network 'umts': '-65 dBm'
RSSI:
	Network 'umts': '-65 dBm'
ECIO:
	Network 'umts': '-125.5 dBm'
IO: '-106 dBm'
SINR: (8) '9.0 dB'
guytp@GTP-RRSC-RTB-01:~/libqmi/libqmi$

You should now edit the /etc/network/interfaces file and add the following lines at the end to instruct the network device to be hot-pluggable and to use DHCP:

allow hotplug wwan0
iface wwan0 inet dhcp

Finally you’re ready to connect. Create a file called /etc/qmi-network.conf and add a single line with your mobile providers Access Point Name in it. For mine I have the following file:

guytp@GTP-RRSC-RTB-01:~/libqmi/libqmi$ cat /etc/qmi-network.conf 
APN=payg.mobilebysainsburys.co.uk
guytp@GTP-RRSC-RTB-01:~/libqmi/libqmi$

Finally start the connection with qmi-network:

guytp@GTP-RRSC-RTB-01:~/libqmi/libqmi$ sudo qmi-network /dev/cdc-wdm0 start
Loading profile...
    APN: payg.mobilebysainsburys.co.uk
    qmi-proxy: no
Checking data format with 'qmicli -d /dev/cdc-wdm0 --wda-get-data-format '...
Link layer protocol retrieved: 802-3
Starting network with 'qmicli -d /dev/cdc-wdm0 --wds-start-network=payg.mobilebysainsburys.co.uk  --client-no-release-cid '...
Saving state... (CID: 2)
Saving state... (PDH: 38750672)
Network started successfully
guytp@GTP-RRSC-RTB-01:~/libqmi/libqmi$

The device’s LED should be a solid blue or green at this point. Instruct it to get an IP for the first time with:

sudo dhclient wwan0

If you then run ifconfig weans you should see it’s IP address:

guytp@GTP-RRSC-RTB-01:~/libqmi/libqmi$ sudo /sbin/ifconfig wwan0
wwan0     Link encap:Ethernet  HWaddr 00:a0:c6:00:00:00  
          inet addr:10.153.204.94  Bcast:10.153.204.95  Mask:255.255.255.252
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:31 errors:0 dropped:0 overruns:0 frame:0
          TX packets:58 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:3814 (3.7 KiB)  TX bytes:13488 (13.1 KiB)
guytp@GTP-RRSC-RTB-01:~/libqmi/libqmi$ 

Next to route WLAN traffic over the 4G rather than your ethernet port you will need to edit /etc/iptables.ipv4.net and replace all references to eth0 with wwan0. Once you’ve done this flush and reload the IP tables with:

sudo iptables -F
sudo iptables-restore < /etc/iptables.ipv4.net

Connecting my phone to the WiFi for testing at this point I got a local IP address with internet connection and could download at a fairly decent 10Mbps. Fairly decent considering the signal in my house at least. Your Pi won’t be connecting automatically every reboot at the moment – so we’ll deal with that next.

There are a few issues as it stands:

  1. A connection isn’t established on boot
  2. The DHCP client initial retry interval is too long to be noticed
  3. udhcpd was not starting on boot for me despite the fact it was meant to
  4. usb_modeswitch doesn’t run every boot, nor does it actually need to as sometimes the card comes up in the correct mode

I tried a few different ways to tackle this – from entries in rc.local to launching screen on boot. The problem seemed to be that at least a couple of the actions I was taking needed to be running in a console session initially. Since this device is functioning as an embedded device with no console I decided that I’d tackle this by having the machine auto-logon as root then run a script to bring everything up. I found out that sometimes usb_modeswitch would hang on boot so added the “-I” flag which tells it not to enquire what the device is first. This seemed to fix it. In these instances though there was a 1-2 second delay before wwan came up so I added a delay to compensate for that.

The script I created does the following:

  1. Restart udhcpd if not already running
  2. Call usb_modeswitch if the device is not in modem mode
  3. Bring wwan0 up if it is down
  4. Start modem if not already connected
  5. Call dhclient to request an IP address immediately rather than waiting for the retry interval
  6. Check that we have an IP

The contents of the script is as follows – I saved this in /usr/local/sbin/modemup.sh then ran chmod 755 /usr/local/sbin/modemup.sh to make it executable:

#!/bin/bash

PATH=$PATH:/usr/local/bin/

echo ModemUp script called

if ps ax | grep -v grep | grep "udhcpd" > /dev/null
then
	echo udhcpd is already running
else
	echo Starting udhcpd
	/usr/sbin/udhcpd -S
	if [[ $? -ne 0 ]]
	then
		echo Failed to start udhcpd
		exit 0
	fi
fi

	if [[ "$(lsusb)" = *"12d1:1505"* ]]
then
	echo Calling modeswitch
	/usr/sbin/usb_modeswitch -W -I -c /etc/usb_modeswitch.d/12d1\:1505
	if [[ $? -ne 0 ]]
	then
		echo Modeswitch failed
	fi
	echo Giving it a couple of seconds
	sleep 2
else
	echo Modeswitch not needed
fi

/sbin/ifconfig wwan0 >/dev/null 2>/dev/null
if [[ $? -ne 0 ]]
then
	echo wwan0 not found, terminating
	exit 0
else
	echo wwan0 is available
fi

if [[ "$(/sbin/ifconfig wwan0)" = *"UP BROADCAST"* ]]
then
	echo wwan0 is already UP
else
	echo wwan0 needs to go UP
	/sbin/ifconfig wwan0 UP
	if [[ $? -ne 0 ]]
	then
		echo Failed to bring wwan0 up, terminating
		exit 0
	fi
fi

if [[ "$(/usr/local/bin/qmi-network /dev/cdc-wdm0 status)" = *"Status: connected"* ]]
then
	echo Network already connected
else
 	echo Starting modem
	/usr/local/bin/qmi-network /dev/cdc-wdm0 start
	if [[ $? -ne 0 ]]
	then
		echo Failed to start QMI network, terminating
		exit 0
	fi
fi

if [[ "$(/sbin/ifconfig wwan0)" = *"inet addr"* ]]
then
	echo wwan0 already has an IP
else
	echo Requesting DHCP for wwan0
	/sbin/dhclient wwan0
fi

ip="$(/sbin/ifconfig wwan0 2>/dev/null|awk '/inet addr:/ {print $2}'|sed 's/addr://')"
echo We have the IP $ip
exit 0

To get this to run on boot through a console I first had to make a change to the system to allow auto-logon. To do this edit /etc/inittab

Change this line:

1:2345:respawn:/sbin/getty --noclear 38400 tty1

To this line:

1:2345:respawn:/bin/login -f root tty1 </dev/tty1 >/dev/tty1 2>&1

This will login as root at boot to a single terminal.

Finally edit /root/.bashrc to launch the script on logon. Since the script is re-runnable I want to run with every logon just so that I see a status if I ssh in as root – but when it’s first-boot I want it to log the output to disk and give it a few seconds before calling the script. I added the following to the bottom of my .bashrc:

if [ ! -f /tmp/boot.log ]
then
	echo First boot, giving it a few seconds more before modem goes up
	sleep 5
	/usr/local/sbin/modemup.sh > /tmp/boot.log 2>/tmp/boot.log
else
	/usr/local/sbin/modemup.sh
fi

If I want to see the status of my connection during boot I can then just take a look at /tmp/boot.log.

Finally for good measure just incase something goes down unexpectedly I re-run the script once per minute. To do this setup a crontab job for root that runs the script once per minute:

guytp@GTP-RRSC-RTB-01:/tmp$ echo "* * * * * /usr/local/sbin/modemup.sh >>/tmp/cron.log 2>>/tmp/cron.log" > cron
guytp@GTP-RRSC-RTB-01:/tmp$ sudo crontab -uroot cron

This will setup root’s crontab to perform the check once per minute and log it to /tmp/cron.log.

The very last thing I decided to do (which is optional) was to setup a transparent web proxy for caching to hopefully give a bit of a boost in-car when the connection isn’t great. I used squid and iptables to redirect web requests. You can install squid as follows:

sudo apt-get install squid3

I then edited /etc/squid3/squid.conf as follows (make sure your IP ranges are correct):

http_port 3128 transparent
 
refresh_pattern ^ftp:           1440    20%     10080
refresh_pattern ^gopher:        1440    0%      1440
refresh_pattern -i (/cgi-bin/|\?) 0     0%      0
refresh_pattern .               0       20%     4320
 
acl manager url_regex -i ^cache_object:// +i ^https?://[^/]+/squid-internal-mgr/
 
acl localnet src 192.168.1.0/24
acl localhost src 127.0.0.1/32
 
acl SSL_ports port 443
acl Safe_ports port 80          # http
acl Safe_ports port 21          # ftp
acl Safe_ports port 443         # https
acl Safe_ports port 70          # gopher
acl Safe_ports port 210         # wais
acl Safe_ports port 1025-65535  # unregistered ports
acl Safe_ports port 280         # http-mgmt
acl Safe_ports port 488         # gss-http
acl Safe_ports port 591         # filemaker
acl Safe_ports port 777         # multiling http
acl CONNECT method CONNECT
 
http_access allow manager localhost
http_access allow manager all
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost
http_access allow localnet
http_access deny all

Finally we redirect port 80 to squid, save the iptables again and restart squid:

sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
sudo service squid3 restart

And we’re done with the router, at long last!

Raspberry Pi 2 – In Car Media Centre

I used a Raspberry Pi B+ rather than a Pi2 as it comes with audio out and component video out as standard ports without a breakout cable. I want to minimise the number of cables in my car so thought this was best. The Pi2 requires a breakout cable if you don’t want to use HDMI video. Of course if your car has HDMI inputs then use this instead. Other than the Pi, cables and a memory stick with some media to play the only other thing you need is a WiFi dongle.

OSMC is based off XBMC allowing playback of 1080p videos and common music formats. There is also significant extensibility available should you want it via plugins and there are already mobile / tablet apps to control OSMC that can be used as your in-car remote.

The entertainment side of things is a lot easier. I decided to start with one Pi dedicated to video. In the future I may make this separate to the audio if required – but for now I’m just going for the one. As I want out-of-the-box I decided to use OSMC (Open Source Media Centre) from https://osmc.tv/. OSMC is based off XBMC allowing playback of 1080p videos and common music formats. There is also significant extensibility available should you want it via plugins and there are already mobile / tablet apps to control OSMC that can be used as your in-car remote. Just download the installer for your desktop OS and follow the steps and it will wipe your memory card and install OSMC – one of the easiest experiences you’ll ever have with a Pi. Just make sure you setup a static IP if you want to use one now as it’s a pain to edit later.

For first setup I’d recommend doing it inside with a reasonable monitor having it connected via WiFi to your other Pi. A few simple one-time setup questions and then you can go about adding media. I just filled a 64GB memory stick with music and videos for the car. Not a lot too this and already a tonne of guides online and then you’re ready to install this.

In-Car Installation

At this point you should have your OSMC connected to the internet via your second Pi’s 4G connection and the magic of WiFi. If you’ve got this far the last part is transferring your mass of cables in to the car. A key to your car is going to be power. Your car power sockets/cigarette lighters provide 12V. This isn’t a guaranteed 12V when the car is running. The car will provide 12V of power guaranteed on battery – but when you turn the ignition on you’ll get a dip and then a spike as it switches to the alternator. During normal running you’ll get approximately 12V but +- a few. Since a Raspberry Pi and all USB devices run off 5V you’ll want to get a converter. This is worth spending the money on – I have fried at least two Raspberry Pis in the past by going on-the cheap. Any in-car power to USB adapter (the same you charge your phone / GPS with) will work – but it’s worth going for one with a high-amp output. I use adapters that provide 2×2.1A USB ports. I use 2 of the in-car sockets, each with 2×2.1A sockets and the Y-power splitter cable I stated before.

It’s also important to make sure that your power sockets are not “always on” and turn off with the car engine. Whilst this does mean the Pi will instantly lose power it has the benefit of not draining your car battery. Ideally you’d add a charging circuit, separate battery and a way to detect power and shut down the Pi gracefully after a period with no power.

The OSMC box has the Raspberry Pi go in to 1x 2.1A socket and the memory stick in the other for power and connected to the Pi for data. I’ve not found this necessary but I’d rather guarantee my devices didn’t lose power during usage. Connect the yellow video-out to your headrest and the audio out to your stereo in the car.

The router/WAP goes into another 2 sockets – 1 for the Pi again and one to power the modem. This is a must as the Pi just cannot provide power for the Huawei reliably – you may get it to work, but probably not well.

I house my OSMC box in the seat pocket behind the driver and the router in some netting in the boot.

Turn the car engine on and wait for everything to boot. With good SD cards you can expect about a 15 second boot time. With some pruning you can definitely make this a lot faster. I’ve seen Pis boot in 3-4 seconds, which is quicker than my Range Rover OEM system. You’ll need to do a lot of pruning but it’s certainly possible.

You should then be able to connect your mobile or tablet to the WiFi, load the OSMC remote and playback some media. I just use my iPhone in the front to control OSMC – but do also have a wireless keyboard so that if I can see the screen myself I can tweak settings/etc. (http://www.amazon.co.uk/dp/B004FSFYG8).

Summary and Parts

So that’s it if you’ve followed this through you should have a wireless network in your car, connected to the internet and a smart-device controlled in car entertainment system. Pretty cool for a not much money. The below is a list of the parts that I used to get this together.

Where Next?

There’s loads I’d love to do with this if I get the time. The full list in a roughly prioritised order is as follows:

Other future work will include:

  • Getting the car to connect to my VPN whenever connection comes up and assign its host via dynamic DNS
  • Switch onto 10.x subnet like the rest of guytp.org, currently on 192.168.1.0/24
  • Use file sharing from the router to the other Pis so that content can be shared across the WiFi
  • Improve boot times significantly
  • Dash mounting an iPad for control and update software I’d written previously
  • Custom code to monitor the network connection and again display it on my iPad so I can see signal status
  • Add RTCs to the Raspberry Pis to keep their time between power-outs
  • Replace cases with aluminium based for heat dissipation
  • Relocate Pis to a completely hidden part of car and improve cabling
  • Add in a battery backup/graceful shutdown system for all the Pis
  • Add more than one 3G/4G connection and dynamically switch to whichever network has the best signal at any point in time to deal with poor signals on UK roads
  • Add two more Raspberry Pis so that the two headrests and AV system can have completely independent signals to them if required
  • Add external antennas for 3G/4G to the outside of the car or have a re-transmitter inside the car (potentially better if I end up with 3-4 connections in there)
  • Remote configuration of the 3G/4G connections and WiFi hotspot through iPad interface
  • Add digital radio to the Pi connected to AUX to replace the analog radio in the car
  • Adding in GPS to monitor location and submit it to online portal
  • CANBUS integration to monitor details about the car and if I do use my iPad dash-mounted I can display it here
  • Allow iOS device to be used as source of music rather than just MP3s on a memory stick
  • Integration with text messaging through in-dash iPad
  • Investigate bluetooth integrate with a Raspberry Pi to be used as a car phone – potentially through QMI or alternatively through my VOIP system so my car is just an extension of that
  • Ability to send the car “commands” by text message or web
  • Potentially SatNav but a tricky one as I want to blend the audio over any music that is playing. Using a tablet as the in-dash display negates the need but means no audio integration without feeding its audio back into the input of a Pi. Still probably a better option than attempting to write my own SatNav off TomTom’s SDK which is my best second bet for now…

Pictures

Carputer Components
Carputer Components
Mounted Carputer Router
Mounted Carputer Router
Rear Carputer Wiring
Rear Carputer Wiring
Rear Carputer Wiring
Rear Carputer Wiring
OSMC on Rear Headrest
OSMC on Rear Headrest
Raspberry Pi in a Lego Case
Lego Case for Raspberry Pi
iPad Showing Carputer Interface
Carputer V2 Interface
Advertisements

11 thoughts on “Using Raspberry Pi as a Carputer and WiFi / 4G Hotspot

  1. Very nice report/ instruction! 🙂
    Concerning the Huawei E392 4G dongle (100 up, 50 down) – have you also tried a newer model (with 150 Mbit down, 50 Mbit up)?
    As far I can see you run the dongle without powered usb-hub (many peoples are having power problems)!? This is also my goal, as I wan´t to run the raspi with a battery.
    I´ve setup “max_usb_current=1” in “/boot/config.txt”, to solve that (but maybe there are still problems related to this).
    I´m running a huawei e3372h-153 (no original Huawei, converted from hilink to non-hilink), but it doesn´t work with “libqmi” or “qmicli”.
    Further I agree about “rather than OEM as I’ve had problems with OEM ones failing for random reasons before”, as I´m experiancing the same problems.
    I´m not even able to get the modem run with sakis3g and I´m really desperate, as I´m tying now since weeks to get it reliable work.
    So any hints concering LTE-USB-modems are welcome, thanks. 🙂

    Liked by 1 person

    1. Hi,

      Glad this could be of some help to you.

      Instead of a powered USB hub I’ve been using a USB Y-splitter cable – one part of the ‘V’ shape on the ‘Y’ runs to the Raspberry Pi, the other to a power source. In my case this was a USB socket in the car but can also be a USB battery as is the case in some other projects I’ve done. Here’s an example of such a cable: http://www.amazon.co.uk/Dual-Input-USB-power-cable/dp/B003OC4KX4.

      You definitely won’t be able to drive a dongle off the Pi with any level of stability. Theoretically the Pi can put out about 500mA but in my experience, particularly on battery sources, it’s not stable with much more than a few mA being drawn and external power is needed. I use these splitters to work around it.

      I’ve not used the E3372h – but I’d definitely steer clear of the generic branded ones. I’d be tempted to chuck it in a pile somewhere and try with another device 🙂 I’ve got a whole bunch of non-genuine 3G sticks that are useless that I’ve bought off eBay over the years. If you’ve not been supplying it enough current though that would explain why you can’t get it to work… have you tried it off a powered USB hub for test purposes? I’d say get it working on a desk first with correct stable power supply.

      What does the device show up as in lsusb? Is it a modem, mass storage device or not present at all?

      Like

      1. Dear Guytp and Aleksander,

        “Instead of a powered USB hub I’ve been using a USB Y-splitter cable – one part of the ‘V’ shape on the ‘Y’ runs to the Raspberry Pi, the other to a power source. In my case this was a USB socket in the car but can also be a USB battery as is the case in some other projects I’ve done. Here’s an example of such a cable: http://www.amazon.co.uk/Dual-Input-USB-power-cable/dp/B003OC4KX4.”

        Thanks for the hint!

        “You definitely won’t be able to drive a dongle off the Pi with any level of stability. Theoretically the Pi can put out about 500mA but in my experience, particularly on battery sources, it’s not stable with much more than a few mA being drawn and external power is needed. I use these splitters to work around it.”

        I´ve read, by putting “max_usb_current=1” you are getting above 1000mA!?

        “I’ve not used the E3372h – but I’d definitely steer clear of the generic branded ones. I’d be tempted to chuck it in a pile somewhere and try with another device 🙂 I’ve got a whole bunch of non-genuine 3G sticks that are useless that I’ve bought off eBay over the years. If you’ve not been supplying it enough current though that would explain why you can’t get it to work… have you tried it off a powered USB hub for test purposes? I’d say get it working on a desk first with correct stable power supply.”

        No, didn´t tried it yet with a powered usb-hub, but just ordered one today…

        Previously I´ve bought the telekom speedstick v (http://www.amazon.de/Telekom-Speedstick-LTE-V-wei%C3%9F/dp/B00M028G9I), but didn´t work neither with QMI, so I thought to give the cheaper stick a try.

        “What does the device show up as in lsusb? Is it a modem, mass storage device or not present at all?”

        Please have a look below (in default it shows as storage device and I have to run usb_modeswitch.
        But sometimes it´s recognised as modem (tried some modeprobe commands/ udev-rules, but didn´t work). I reflashed the firmware some days ago, and now it´s always recognised as storage device!?
        Really dont´get an idea, what going on.

        Thanks for your help!!

        Cheers
        Tom

        ##############################################################################

        “How exactly “doesn’t work with libqmi or qmicli”? What’s the exact error you’re getting? Do you even get a pair of /dev/cdc-wdm and wwan interfaces?”

        Yes:
        root@rasp-LTE:~# ll /dev/cdc-wdm0
        crw——- 1 root root 180, 176 Feb 9 01:19 /dev/cdc-wdm0

        root@rasp-LTE:~# ifconfig |grep wwan0
        wwan0 Link encap:Ethernet HWaddr 00:1e:10:1f:00:00

        I dont get an error by executing e. g.

        “qmicli -d /dev/cdc-wdm0 –nas-get-signal-strength”

        It just hungs up (same about “uqmi -s -d /dev/cdc-wdm0 –get-signal-info”) and no logging at all.

        “That modem you’re referring to may actually not be QMI at all, and instead be driven by the “huawei-cdc-wdm” kernel driver, which means the /dev/cdc-wdm is actually a non-serial USB AT port, and then the WWAN is really just a NCM interface with a bunch of hacks to make it work properly. ”

        Yes again. WWAN0 works just with some AT commands, but neither reliable.

        Output of lsusb -v:

        Bus 001 Device 006: ID 12d1:1506 Huawei Technologies Co., Ltd. E398 LTE/UMTS/GSM Modem/Networkcard
        Device Descriptor:
        bLength 18
        bDescriptorType 1
        bcdUSB 2.10
        bDeviceClass 0 (Defined at Interface level)
        bDeviceSubClass 0
        bDeviceProtocol 0
        bMaxPacketSize0 64
        idVendor 0x12d1 Huawei Technologies Co., Ltd.
        idProduct 0x1506 E398 LTE/UMTS/GSM Modem/Networkcard
        bcdDevice 1.02
        iManufacturer 1 HUAWEI_MOBILE
        iProduct 2 HUAWEI_MOBILE
        iSerial 0
        bNumConfigurations 1
        Configuration Descriptor:
        bLength 9
        bDescriptorType 2
        wTotalLength 221
        bNumInterfaces 5
        bConfigurationValue 1
        iConfiguration 0
        bmAttributes 0x80
        (Bus Powered)
        MaxPower 2mA
        Interface Descriptor:
        bLength 9
        bDescriptorType 4
        bInterfaceNumber 0
        bAlternateSetting 0
        bNumEndpoints 2
        bInterfaceClass 255 Vendor Specific Class
        bInterfaceSubClass 2
        bInterfaceProtocol 18
        iInterface 0
        ** UNRECOGNIZED: 05 24 00 10 01
        ** UNRECOGNIZED: 04 24 02 02
        ** UNRECOGNIZED: 05 24 01 00 00
        ** UNRECOGNIZED: 05 24 06 00 00
        Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x82 EP 2 IN
        bmAttributes 2
        Transfer Type Bulk
        Synch Type None
        Usage Type Data
        wMaxPacketSize 0x0200 1x 512 bytes
        bInterval 0
        Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x02 EP 2 OUT
        bmAttributes 2
        Transfer Type Bulk
        Synch Type None
        Usage Type Data
        wMaxPacketSize 0x0200 1x 512 bytes
        bInterval 0
        Interface Descriptor:
        bLength 9
        bDescriptorType 4
        bInterfaceNumber 1
        bAlternateSetting 0
        bNumEndpoints 3
        bInterfaceClass 255 Vendor Specific Class
        bInterfaceSubClass 2
        bInterfaceProtocol 1
        iInterface 0
        ** UNRECOGNIZED: 05 24 00 10 01
        ** UNRECOGNIZED: 04 24 02 02
        ** UNRECOGNIZED: 05 24 01 00 01
        ** UNRECOGNIZED: 05 24 06 00 00
        Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x84 EP 4 IN
        bmAttributes 3
        Transfer Type Interrupt
        Synch Type None
        Usage Type Data
        wMaxPacketSize 0x000a 1x 10 bytes
        bInterval 9
        Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x83 EP 3 IN
        bmAttributes 2
        Transfer Type Bulk
        Synch Type None
        Usage Type Data
        wMaxPacketSize 0x0200 1x 512 bytes
        bInterval 0
        Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x03 EP 3 OUT
        bmAttributes 2
        Transfer Type Bulk
        Synch Type None
        Usage Type Data
        wMaxPacketSize 0x0200 1x 512 bytes
        bInterval 0
        Interface Descriptor:
        bLength 9
        bDescriptorType 4
        bInterfaceNumber 2
        bAlternateSetting 0
        bNumEndpoints 1
        bInterfaceClass 255 Vendor Specific Class
        bInterfaceSubClass 2
        bInterfaceProtocol 22
        iInterface 8 NCM Network Control Model
        ** UNRECOGNIZED: 05 24 00 10 01
        ** UNRECOGNIZED: 06 24 1a 00 01 1f
        ** UNRECOGNIZED: 0d 24 0f 0a 0f 00 00 00 ea 05 03 00 01
        ** UNRECOGNIZED: 05 24 06 02 02
        Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x86 EP 6 IN
        bmAttributes 3
        Transfer Type Interrupt
        Synch Type None
        Usage Type Data
        wMaxPacketSize 0x0010 1x 16 bytes
        bInterval 5
        Interface Descriptor:
        bLength 9
        bDescriptorType 4
        bInterfaceNumber 2
        bAlternateSetting 1
        bNumEndpoints 3
        bInterfaceClass 255 Vendor Specific Class
        bInterfaceSubClass 2
        bInterfaceProtocol 22
        iInterface 9 CDC Network Data
        Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x86 EP 6 IN
        bmAttributes 3
        Transfer Type Interrupt
        Synch Type None
        Usage Type Data
        wMaxPacketSize 0x0010 1x 16 bytes
        bInterval 5
        Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x85 EP 5 IN
        bmAttributes 2
        Transfer Type Bulk
        Synch Type None
        Usage Type Data
        wMaxPacketSize 0x0200 1x 512 bytes
        bInterval 0
        Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x04 EP 4 OUT
        bmAttributes 2
        Transfer Type Bulk
        Synch Type None
        Usage Type Data
        wMaxPacketSize 0x0200 1x 512 bytes
        bInterval 0
        Interface Descriptor:
        bLength 9
        bDescriptorType 4
        bInterfaceNumber 3
        bAlternateSetting 0
        bNumEndpoints 2
        bInterfaceClass 8 Mass Storage
        bInterfaceSubClass 6 SCSI
        bInterfaceProtocol 80 Bulk-Only
        iInterface 4 Mass Storage
        Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x87 EP 7 IN
        bmAttributes 2
        Transfer Type Bulk
        Synch Type None
        Usage Type Data
        wMaxPacketSize 0x0200 1x 512 bytes
        bInterval 0
        Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x05 EP 5 OUT
        bmAttributes 2
        Transfer Type Bulk
        Synch Type None
        Usage Type Data
        wMaxPacketSize 0x0200 1x 512 bytes
        bInterval 1
        Interface Descriptor:
        bLength 9
        bDescriptorType 4
        bInterfaceNumber 4
        bAlternateSetting 0
        bNumEndpoints 2
        bInterfaceClass 8 Mass Storage
        bInterfaceSubClass 6 SCSI
        bInterfaceProtocol 80 Bulk-Only
        iInterface 4 Mass Storage
        Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x88 EP 8 IN
        bmAttributes 2
        Transfer Type Bulk
        Synch Type None
        Usage Type Data
        wMaxPacketSize 0x0200 1x 512 bytes
        bInterval 0
        Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x06 EP 6 OUT
        bmAttributes 2
        Transfer Type Bulk
        Synch Type None
        Usage Type Data
        wMaxPacketSize 0x0200 1x 512 bytes
        bInterval 1
        Binary Object Store Descriptor:
        bLength 5
        bDescriptorType 15
        wTotalLength 22
        bNumDeviceCaps 2
        USB 2.0 Extension Device Capability:
        bLength 7
        bDescriptorType 16
        bDevCapabilityType 2
        bmAttributes 0x00000002
        Link Power Management (LPM) Supported
        SuperSpeed USB Device Capability:
        bLength 10
        bDescriptorType 16
        bDevCapabilityType 3
        bmAttributes 0x00
        wSpeedsSupported 0x000f
        Device can operate at Low Speed (1Mbps)
        Device can operate at Full Speed (12Mbps)
        Device can operate at High Speed (480Mbps)
        Device can operate at SuperSpeed (5Gbps)
        bFunctionalitySupport 1
        Lowest fully-functional device speed is Full Speed (12Mbps)
        bU1DevExitLat 1 micro seconds
        bU2DevExitLat 500 micro seconds
        Device Status: 0x0001
        Self Poweredget a pair of /dev/cdc-wdm and wwan interfaces?”

        Yes:
        root@rasp-LTE:~# ll /dev/cdc-wdm0
        crw——- 1 root root 180, 176 Feb 9 01:19 /dev/cdc-wdm0

        root@rasp-LTE:~# ifconfig |grep wwan0
        wwan0 Link encap:Ethernet HWaddr 00:1e:10:1f:00:00

        I dont get an error by executing e. g.

        “qmicli -d /dev/cdc-wdm0 –nas-get-signal-strength”

        It just hungs up (same about “uqmi -s -d /dev/cdc-wdm0 –get-signal-info”) and no logging at all.

        “That modem you’re referring to may actually not be QMI at all, and instead be driven by the “huawei-cdc-wdm” kernel driver, which means the /dev/cdc-wdm is actually a non-serial USB AT port, and then the WWAN is really just a NCM interface with a bunch of hacks to make it work properly. ”

        Yes again. WWAN0 works just with some AT commands, but neither reliable.

        Output of lsusb -v:

        Bus 001 Device 006: ID 12d1:1506 Huawei Technologies Co., Ltd. E398 LTE/UMTS/GSM Modem/Networkcard
        Device Descriptor:
        bLength 18
        bDescriptorType 1
        bcdUSB 2.10
        bDeviceClass 0 (Defined at Interface level)
        bDeviceSubClass 0
        bDeviceProtocol 0
        bMaxPacketSize0 64
        idVendor 0x12d1 Huawei Technologies Co., Ltd.
        idProduct 0x1506 E398 LTE/UMTS/GSM Modem/Networkcard
        bcdDevice 1.02
        iManufacturer 1 HUAWEI_MOBILE
        iProduct 2 HUAWEI_MOBILE
        iSerial 0
        bNumConfigurations 1
        Configuration Descriptor:
        bLength 9
        bDescriptorType 2
        wTotalLength 221
        bNumInterfaces 5
        bConfigurationValue 1
        iConfiguration 0
        bmAttributes 0x80
        (Bus Powered)
        MaxPower 2mA
        Interface Descriptor:
        bLength 9
        bDescriptorType 4
        bInterfaceNumber 0
        bAlternateSetting 0
        bNumEndpoints 2
        bInterfaceClass 255 Vendor Specific Class
        bInterfaceSubClass 2
        bInterfaceProtocol 18
        iInterface 0
        ** UNRECOGNIZED: 05 24 00 10 01
        ** UNRECOGNIZED: 04 24 02 02
        ** UNRECOGNIZED: 05 24 01 00 00
        ** UNRECOGNIZED: 05 24 06 00 00
        Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x82 EP 2 IN
        bmAttributes 2
        Transfer Type Bulk
        Synch Type None
        Usage Type Data
        wMaxPacketSize 0x0200 1x 512 bytes
        bInterval 0
        Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x02 EP 2 OUT
        bmAttributes 2
        Transfer Type Bulk
        Synch Type None
        Usage Type Data
        wMaxPacketSize 0x0200 1x 512 bytes
        bInterval 0
        Interface Descriptor:
        bLength 9
        bDescriptorType 4
        bInterfaceNumber 1
        bAlternateSetting 0
        bNumEndpoints 3
        bInterfaceClass 255 Vendor Specific Class
        bInterfaceSubClass 2
        bInterfaceProtocol 1
        iInterface 0
        ** UNRECOGNIZED: 05 24 00 10 01
        ** UNRECOGNIZED: 04 24 02 02
        ** UNRECOGNIZED: 05 24 01 00 01
        ** UNRECOGNIZED: 05 24 06 00 00
        Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x84 EP 4 IN
        bmAttributes 3
        Transfer Type Interrupt
        Synch Type None
        Usage Type Data
        wMaxPacketSize 0x000a 1x 10 bytes
        bInterval 9
        Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x83 EP 3 IN
        bmAttributes 2
        Transfer Type Bulk
        Synch Type None
        Usage Type Data
        wMaxPacketSize 0x0200 1x 512 bytes
        bInterval 0
        Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x03 EP 3 OUT
        bmAttributes 2
        Transfer Type Bulk
        Synch Type None
        Usage Type Data
        wMaxPacketSize 0x0200 1x 512 bytes
        bInterval 0
        Interface Descriptor:
        bLength 9
        bDescriptorType 4
        bInterfaceNumber 2
        bAlternateSetting 0
        bNumEndpoints 1
        bInterfaceClass 255 Vendor Specific Class
        bInterfaceSubClass 2
        bInterfaceProtocol 22
        iInterface 8 NCM Network Control Model
        ** UNRECOGNIZED: 05 24 00 10 01
        ** UNRECOGNIZED: 06 24 1a 00 01 1f
        ** UNRECOGNIZED: 0d 24 0f 0a 0f 00 00 00 ea 05 03 00 01
        ** UNRECOGNIZED: 05 24 06 02 02
        Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x86 EP 6 IN
        bmAttributes 3
        Transfer Type Interrupt
        Synch Type None
        Usage Type Data
        wMaxPacketSize 0x0010 1x 16 bytes
        bInterval 5
        Interface Descriptor:
        bLength 9
        bDescriptorType 4
        bInterfaceNumber 2
        bAlternateSetting 1
        bNumEndpoints 3
        bInterfaceClass 255 Vendor Specific Class
        bInterfaceSubClass 2
        bInterfaceProtocol 22
        iInterface 9 CDC Network Data
        Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x86 EP 6 IN
        bmAttributes 3
        Transfer Type Interrupt
        Synch Type None
        Usage Type Data
        wMaxPacketSize 0x0010 1x 16 bytes
        bInterval 5
        Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x85 EP 5 IN
        bmAttributes 2
        Transfer Type Bulk
        Synch Type None
        Usage Type Data
        wMaxPacketSize 0x0200 1x 512 bytes
        bInterval 0
        Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x04 EP 4 OUT
        bmAttributes 2
        Transfer Type Bulk
        Synch Type None
        Usage Type Data
        wMaxPacketSize 0x0200 1x 512 bytes
        bInterval 0
        Interface Descriptor:
        bLength 9
        bDescriptorType 4
        bInterfaceNumber 3
        bAlternateSetting 0
        bNumEndpoints 2
        bInterfaceClass 8 Mass Storage
        bInterfaceSubClass 6 SCSI
        bInterfaceProtocol 80 Bulk-Only
        iInterface 4 Mass Storage
        Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x87 EP 7 IN
        bmAttributes 2
        Transfer Type Bulk
        Synch Type None
        Usage Type Data
        wMaxPacketSize 0x0200 1x 512 bytes
        bInterval 0
        Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x05 EP 5 OUT
        bmAttributes 2
        Transfer Type Bulk
        Synch Type None
        Usage Type Data
        wMaxPacketSize 0x0200 1x 512 bytes
        bInterval 1
        Interface Descriptor:
        bLength 9
        bDescriptorType 4
        bInterfaceNumber 4
        bAlternateSetting 0
        bNumEndpoints 2
        bInterfaceClass 8 Mass Storage
        bInterfaceSubClass 6 SCSI
        bInterfaceProtocol 80 Bulk-Only
        iInterface 4 Mass Storage
        Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x88 EP 8 IN
        bmAttributes 2
        Transfer Type Bulk
        Synch Type None
        Usage Type Data
        wMaxPacketSize 0x0200 1x 512 bytes
        bInterval 0
        Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x06 EP 6 OUT
        bmAttributes 2
        Transfer Type Bulk
        Synch Type None
        Usage Type Data
        wMaxPacketSize 0x0200 1x 512 bytes
        bInterval 1
        Binary Object Store Descriptor:
        bLength 5
        bDescriptorType 15
        wTotalLength 22
        bNumDeviceCaps 2
        USB 2.0 Extension Device Capability:
        bLength 7
        bDescriptorType 16
        bDevCapabilityType 2
        bmAttributes 0x00000002
        Link Power Management (LPM) Supported
        SuperSpeed USB Device Capability:
        bLength 10
        bDescriptorType 16
        bDevCapabilityType 3
        bmAttributes 0x00
        wSpeedsSupported 0x000f
        Device can operate at Low Speed (1Mbps)
        Device can operate at Full Speed (12Mbps)
        Device can operate at High Speed (480Mbps)
        Device can operate at SuperSpeed (5Gbps)
        bFunctionalitySupport 1
        Lowest fully-functional device speed is Full Speed (12Mbps)
        bU1DevExitLat 1 micro seconds
        bU2DevExitLat 500 micro seconds
        Device Status: 0x0001
        Self Powered

        I´d like to know a QMI-device which runs on raspi without powered hub. There isn´t any one??

        Thanks
        Tom

        Like

      2. Hi,

        The config setting for power draw on RPi doesn’t help if you cannot provide sufficient power in the first place. If your battery source isn’t providing a reliable 2A, especially if you have other peripherals attached, may still result in occassional drop-outs or weird use with the device.

        I’ve had cheap knock off Huawei devices act as described (reporting as modem but just not reporting to commands) that identical “genuine” (or even other Chinese copies) work fine with.

        The first problem is you need to make sure it is definitely reporting as a modem though. I’d reflash back to old version as you won’t get anywhere with it mass storage device. If you have a Windows machine can try plugging it in there just to check it does work at all in its current state as a modem.

        I’d try ensuring you have enough power first of all – if you can run a powered USB hub first that can provide enough power for the device you can rule out whether it is power dropouts as providing insufficient power to these dongles has caused various weird issues on Pi for me. I’ve had the Pi reboot, I’ve had devices just stop responding and sometimes this may be a while after boot when everything seems OK. I’ve also had them get as far as starting to connect but never finish – power stability sorted it out in all of these. Unless you’ve got a good solid power supply to begin (which is really easy to fix) I wouldn’t waste time chasing all the other possibilities.

        Liked by 1 person

    2. How exactly “doesn’t work with libqmi or qmicli”? What’s the exact error you’re getting? Do you even get a pair of /dev/cdc-wdm and wwan interfaces?

      That modem you’re referring to may actually not be QMI at all, and instead be driven by the “huawei-cdc-wdm” kernel driver, which means the /dev/cdc-wdm is actually a non-serial USB AT port, and then the WWAN is really just a NCM interface with a bunch of hacks to make it work properly. The output of “lsusb -v” for your device will give us more info on how it’s being used.

      BTW; ModemManager works with all QMI and huawei-cdc-ncm modems transparently (same APIs for all), provided the kernel drivers are up to date.

      Like

      1. The external power source is a key point, but really, only when the modem starts to get registered and connected. If you cannot even talk to the modem, then the problem is elsewhere. I’d suggest you make the modem work first in a standard GNU/Linux distro, e.g. with ModemManager/NetworkManager, and once you know how ModemManager handles it (e.g. looking at the debug logs it generates), try to replicate that in the RPi. We spend a lot of time making modems work in ModemManager.

        Like

  2. Hello guytp and aleksander,

    in the meantime I made some new tests. I run my device with a powered usb-hub, which enhanced my situation, but still I can´t get an reliable connection.
    I also took your recomendation about

    “Instead of a powered USB hub I’ve been using a USB Y-splitter cable – one part of the ‘V’ shape on the ‘Y’ runs to the Raspberry Pi, the other to a power source. In my case this was a USB socket in the car but can also be a USB battery as is the case in some other projects I’ve done. Here’s an example of such a cable: http://www.amazon.co.uk/Dual-Input-USB-power-cable/dp/B003OC4KX4.”

    and bought such a y-cable as well. Additionally I´ve bougt “http://www.amazon.de/gp/product/B01A8S9R6G?psc=1&redirect=true&ref_=oh_aui_detailpage_o02_s00” and one usb-plug connected to the pi and the other one connected via the y-cable to the usb-LTE-dongle (cheaper solution than an usb-hub, which I don´t need for other stuff). This setup is now working for me (still not 100% reliable, but I think it has nothing to do with my dongle).

    Now I still have 1 open point:

    – Which device runs with QMI/ qmicli/ uqmi? I want to get it run with the wwan interface, as ppp is limited up to 20 Mbit concering speed (maybe somebody could confirm, as I´ve read different values about ppp).

    “guytp” is referencing this one:
    http://www.amazon.co.uk/dp/B0085C6IY2

    There no other device (other brand) which supports QMI? The Huawei E392 is not available anymore or very expensive (as it´s not an actual device).

    “I’d suggest you make the modem work first in a standard GNU/Linux distro, e.g. with ModemManager/NetworkManager, and once you know how ModemManager handles it (e.g. looking at the debug logs it generates), try to replicate that in the RPi. We spend a lot of time making modems work in ModemManager.”

    Good sugestion and I´ll try as well (even I have already some success with the pi). 🙂

    Cheers
    Tom

    Like

  3. Guy,

    Thank you for a great work.

    I used your tutorial to build a Port forwarder with a PI 3 running minimal raspberian 8.0. After commenting out the udhcpd section of the modemup.sh all worked good. I was never able to get it to run to boot so I have to wait 1 minute for the network to start for the first time. My iptables configuration was a bit different too.

    For the most part it is extremely stable but once in a while I will lose my inet addr, the network will not restart and I will have to reboot.

    root@raspberrypi:/# ifconfig wwan0
    wwan0 Link encap:Ethernet HWaddr 0e:6f:40:2a:fc:26
    inet6 addr: fe80::fad9:d74e:db4c:2e6d/64 Scope:Link
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:0 errors:0 dropped:0 overruns:0 frame:0
    TX packets:501 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:0 (0.0 B) TX bytes:133346 (130.2 KiB)

    root@raspberrypi:/etc# modemup.sh
    ModemUp script called
    Modeswitch not needed
    wwan0 is available
    wwan0 is already UP
    error: operation failed: Transaction timed out
    error: couldn’t get packet service status
    Starting modem
    Loading profile at /etc/qmi-network.conf…
    APN: r.ispn
    APN user: unset
    APN password: unset
    qmi-proxy: no
    Loading previous state from /tmp/qmi-network-state-cdc-wdm0…
    Previous CID: 17
    Previous PDH: 1137430528
    error: cannot re-start network, PDH already exists
    Failed to start QMI network, terminating

    root@raspberrypi:/# qmi-network /dev/cdc-wdm0 start
    Loading profile at /etc/qmi-network.conf…
    APN: r.ispn
    APN user: unset
    APN password: unset
    qmi-proxy: no
    Loading previous state from /tmp/qmi-network-state-cdc-wdm0…
    Previous CID: 17
    Previous PDH: 1137430528
    error: cannot re-start network, PDH already exists
    root@raspberrypi:/# dhclient wwan0
    PING 192.168.15.5 (192.168.15.5) 56(84) bytes of data.

    — 192.168.15.5 ping statistics —
    1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms

    cat /var/log/syslog
    Jun 29 14:51:01 raspberrypi CRON[29787]: (root) CMD (/usr/local/sbin/modemup.sh >>/tmp/cron.log 2>>/tmp/cron.log)
    Jun 29 14:51:01 raspberrypi dhclient: DHCPDISCOVER on wwan0 to 255.255.255.255 port 67 interval 13
    Jun 29 14:51:08 raspberrypi dhclient: DHCPREQUEST on wwan0 to 192.168.15.5 port 67
    Jun 29 14:51:11 raspberrypi dhclient: DHCPREQUEST on wwan0 to 192.168.15.5 port 67
    Jun 29 14:51:14 raspberrypi dhclient: DHCPDISCOVER on wwan0 to 255.255.255.255 port 67 interval 18
    Jun 29 14:51:19 raspberrypi dhclient: DHCPREQUEST on wwan0 to 192.168.15.5 port 67
    Jun 29 14:51:20 raspberrypi dhclient: DHCPREQUEST on wwan0 to 192.168.15.5 port 67
    Jun 29 14:51:20 raspberrypi dhclient: DHCPREQUEST on wwan0 to 192.168.15.5 port 67
    Jun 29 14:51:28 raspberrypi dhclient: DHCPREQUEST on wwan0 to 192.168.15.5 port 67
    Jun 29 14:51:28 raspberrypi dhclient: DHCPREQUEST on wwan0 to 192.168.15.5 port 67
    Jun 29 14:51:30 raspberrypi dhclient: DHCPREQUEST on wwan0 to 192.168.15.5 port 67
    Jun 29 14:51:32 raspberrypi dhclient: DHCPDISCOVER on wwan0 to 255.255.255.255 port 67 interval 17
    Jun 29 14:51:37 raspberrypi dhclient: DHCPREQUEST on wwan0 to 192.168.15.5 port 67
    Jun 29 14:51:43 raspberrypi dhclient: DHCPREQUEST on wwan0 to 192.168.15.5 port 67
    Jun 29 14:51:44 raspberrypi dhclient: DHCPREQUEST on wwan0 to 192.168.15.5 port 67
    Jun 29 14:51:49 raspberrypi dhclient: DHCPDISCOVER on wwan0 to 255.255.255.255 port 67 interval 6
    Jun 29 14:51:49 raspberrypi rsyslogd-2007: action ‘action 17’ suspended, next retry is Wed Jun 29 14:53:19 2016 [try http://www.rsyslog.com/e/2007 ]
    Jun 29 14:51:49 raspberrypi dhclient: DHCPREQUEST on wwan0 to 192.168.15.5 port 67
    Jun 29 14:51:50 raspberrypi dhclient: DHCPREQUEST on wwan0 to 192.168.15.5 port 67
    Jun 29 14:51:55 raspberrypi dhclient: No DHCPOFFERS received.
    Jun 29 14:51:55 raspberrypi dhclient: Trying recorded lease 192.168.15.4
    Jun 29 14:51:55 raspberrypi avahi-daemon[551]: Joining mDNS multicast group on interface wwan0.IPv4 with address 192.168.15.4.
    Jun 29 14:51:55 raspberrypi avahi-daemon[551]: New relevant interface wwan0.IPv4 for mDNS.
    Jun 29 14:51:55 raspberrypi avahi-daemon[551]: Registering new address record for 192.168.15.4 on wwan0.IPv4.
    Jun 29 14:51:56 raspberrypi ntpd[957]: Listen normally on 27 wwan0 192.168.15.4 UDP 123
    Jun 29 14:51:56 raspberrypi ntpd[957]: peers refreshed
    Jun 29 14:51:57 raspberrypi dhclient: DHCPREQUEST on wwan0 to 192.168.15.5 port 67
    Jun 29 14:51:58 raspberrypi avahi-daemon[551]: Withdrawing address record for 192.168.15.4 on wwan0.
    Jun 29 14:51:58 raspberrypi avahi-daemon[551]: Leaving mDNS multicast group on interface wwan0.IPv4 with address 192.168.15.4.
    Jun 29 14:51:58 raspberrypi avahi-daemon[551]: Interface wwan0.IPv4 no longer relevant for mDNS.
    Jun 29 14:51:58 raspberrypi dhclient: No working leases in persistent database – sleeping.
    Jun 29 14:51:59 raspberrypi ntpd[957]: Deleting interface #27 wwan0, 192.168.15.4#123, interface stats: received=0, sent=0, dropped=0, active_time=3 secs
    Jun 29 14:51:59 raspberrypi ntpd[957]: peers refreshed
    Jun 29 14:52:01 raspberrypi CRON[29859]: (root) CMD (/usr/local/sbin/modemup.sh >>/tmp/cron.log 2>>/tmp/cron.log)
    Jun 29 14:52:05 raspberrypi dhclient: DHCPREQUEST on wwan0 to 192.168.15.5 port 67
    Jun 29 14:52:06 raspberrypi dhclient: DHCPREQUEST on wwan0 to 192.168.15.5 port 67
    Jun 29 14:52:14 raspberrypi dhclient: DHCPREQUEST on wwan0 to 192.168.15.5 port 67

    The IP address of the pi is 192.169.15.1 and the modem is 192.168.15.4 I am not sure what 192,168.15.5 is I can only assume that it is the on board wlan0 which I am not using at this time since the aircard has Wi-Fi already running.

    What is the best way to troubleshoot and/or resolve this glitch?

    Thanks

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s