<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="FeedCreator 1.8" -->
<?xml-stylesheet href="https://baszerr.eu/lib/exe/css.php?s=feed" type="text/css"?>
<rss version="2.0">
    <channel xmlns:g="http://base.google.com/ns/1.0">
        <title>BaSzErr - prjs:usb_power_ctrl</title>
        <description></description>
        <link>https://baszerr.eu/</link>
        <lastBuildDate>Fri, 01 May 2026 12:38:37 +0000</lastBuildDate>
        <generator>FeedCreator 1.8</generator>
        <image>
            <url>https://baszerr.eu/lib/exe/fetch.php?media=wiki:dokuwiki.svg</url>
            <title>BaSzErr</title>
            <link>https://baszerr.eu/</link>
        </image>
        <item>
            <title>usb_power_controller</title>
            <link>https://baszerr.eu/doku.php?id=prjs:usb_power_ctrl:usb_power_controller</link>
            <description>
&lt;h1 class=&quot;sectionedit1&quot; id=&quot;usb_power_controller&quot;&gt;USB power controller&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
&lt;a href=&quot;https://baszerr.eu/lib/exe/detail.php?id=prjs%3Ausb_power_ctrl%3Ausb_power_controller&amp;amp;media=prjs:usb_power_ctrl:cmd_line_iface.png&quot; class=&quot;media&quot; title=&quot;prjs:usb_power_ctrl:cmd_line_iface.png&quot;&gt;&lt;img src=&quot;https://baszerr.eu/lib/exe/fetch.php?w=400&amp;amp;tok=32b78f&amp;amp;media=prjs:usb_power_ctrl:cmd_line_iface.png&quot; class=&quot;mediaright&quot; align=&quot;right&quot; loading=&quot;lazy&quot; title=&quot;command line view&quot; alt=&quot;command line view&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;
this software-hardware solution allows you to turn on and off any devices connected to the computer via software. it has been developed in a free time to spare my plugging in and out devices manually. yes - i am lazy and proud of it. ;)
&lt;/p&gt;

&lt;p&gt;
device has a wide number of usages. you can connect typical devices used with-or-near your computer and operate them, without have a need to have all of the cables on the desk. typical devices are:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; routers and switches (note: auto power up when computer starts)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; phone and laptop chargers&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; printers (note: script may power it up when printer&amp;#039;s queue is non-empty and shut down later on – fully automatic!)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; external hard drives&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; monitors (note: can be connected with the screen saver)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; toasters, kettles, coffee machines… :)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; …&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;USB power controller&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;usb_power_controller&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:1,&amp;quot;range&amp;quot;:&amp;quot;1-898&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit2&quot; id=&quot;features&quot;&gt;features&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; 4 independent sockets to control&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; USB standard device&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; persistent memory for default states upon power on&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; command line and &lt;abbr title=&quot;Graphical User Interface&quot;&gt;GUI&lt;/abbr&gt; interfaces&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; tested to work on &lt;a href=&quot;https://en.wikipedia.org/wiki/Linux&quot; class=&quot;interwiki iw_wp&quot; title=&quot;https://en.wikipedia.org/wiki/Linux&quot;&gt;Linux&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Windows&quot; class=&quot;interwiki iw_wp&quot; title=&quot;https://en.wikipedia.org/wiki/Windows&quot;&gt;Windows&lt;/a&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; plain-text protocol used&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; driver written in &lt;a href=&quot;https://en.wikipedia.org/wiki/Python (programming language)&quot; class=&quot;interwiki iw_wp&quot; title=&quot;https://en.wikipedia.org/wiki/Python (programming language)&quot;&gt;Python&lt;/a&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; automatic power off devices when computer is shut down&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;features&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;features&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:2,&amp;quot;range&amp;quot;:&amp;quot;899-1281&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit3&quot; id=&quot;hardware&quot;&gt;hardware&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
hardware consists of two pain parts:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; the board, connected to the computer&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; relays, turning on and off devices&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
the board is quite simple. it consists of FT232 for USB communications, ATTiny2313 uC for doing all of the processing, communications and saving persistent state, transistors for controlling relays. see schematics (click on the image to enlarge it):
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://baszerr.eu/lib/exe/detail.php?id=prjs%3Ausb_power_ctrl%3Ausb_power_controller&amp;amp;media=prjs:usb_power_ctrl:schematics.png&quot; class=&quot;media&quot; title=&quot;prjs:usb_power_ctrl:schematics.png&quot;&gt;&lt;img src=&quot;https://baszerr.eu/lib/exe/fetch.php?w=600&amp;amp;tok=8b0e19&amp;amp;media=prjs:usb_power_ctrl:schematics.png&quot; class=&quot;media&quot; loading=&quot;lazy&quot; title=&quot;board schematics&quot; alt=&quot;board schematics&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
note that Kanda connector is optional. if you have an option to flash uC before soldering it, there is no need for you to use it at all. PCB view goes here (click to enlarge image):
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://baszerr.eu/lib/exe/detail.php?id=prjs%3Ausb_power_ctrl%3Ausb_power_controller&amp;amp;media=prjs:usb_power_ctrl:board.png&quot; class=&quot;media&quot; title=&quot;prjs:usb_power_ctrl:board.png&quot;&gt;&lt;img src=&quot;https://baszerr.eu/lib/exe/fetch.php?w=400&amp;amp;tok=1f6368&amp;amp;media=prjs:usb_power_ctrl:board.png&quot; class=&quot;media&quot; loading=&quot;lazy&quot; title=&quot;PCB view&quot; alt=&quot;PCB view&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
note that board is almost one-sided. :) it is prepared so that you can make it as a one-side board at home and than wire the missing “bottom” elements together, with any isolated wire. if you do not use Kanda, only 3 wires are there. :)
&lt;/p&gt;

&lt;p&gt;
as a base for the electric part i&amp;#039;ve decided to use &lt;a href=&quot;http://www.brennenstuhl.de&quot; class=&quot;urlextern&quot; title=&quot;http://www.brennenstuhl.de&quot; rel=&quot;ugc nofollow&quot;&gt;Brennenstuhl&amp;#039;s&lt;/a&gt; PremiumLine power extension cord, like this:
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://baszerr.eu/lib/exe/detail.php?id=prjs%3Ausb_power_ctrl%3Ausb_power_controller&amp;amp;media=prjs:usb_power_ctrl:pwr_ext_cord.jpg&quot; class=&quot;media&quot; title=&quot;prjs:usb_power_ctrl:pwr_ext_cord.jpg&quot;&gt;&lt;img src=&quot;https://baszerr.eu/lib/exe/fetch.php?w=500&amp;amp;tok=0b74f6&amp;amp;media=prjs:usb_power_ctrl:pwr_ext_cord.jpg&quot; class=&quot;media&quot; loading=&quot;lazy&quot; title=&quot;power extension cord used&quot; alt=&quot;power extension cord used&quot; width=&quot;500&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
i choose it because of its modular design and on/off switches already available, which means that each socket is separated by design, thus making my hack simpler to apply. :) all you need to do is to make a hole for USB cable to fit and replace connectors to the switches with the relays of your choice and connecting relays to the control board, presented above. tiny wires are fine to connect relay control.
&lt;/p&gt;

&lt;p&gt;
speaking of the relays. i&amp;#039;ve chosen &lt;a href=&quot;http://www.willow.co.uk/RM84.pdf&quot; class=&quot;urlextern&quot; title=&quot;http://www.willow.co.uk/RM84.pdf&quot; rel=&quot;ugc nofollow&quot;&gt;RM84&lt;/a&gt; relays, of polish production. they are controlled with 5V, 80mA. this fits perfectly, since 5V is the voltage we get from USB and 4*80mA=420mA + few mA for control electronics fits in 500mA USB 2.0 power limit as well.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;hardware&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;hardware&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:3,&amp;quot;range&amp;quot;:&amp;quot;1282-3131&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit4&quot; id=&quot;software&quot;&gt;software&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
software consists of two parts:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; computer driver&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; device driver (i.e. uC code)&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;software&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;software&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:4,&amp;quot;range&amp;quot;:&amp;quot;3132-3240&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit5&quot; id=&quot;device_driver&quot;&gt;device driver&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
device driver is placed in board/src/ directory. to compile it it is enough to type:
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;make&lt;/pre&gt;

&lt;p&gt;
by default release version is build. note that by default precompiled version is available in board/src/gen/release directory (bot binary and hex file).
&lt;/p&gt;

&lt;p&gt;
to perform next steps you need to be root. in order to flash uC with build software type:
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;make PROFILE=release flash_mcu&lt;/pre&gt;

&lt;p&gt;
now it is time to plug in USB cable and reprogram FT232, to serve its purpose:
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;make setup_ft232&lt;/pre&gt;

&lt;p&gt;
this sets maximum current and output clock signal on the proper pins. this step has to be done only once.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;device driver&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;device_driver&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:5,&amp;quot;range&amp;quot;:&amp;quot;3241-3840&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit6&quot; id=&quot;computer_driver&quot;&gt;computer driver&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
having device configured and flashed with software it is time to run the computer driver. driver script is written in Python and is placed under driver/ directory. following files are available:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; extension_cort_ctrl-gui.pyw – &lt;abbr title=&quot;Graphical User Interface&quot;&gt;GUI&lt;/abbr&gt; interface version&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; extension_cort_ctrl.py – command line version&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; usbpwrctrl.py – module that implements device&amp;#039;s communication protocol&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
module can be freely used from other scripts directly, though for simplicity, most of the time, command line tool should just do the trick. :)
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;computer driver&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;computer_driver&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:6,&amp;quot;range&amp;quot;:&amp;quot;3841-4391&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit7&quot; id=&quot;download&quot;&gt;download&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
latest version can be obtained via &lt;a href=&quot;https://github.com/el-bart/usb_power_ctrl&quot; class=&quot;urlextern&quot; title=&quot;https://github.com/el-bart/usb_power_ctrl&quot; rel=&quot;ugc nofollow&quot;&gt;USB power control&lt;/a&gt; project on github. &lt;a href=&quot;https://github.com/el-bart/usb_power_ctrl/tags&quot; class=&quot;urlextern&quot; title=&quot;https://github.com/el-bart/usb_power_ctrl/tags&quot; rel=&quot;ugc nofollow&quot;&gt;recent releases&lt;/a&gt; can be obtained via proper tags.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;download&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;download&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:7,&amp;quot;range&amp;quot;:&amp;quot;4392-&amp;quot;} --&gt;</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Tue, 15 Jun 2021 20:09:53 +0000</pubDate>
        </item>
    </channel>
</rss>
