Wednesday, 7 November 2012

[Python] HUAWEI E3131 library

The modem Huawei E3131 is used to connect any pc or laptop to internet through a 3G network, you can also think about it and create a program that  needs a 3G connection.
This model is very useful because you don't need to install any drivers and it works strength away on each operate system, due the clever idea to show this device as a normal Ethernet card.
I used this great product on my Raspberry project and I can say that I am very happy with it!

I found a website that talks about how to use the API with the modem Huawei and which commands you can send.
Check this out to understand what can you do with this little device, on the website is not described all functions but just the basic one.
You can even looking for a specific action when you are browsing the web interface of the modem, it's very simple and clear! Just go to when the dongle is attached on your computer.

I had to create a library to use this dongle with my project, you may not like Python but you can even port my helper class to any other languages!
Just remember that each call have to be sent as XML content

Link of the library

How to use it
The library is very easy to use, just import it on your own project and then create the object:
a  = Huawei()
after that you can easily check if your dongle is already connected, just calling:

Please send me an email if you are going to find any issue with this library or if you want to add some other things.

Implementation with Raspberry 


  1. Hi Christian,

    Thanks for the api. Used it in conjunction with a debugging proxy to investigate the different api calls. I'm building a small Android app that (re)connects my t-mobile branded Huawei E587 mifi. Such a pain to login to the web interface, press connect, press OK at the roaming warning and connect. Especially while driving...

    Thanks for sharing!

    Arend de Boer

  2. Have you managed to use USSD codes?
    Can you also shed some light on how to unlock the pin lock? I'm trying but I do not want to update to a new pin, just unlock the dongle.