4

I found out that my 3G modem keeps closing the connection every couple hours. I tried to set up a reset script, everything works fine and I know how to do it, with one little problem: The only way I've found how to reset the device is physically unplug it and plug it back.

So my question is, how can I perform the unplug+replug operation software-wise? I've seen both How do I reset a USB device using a script? suggesting echo 0/1 > authorized and Resetting usb device from terminal suggesting usbreset, but usbreset doesn't manage to reset the device properly, and writing to authorized managed to cause two things: 1) freeze RPi, 2) forbidding echo 1>authorized with Error: Broken pipe.

So I look for another method how to truly reset the device without having to touch it. If it's easily possible via GPIO with some trick, I'm open to such solution as well.

Details: Debian GNU/Linux 7.0 (wheezy), the device is Huawei E220 12d1:1003, plugged through a powered USB hub 05e3:0606.

2
  • I have the same problem with the Huawei E220 USB modem. Did you find a solution to this? or do you know any other USB modem that does not crash every few hours?
    – Arya
    Commented Jul 2, 2015 at 16:08
  • This solution works well: electronics.stackexchange.com/questions/103678/…
    – yo'
    Commented Jul 2, 2015 at 18:21

1 Answer 1

2

I have no idea on how to do that in software, but I do have an idea on how to implement such a feature in hardware, using one GPIO from the Pi.

You need a N-channel MOSFET like BS170 (It switches 500mA, maybe you want a bigger one) and a USB extension cord for this. Remove the protective shielding of the cable and find out its power wire, ususlly red. Cut that wire and insert the MOSFET, source pin to the MODEM and drain pin to your Pi, then wire the Gate pin to one of the GPIO on your Pi.

When you are using the modem, write 1 to the GPIO pin, turning the 3G modem on; and when you need to reset it, write 0 to the GPIO and wait for a little while, write 1 again to power cycle the modem.

5
  • Sounds cool. I'll definitely try this. I think that 500mA is quite tight, but should be fine, I'll see if my electronics shop has something stronger. Thanks a lot!
    – yo'
    Commented Mar 20, 2014 at 7:31
  • I can't make it work :( I found out a scheme at elinux.org. They suggest a bit different thing: putting the MOSFET on the - wire instead of the + one. As well, the maximum gate voltage is 3V and I gave it 3.3V :-/ Have you got an idea what could I have done wrong?
    – yo'
    Commented Mar 20, 2014 at 23:49
  • You need another MOSFET, a bigger one. I am no guru on that so maybe you need to find a datasheet collection and look for your ideal model. Alternatively, you can use low-voltage solid-state relays. Those switches 1A or up at 5V. Commented Mar 24, 2014 at 5:23
  • I've got a working solution, but it took me a lot of effort and remembering my physics knowledge from the high school. You need an N-FET on the GPIO side and a P-FET on the USB cable side, see my self-answer on EE.SE
    – yo'
    Commented Mar 24, 2014 at 9:38
  • @tohecz I have implemented one myself too but using both MOSFET and BJT. I used a 2N7000 N-MOSFET to push out a little current then a C8550 PNP-BJT to push out the power. Also the four-terminal adjustable low-drop linear regulator PQ30NV11 but that is very difficult to find and quite expensive Commented Apr 1, 2014 at 5:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.