[under construction - e.g. some details have been omitted at this point]
SETTING UP THE HUAWEI E303 3G DONGLE FOR MOBILE CONNECTIVITY
So advantages here include this 3G dongle being quite ubiquitous - so you won't have problems getting it. The FONA modules can be often out of stock, and some of the other modules are quite hard to source, expensive, and only available from one country.
1. There's an issue powering this from the Raspberry Pi USB port. So you need to use a powered USB hub, i.e. externally powered. That's fine, because we can get power from our battery to it at 5V.
[I have not had this issue]
2. Connect the E303 to the USB port
3. Get a list of USB devices from the raspberry pi with
lsusb
Ok, so the second problem may occur at this stage. If we get something similar to Bus 001 Device 010: ID 12d1:----[?] Huawei Technologies Co., Ltd. E303 LTE/UMTS/GSM Modem/Networkcard is the list we are fine.
But if we don't get modem, them we've a problem. For example we got 12d1:1f01 here. The problem is that Raspberry Pi is detecting the E303 as a storage device. This is due to the E303 having a partition on it containing software for windows. Now this can occur intermittently which is real problem! Sometimes listed as a modem, sometimes as a storage device!
Here we go: it was detected as storage device :-(
You can go ahead and fix this with usb-modeswitch. This will designate a mode to the E303 and store this mode. We need to designate the mode using the hexadecimal value corresponding to modem mode.
The 12d1 is for Huawei, and the 1506 is the device id for a modem. We might have to look these up if we keep getting a storage device detected!
4.
So, let's install usb-modeswitch
sudo apt-get install usb-modeswitch
Now we need to edit the config file for usb-modeswitch and insert the correct vendor and device id that corresponds to a modem! The config file is at /etc/usb_modeswitch.conf
Go ahead and edit the file with the following command (or whichever editor you prefer):
sudo nano /etc/usb_modeswitch.conf
The mode switch forum can be helpful to get the correct details!
So here's what I found first when I searched for what to add to usb_modeswitch.conf:
DefaultVendor= 0x12d1
DefaultProduct= 0x1f01
TargetVendor= 0x12d1
TargetProduct= 0x14dc
MessageEndPoint = "0x01"
MessageContent="55534243123456780000000000000a11062000000000000100000000000000"
NoDriverLoading=1
So I added this, and yes it the E303 switched from being a storage device (i.e.12d1:1f01) to being a modem (12d1:14dc). So when I ran lsusb again I got:
So I was thinking I'm all ready to search how to install pppd etc. But when I tried to search from my web browser, I saw this message!!
Wow! What is going on! wlan, which I was using to connect to internet had been disabled! And eth1 was now associated with the E303! Note, the SIM error is fine, because I didn't have a SIM in the E303 at this point. So the E303 is not acting as a serial modem, it is on Ethernet! With 192.168.1.1 being the gateway and dhcp server. So I found out this is the HighLink mode (see here: https://projects.hologram.io/hologram/working-with-hilink-mode-on-the-huawei-e303-353-58ab21)
So, that's quite good in a way.. If we wanted to use the E303 to have 3G connection to internet using PPP. It's all very easy!
However, we want the E303 to act as a serial modem so we can send AT commands, and get SMS sent out from it! So it the above mode, we can't use screen or cu to start a session with it and try this. E.g. with 'screen /dev/ttyUSB0'
Now we need to make the E303 act as a serial modem!
FORCING THE E303 TO ACT AS A SERIAL MODEM
After some research, I found this could be as simple as passing usb_modeswitch the following:
usb_modeswitch -v 0x12d1 -p 0x1f01 -V 0x12d1 -P 0x1001 -M "55534243000000000000000000000611060000000000000000000000000000"
However! A lot of the research I did turned up things people had done in 2013-2015. Has the firmware changed since then? According to this post, from 2016 - which applies to the E3272 rather than E303 - yes! We would need to go back to older firmware in order to force the E3272 to act as serial http://blog.le-vert.net/?p=196 !
we had too:
# Huawei E3531s-2 - switch to modem mode instead of HiLink CDC-Ether mode
TargetVendor=0x12d1
TargetProduct=0x1f01
# switch to 12d1:1001 (modem mode, 3 virtual serial ports)
MessageContent="55534243123456780000000000000011062000000100000000000000000000"
==== these may not be required
5. USING PPPd and others to get PPP over 3G
Ok, now we need to install the Point-to-Point Protocol daemon (pppd) to manage the connection between the pi/E303 and the service provider.
[update background on this daemon]
You can install it with the following command:
sudo apt-get install ppp
6.
Well there are several approaches now:
There's the https://github.com/Trixarian/sakis3g-source sakis3g script which we can use [license unknown] to connect to 3G provider. You'll need to pass your APN, SIM PIN (if applicable) and username/password (if applicable).
There's the UMTSkeeper http://mintakaconciencia.net/squares/umtskeeper/index.html- which is to reconnect if the mobile connection is lost.
This is licensed under Hacktivismo Enhanced-Source Software License Agreement (HESSLA) and GNU General Public License (GPL)
=====
JUST USING THE E303 FOR SMS
So here we just send AT commands to the E303. We can do this in python using serial library e.g PysSerial (https://pythonhosted.org/pyserial) , or there are several other methods too.
First we need to instruct the E303 to act in SMS mode with the following AT command:
AT+CMGF=1
We should get back OK. If we don't, we have an error.
Next we send the following command, which includes to phone number to send SMS to:
AT+CMGS="+443283870634" <CR>
It requires a carriage return afterwards, so ASCII code=13 would need to be passed. Next we can send the message, followed by Ctrl-Z, so ASCII code=26:
this is the text message string <CTRL-Z>
At this point we should get back: "+CMGS: x" with x corresponding to the number allocated as an SMS reference number. After that we would get "OK" for the SMS being sent successfully, or we get either "ERROR" or "+CMS ERROR" if the SMS failed to send.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.