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.

yo'
  • 397
  • 5
  • 19

1 Answers1

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.

Maxthon Chan
  • 1,051
  • 8
  • 14