# usbconfig power_off does not power off



## weberjn (Aug 5, 2021)

I have an old Nexus 9 I'd like to use as display for openHAB.

To preserve the battery I am thinking to keep charge between 20 and 80%
Idea is to plug it into an USB port of my FreeBSD NUC7 and switch on and off the USB port, controlled by termux and termux-battery-status on the tablet.



```
sudo usbconfig -d 0.3 power_off
sudo usbconfig
ugen0.1: <0x8086 XHCI root HUB> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA)
ugen0.2: <vendor 0x8087 product 0x0aaa> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (100mA)
ugen0.3: <Android    gr8rFiV8US03C03C00 Android> at usbus0, cfg=255 md=HOST spd=FULL (12Mbps) pwr=OFF (500mA)
```

but the tablet still gets power. Any ideas? 

FreeBSD 13.0-RELEASE-p3

I plugged the tablet into a Pi 3B, there I can switch off the usb ports with uhubctl -l 1-1 -p 2 -a 0  and the tablet goes off power. Unfortunately, the PI 3 usb ports are ganged, you switch off all of them at once.

I also compiled uhubctl on FreeBSD, but it does not see any usb ports.


----------



## SirDice (Aug 6, 2021)

weberjn said:


> To preserve the battery I am thinking to keep charge between 20 and 80%


That was good form for old NiCd or NiMH batteries, modern batteries are usually Lithium-ion. Li-ion doesn't suffer from the memory effect. 

`usbconfig -d ... power_off` turns off the device, not the USB port.


----------



## trev (Aug 7, 2021)

There's an interesting discussion about the topic of USB devices not turning off in the uhubctl repo (uhubctl is a utility to control USB power per-port on smart USB hubs. Smart hub is defined as one that implements per-port power switching) .


----------



## weberjn (Aug 8, 2021)

I think now, the Nuc doesn't have a controllable usb hub.

So I'll use a Raspberry 3 I have laying around, it doesn't cost more than a controllable hub, and uses less energie. I tested uhubctl, it can control the Pi 3 ports, but only all of them at once.

On the tablet in Termux, I have a cron job that checks the battery and triggers via nttp openHAB which controls the pi via ssh.



SirDice said:


> That was good form for old NiCd or NiMH batteries, modern batteries are usually Lithium-ion. Li-ion doesn't suffer from the memory effect.



I have no experience, but there are lots of postings about swollen batteries on the web, e.g.








						iPad being using in wall mount battery swollen
					

Ive got an install with an iPad mini 4 installed in a wall mount running locked to a single app. The wall mount has a POE to USB adaptor built in.  The iPad is powered by a TP link POE adaptor : ht...




					apple.stackexchange.com


----------



## SirDice (Aug 8, 2021)

weberjn said:


> I have no experience, but there are lots of postings about swollen batteries on the web, e.g.


Li-ion will still degrade over time even if it doesn't suffer from the same issues as NiCd or NiMH. Heat is a much bigger problem for Li-ion.


----------

