# Raspberry Pi Zero W USB power

**URL:** <https://forum.core-electronics.com.au/t/raspberry-pi-zero-w-usb-power/2105>\
**Category:** Raspberry Pi\
**Created:** [22 January 2018 04:55 UTC](https://forum.core-electronics.com.au/t/raspberry-pi-zero-w-usb-power/2105 "2018-01-22T04:55:52Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dylan56007](https://avatars.discourse-cdn.com/v4/letter/d/50afbb/32.png) [@Dylan56007](https://forum.core-electronics.com.au/u/Dylan56007)\
**Post date:** [22 January 2018 04:55 UTC](https://forum.core-electronics.com.au/t/raspberry-pi-zero-w-usb-power/2105/1 "2018-01-22T04:55:52Z")

</div>

Hi All!

I have a quick question.

Using the following code, I am able to successfully cut power to a USB device:

```
echo 0 > /sys/devices/platform/soc/20980000.usb/buspower
sleep 5
echo 1 > /sys/devices/platform/soc/20980000.usb/buspower

```

However, no matter how long the sleep time, it still only cuts power for a second.  
Anyone know how to cut power for say, 5 seconds?

I have a USB device that sometimes freezes, and would like to automate unplugging/replugging to save me the tedious exercise of doing so manually each day

---

<div class="post-metadata">

**Author:** ![Sam](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/sam/32/99_2.png) [@Sam](https://forum.core-electronics.com.au/u/Sam)\
**Post date:** [23 January 2018 00:08 UTC](https://forum.core-electronics.com.au/t/raspberry-pi-zero-w-usb-power/2105/2 "2018-01-23T00:08:31Z")

</div>

Hi Dylan,

Straight off the bat, I’m not sure why that doesn’t work. How are you running it? Are you making it executable and then running it?

---

<div class="post-metadata">

**Author:** ![Dylan56007](https://avatars.discourse-cdn.com/v4/letter/d/50afbb/32.png) [@Dylan56007](https://forum.core-electronics.com.au/u/Dylan56007)\
**Post date:** [23 January 2018 00:44 UTC](https://forum.core-electronics.com.au/t/raspberry-pi-zero-w-usb-power/2105/3 "2018-01-23T00:44:58Z")

</div>

Hi Sam,  
Yeah

Made a script: dem  
Placed snippet in dem  
chmod +x ./dem  
then running sudo ./dem

---

<div class="post-metadata">

**Author:** ![Sam](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/sam/32/99_2.png) [@Sam](https://forum.core-electronics.com.au/u/Sam)\
**Post date:** [23 January 2018 01:04 UTC](https://forum.core-electronics.com.au/t/raspberry-pi-zero-w-usb-power/2105/4 "2018-01-23T01:04:31Z")

</div>

Hmm, what about if you run it from the full extension? ie. sudo /home/pi/bin/_script\_emphasized text_\_

---

<div class="post-metadata">

**Author:** ![Dylan56007](https://avatars.discourse-cdn.com/v4/letter/d/50afbb/32.png) [@Dylan56007](https://forum.core-electronics.com.au/u/Dylan56007)\
**Post date:** [23 January 2018 01:09 UTC](https://forum.core-electronics.com.au/t/raspberry-pi-zero-w-usb-power/2105/5 "2018-01-23T01:09:12Z")

</div>

Yeah it doesnt change.

It’s almost like something changes it right back to 1 the moment i do it

---

<div class="post-metadata">

**Author:** ![Sam](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/sam/32/99_2.png) [@Sam](https://forum.core-electronics.com.au/u/Sam)\
**Post date:** [23 January 2018 01:17 UTC](https://forum.core-electronics.com.au/t/raspberry-pi-zero-w-usb-power/2105/6 "2018-01-23T01:17:27Z")

</div>

Hmm, what about if you make it something like 20 seconds? It could also be something in the kernal or hardware implementation which prevents it from being turned off for too long. I’ll have a look and let you know

---

<div class="post-metadata">

**Author:** ![Dylan56007](https://avatars.discourse-cdn.com/v4/letter/d/50afbb/32.png) [@Dylan56007](https://forum.core-electronics.com.au/u/Dylan56007)\
**Post date:** [23 January 2018 01:26 UTC](https://forum.core-electronics.com.au/t/raspberry-pi-zero-w-usb-power/2105/7 "2018-01-23T01:26:18Z")

</div>

yeah the duration of the sleep doesn’t make a difference 😕

Oh thanks!

---

<div class="post-metadata">

**Author:** ![Sam](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/sam/32/99_2.png) [@Sam](https://forum.core-electronics.com.au/u/Sam)\
**Post date:** [23 January 2018 01:30 UTC](https://forum.core-electronics.com.au/t/raspberry-pi-zero-w-usb-power/2105/8 "2018-01-23T01:30:48Z")

</div>

Well, I can’t seem to find a concrete answer on that. There does seem to be have been changes on how USB power management is handled and what you can do in software. I’m not sure if that has something to do with it though. The easiest way to test that would be to control an LED as well (or some other indicator) before and after the sleep duration so you can see if the script is running correctly and it’s just a hardware management issue.

---

<div class="post-metadata">

**Author:** ![Dylan56007](https://avatars.discourse-cdn.com/v4/letter/d/50afbb/32.png) [@Dylan56007](https://forum.core-electronics.com.au/u/Dylan56007)\
**Post date:** [23 January 2018 01:36 UTC](https://forum.core-electronics.com.au/t/raspberry-pi-zero-w-usb-power/2105/9 "2018-01-23T01:36:31Z")

</div>

HI Sam,

I know - it’s infuriating.

The device I’m using does have an LED, so you can see when it turns off & when it turns back on.

[http://sendvid.com/fukj9xmq](http://sendvid.com/fukj9xmq)

---

<div class="post-metadata">

**Author:** ![Sam](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/sam/32/99_2.png) [@Sam](https://forum.core-electronics.com.au/u/Sam)\
**Post date:** [23 January 2018 01:49 UTC](https://forum.core-electronics.com.au/t/raspberry-pi-zero-w-usb-power/2105/10 "2018-01-23T01:49:06Z")

</div>

Hmm, what I’d try, is get a multimeter out (or even better, a scope), and monitor the 5V line to see if it’s truly disconnecting bus power, or just sending a shutdown message to your USB device.

---

<div class="post-metadata">

**Author:** ![Dylan56007](https://avatars.discourse-cdn.com/v4/letter/d/50afbb/32.png) [@Dylan56007](https://forum.core-electronics.com.au/u/Dylan56007)\
**Post date:** [23 January 2018 01:57 UTC](https://forum.core-electronics.com.au/t/raspberry-pi-zero-w-usb-power/2105/11 "2018-01-23T01:57:02Z")

</div>

Haha, bugger, I would but I’m overseas for the next two weeks

---

<div class="post-metadata">

**Author:** ![Sam](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/sam/32/99_2.png) [@Sam](https://forum.core-electronics.com.au/u/Sam)\
**Post date:** [23 January 2018 01:59 UTC](https://forum.core-electronics.com.au/t/raspberry-pi-zero-w-usb-power/2105/12 "2018-01-23T01:59:37Z")

</div>

No worries, well, perhaps we can get back to it then

---

<div class="post-metadata">

**Author:** ![Dylan56007](https://avatars.discourse-cdn.com/v4/letter/d/50afbb/32.png) [@Dylan56007](https://forum.core-electronics.com.au/u/Dylan56007)\
**Post date:** [23 January 2018 05:31 UTC](https://forum.core-electronics.com.au/t/raspberry-pi-zero-w-usb-power/2105/13 "2018-01-23T05:31:59Z")

</div>

No stress,

In the meantime, I may be able to solve my problem using this API:

> <https://github.com/Schroedingers-Hat/Huawei-K4203/blob/master/huawei-K4203-api.yml>

but I’m struggling with the HTTP post format. Do you know how it’s meant to be written?

curl -d “request=!!omap&Action=1” -X POST [http://192.168.9.1/api/dialup/dial](http://192.168.9.1/api/dialup/dial)

---

<div class="post-metadata">

**Author:** ![Sam](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/sam/32/99_2.png) [@Sam](https://forum.core-electronics.com.au/u/Sam)\
**Post date:** [24 January 2018 00:07 UTC](https://forum.core-electronics.com.au/t/raspberry-pi-zero-w-usb-power/2105/14 "2018-01-24T00:07:43Z")

</div>

You’re stepping into unknown waters for me too I’m afraid. Someone else from the community might be able to shed some more insight though.

---

<div class="post-metadata">

**Author:** ![Dylan56007](https://avatars.discourse-cdn.com/v4/letter/d/50afbb/32.png) [@Dylan56007](https://forum.core-electronics.com.au/u/Dylan56007)\
**Post date:** [24 January 2018 01:07 UTC](https://forum.core-electronics.com.au/t/raspberry-pi-zero-w-usb-power/2105/15 "2018-01-24T01:07:34Z")

</div>

Hi Sam,

No stress found the answer.

In case anybody else is wondering:

download and unzip (on pi) the API from: [https://github.com/Schroedingers-Hat/](https://github.com/Schroedingers-Hat/)

then install “python-yaml” to run that (sudo apt-get install python-yaml)​

then run “python [huaweisms.py](http://huaweisms.py) connect”, or “disconnect”, or any other action

---

<div class="post-metadata">

**Author:** ![Sam](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/sam/32/99_2.png) [@Sam](https://forum.core-electronics.com.au/u/Sam)\
**Post date:** [24 January 2018 02:02 UTC](https://forum.core-electronics.com.au/t/raspberry-pi-zero-w-usb-power/2105/16 "2018-01-24T02:02:35Z")

</div>

Nice! Glad to hear it all worked out Dylan, definitely some valuable info to have on the forum.
