<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>electro·pizza</title>
  
  <subtitle>Chaotic Ramblings</subtitle>
  <link href="https://electro.pizza/feed.xml" rel="self"/>
  
  <link href="https://electro.pizza/"/>
  <updated>2023-11-09T21:45:09.035Z</updated>
  <id>https://electro.pizza/</id>
  
  <author>
    <name>Ryan Oles</name>
    
  </author>
  
  <generator uri="https://hexo.io/">Hexo</generator>
  
  <entry>
    <title>Selfhosting with Odroid XU4 CloudShell2</title>
    <link href="https://electro.pizza/2020/05/selfhosting-cloudshell2/"/>
    <id>https://electro.pizza/2020/05/selfhosting-cloudshell2/</id>
    <published>2020-05-24T22:19:50.000Z</published>
    <updated>2023-11-09T21:45:09.035Z</updated>
    
    <content type="html"><![CDATA[<p>For several years I have wanted to setup a Network Attached Storage (NAS) solution.  My thinking at the time was to have a place for local backups, and ease of filesharing amongst devices. There are many solutions available for someone looking to setup a NAS. So much so that I found myself paralyzed by choice. Do you build your own, and if so should it be some Xeon monster or something more modest? Maybe an off the shelf solution is the way to go? Once that’s sorted then what do you run? Open Media Vault, FreeNAS, Yunohost, etc, etc?</p><p>A confluence of things helped me to finally make a decision:</p><ul><li>I had been using Single Board Computers (SBC) for small projects and utilities, and have watched these small affordable devices grow in capability with excitement.</li><li>HardKernel was offering a case for its relatively powerful Odroid XU4 SBC that accepted two 3.5” drives along with a hardware RAID controller.</li><li>A realization that folks were using Docker, and production server strategies used on the web for years, to build up their home server software solutions.</li><li>Growing frustration, disenchantment, and general mistrust of mainstream cloud service providers motivated me to dive in and try something.</li></ul><img src="/2020/05/selfhosting-cloudshell2/cloudshell-cactus.jpg" class="" title="CloudShell2 on the Desk"><p>The XU4 CloudShell2 solution is small and affordable, a perfect platform to experiment and try things without a huge upfront investment. I felt that even if I quickly found myself wanting to upgrade, the experienced gained from running this little box would help me better understand my needs.</p><p>I’d like to detail some of the setup along with a few tweaks that improved my experience with this device. Hopefully this will provide a bit more information to anyone considering the CloudShell2, and perhaps some guidance to those who may be setting up their own.</p><h2 id="Cost"><a href="#Cost" class="headerlink" title="Cost"></a>Cost</h2><p>For those interested, below is an itemization of my costs. These components were purchsed in the Spring of 2019, and prices will of course fluctuate (and I imagine reduce) over time. Links to the products are omitted over concern that they will eventually become invalid, but at the time of this writing they should be relatively easy to find.</p><table><thead><tr><th>Component</th><th>Vendor</th><th align="right">Price</th></tr></thead><tbody><tr><td>Odroid-XU4</td><td>ameriDroid</td><td align="right">$51.95</td></tr><tr><td>eMMC 32GB</td><td>ameriDroid</td><td align="right">$26.95</td></tr><tr><td>CloudShell2 Kit</td><td>ameriDroid</td><td align="right">$69.95</td></tr><tr><td>Power Cord</td><td>ameriDroid</td><td align="right">$2.95</td></tr><tr><td>Seagate IronWolf 4TB Drive x 2</td><td>amazon</td><td align="right">$200.00</td></tr></tbody></table><pre><code>                          |          |                          |__Total:__|__$351.80__</code></pre><p>Of course this setup could be considerably cheaper if you went with some smaller drives or if you have some spares lying around. Drive cost aside, things come in at a very reasonable $150.</p><p>Comparatively you can purchase a driveless Synology DiskStation DS218+ 2 bay NAS for just shy of $300. Adding the cost of a couple 4TB drives and you’re looking at about $500. Granted this is a bit of an apples to oranges comparison, but I think it’s worth looking at something a least somewhat analogous in the consumer “plug and play” space.</p><h2 id="Initial-Setup"><a href="#Initial-Setup" class="headerlink" title="Initial Setup"></a>Initial Setup</h2><p>Generally I followed the <a href="https://wiki.odroid.com/accessory/add-on_boards/xu4_cloudshell2/xu4_cloudshell2#easy_installations">easy install guide</a> with only a couple of changes. Most notably, I didn’t bother with the IR sensor configuration, and I didn’t install the <code>cloudshell-lcd</code> package in favor of <a href="#nmon-on-the-LCD">something more custom</a>.</p><h3 id="Assembly"><a href="#Assembly" class="headerlink" title="Assembly"></a>Assembly</h3><p>Assembly is fairly straightforward when following <a href="https://wiki.odroid.com/accessory/add-on_boards/xu4_cloudshell2/cs2_assembling2">the assembly guide</a>. The only tool required is a phillips head screwdriver. Go slow and don’t try to force any of the acryllic fittings. They should slide together easily and you may break tabs if you use too much force (I broke two).<br><video title="Assembling the CloudShell. Yeah the lighting sucks." loop="true" muted="true" autoplay="false"><br>  <source src="/2020/05/selfhosting-cloudshell2/cloudshell-fast.mp4" type="video/mp4"><br>  <em>Your browser is having trouble with the video. You can check it out <a href="/2020/05/selfhosting-cloudshell2/cloudshell-fast.mp4">here</a>.</em><br></video></p><h3 id="Drive-Setup"><a href="#Drive-Setup" class="headerlink" title="Drive Setup"></a>Drive Setup</h3><p>After <a href="https://wiki.odroid.com/accessory/add-on_boards/xu4_cloudshell2/xu4_cloudshell2#set_the_raid_mode">dialing in the RAID controller</a> you will need to make some decisions about drive partitioning, file system type, and mounting location. Everyone will have their own preferences on this configuration, but I settled on RAID 1 formatted with an ext4 filesystem with only 1 partition mounted at <code>/mnt/storage</code>.</p><p>I am planning on managing everthing on this system with Docker, leaning on a docker-compose file that lives on the emmc (and backed up in a private repo). The thinking is that all volumes defined in Docker will be housed on the <code>/mnt/storage</code> RAID drive, and nothing else. This simplifies offsite backups and recovery. A backup script can run across the whole drive knowing that it will only be getting relevant data and no OS cruft. Further, if the RAID drive fails and needs replacement, new drives can be swapped in, formatted, and mounted. Afterward a simple <code>docker-compose up</code> command will build a fresh setup, or offiste backups can be restored, and Docker will chug along like nothing happened.</p><h3 id="nmon-on-the-LCD"><a href="#nmon-on-the-LCD" class="headerlink" title="nmon on the LCD"></a>nmon on the LCD</h3><p>CloudShell2 comes with a small (320x240) LCD screen attached. If you follow the <a href="https://wiki.odroid.com/accessory/add-on_boards/xu4_cloudshell2/quicksetup">Quick Setup guide</a> from HardKernel it will be enabled with a simple script displaying some hardware stats.  This is okay, but I’m much more interested in being able to see activity at a glance. <a href="https://github.com/DaveBurkhardt/cloudshell-nmon">Dave Burkhardt’s excellent work modifying nmon</a> for the CloudShell display fits the bill nicely. Installation is straight forward, and it is well detailed in the <a href="https://github.com/DaveBurkhardt/cloudshell-nmon#readme">project readme</a>.</p><img src="/2020/05/selfhosting-cloudshell2/nmon-sync.png" class="" title="Modified nmon"><p>By default the script will show network activity, which when using Docker becomes a bit useless due to clutter. Mostly I want to see CPU and drive activity, so I’ve modified the nmon options in <code>nmon-xu4</code> as follows:</p><figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">export NMON=xtfcdG</span><br></pre></td></tr></table></figure><p>These options will show CPU activity, drive activity, and a short top list of processes.</p><h3 id="Fan-Upgrade"><a href="#Fan-Upgrade" class="headerlink" title="Fan Upgrade"></a>Fan Upgrade</h3><p>The fan that ships with the Cloudshell kit is adequate but noisy. I don’t think this would be much of a problem if you are keeping the Cloudshell in a closet, or a good distance from you. However, I have it sitting on my desk and the fan noise began to slowly erode my sanity. Time for an upgrade! The kit takes a 92mm 5V 3-Pin fan and there are plenty of high quality quiet fan options out there that fit this spec. I settled on a Noctua NF-A9 and it has been a huge improvement.</p><img src="/2020/05/selfhosting-cloudshell2/noctua-fan-replacement.jpg" class="" title="Noctua NF-A9 Replacement"><h2 id="Docker"><a href="#Docker" class="headerlink" title="Docker"></a>Docker</h2><p>There is a lot of documentation on the web about using Docker, and it is a bit out of scope for this document to detail its use. It has been a good experience managing things with <a href="https://docs.docker.com/compose/">Docker Compose</a> and I can recommend doing so. There are a couple of XU4&#x2F;ARM related issues I ran across while getting things installed that are worth mentioning:</p><h3 id="Installing-Docker"><a href="#Installing-Docker" class="headerlink" title="Installing Docker"></a>Installing Docker</h3><p>Installing Docker via apt on ARM does not seem possible at this time, resulting in the following error:</p><figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">E: Package &#x27;docker-ce&#x27; has no installation candidate</span><br></pre></td></tr></table></figure><p>However using the Docker installation script from <a href="https://get.docker.com/">get.docker.com</a> works just fine.</p><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">apt install curl</span><br><span class="line">curl -fsSL get.docker.com -o get-docker.sh</span><br><span class="line">sh get-docker.sh</span><br></pre></td></tr></table></figure><p>Once the script has finished be sure to add your user to the Docker group.</p><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">usermod -aG docker &lt;username&gt;</span><br></pre></td></tr></table></figure><h3 id="Docker-Compose-Installation"><a href="#Docker-Compose-Installation" class="headerlink" title="Docker Compose Installation"></a>Docker Compose Installation</h3><p>Presently there is not a <a href="https://github.com/docker/compose/releases">binary release</a> for ARM64. It appears there is <a href="https://docs.docker.com/compose/install/#install-using-pip">movement</a> to get this into the official builds, so this may not be necessary in the near future. For now however, you can install via pip.</p><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">apt install python-pip libffi-dev</span><br><span class="line">pip install docker-compose</span><br></pre></td></tr></table></figure><h3 id="Portainer"><a href="#Portainer" class="headerlink" title="Portainer"></a>Portainer</h3><p>While I don’t wish to detail all of the containers&#x2F;applications I have running, I feel that <a href="https://www.portainer.io/">Portainer</a> is worth mentioning. Portainer provides a nice web GUI where you can quickly see the status of all of your containers, volumes, networks, etc. Further, you can perform actions on them like restarting a container. I’ve found this very useful to quickly troubleshoot things without having to shell into the box to see what’s going on.</p><img src="/2020/05/selfhosting-cloudshell2/portainer.png" class="" title="Portainer Container List Screen Shot"><h3 id="Traefik-with-Pi-hole-DNS"><a href="#Traefik-with-Pi-hole-DNS" class="headerlink" title="Traefik with Pi-hole DNS"></a>Traefik with Pi-hole DNS</h3><p>Another very common application used in a docker setup is the <a href="https://containo.us/traefik/">traefik</a> reverse proxy. While I have no intention of exposing this NAS to the greater web, I do want to be able to access the various applications using human friendly domain names. Thankfully my local network has a box running <a href="https://pi-hole.net/">pi-hole</a> for LAN-wide ad blocking. Pi-hole uses dnsmasq, and if you use pi-hole on your network you can set a config file to tell dnsmasq to wildcard a domain suffix. For instance on the box running pi-hole you can create a conf file in <code>/etc/dnsmasq.d/</code>, lets call it <code>02-nas.conf</code>, and the file should contain the line:</p><figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line"># Wildcarding for domains to the NAS</span><br><span class="line"></span><br><span class="line">address=/.nas/192.168.xxx.xxx</span><br></pre></td></tr></table></figure><p>Where <code>192.168.xxx.xxx</code> is the local ip of your NAS, then restart the dnsmasq service.</p><figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">pihole restartdns</span><br></pre></td></tr></table></figure><p>What this configuration does is direct dnsmasq to point everything on the LAN requesting a domain with the <code>.nas</code> suffix to the NAS. Now on the traefik side we can use <code>.nas</code> domains for our containers. For instance we could add this label for Portainer in our Docker Compose file:</p><figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">labels:</span><br><span class="line">  - &quot;traefik.frontend.rule=Host:portainer.nas&quot;</span><br></pre></td></tr></table></figure><p>Now if you navigate to <code>portainer.nas</code> in a browser on a machine on the LAN, you will be presented with the Portainer application! I’ve found this to be incredibly handy, especially as the number of applications with a web interface I have on the NAS increases.</p><h2 id="Impressions"><a href="#Impressions" class="headerlink" title="Impressions"></a>Impressions</h2><p>As of this posting I have been using this setup for just over a year, and I am very pleased with it. The system itself is on 24&#x2F;7 and has been very stable. Setting things up with Docker has also proven to be quite useful. It’s easy to spin up and try out new applications, conversly its equally trivial to completely remove applications I am no longer iterested in. This has made for an excellent self-hosted test bed.</p><p>It has been interesting to see what the stand out applications for me are. There are three I actively use every day, <a href="https://nextcloud.com/">Nextcloud</a>, <a href="https://miniflux.app/">Miniflux</a> RSS reader, and <a href="https://wiki.znc.in/ZNC">ZNC</a> IRC bouncer. I have my phone syncing images, contacts, and calendars with NextCloud and this feature alone has become indispensable for me. Since the demise of Google Reader I had been using Feedly to handle all of my RSS subscriptions. Happily, importing an opml file containing my subscriptions and tags from Feedly was simple. I was able to seamlessly begin using miniflux, and I haven’t looked back. Lastly, I went down a small rabbit hole after getting frustrated having multiple chat windows open to converse with people across various chat platforms (hangouts, slack, discord, irc). I wound up being able to let ZNC not only stay logged into IRC, but through the use of <a href="https://www.bitlbee.org/">BitlBee</a>, all of my other chat accounts as well. This means all of my chats can be consolidated into one IRC client connecting to my self-hosted ZNC instance.</p><p>This setup has also been useful in exploring new projects and experimentation. For instance, I’ve been working on local first&#x2F;only home automation. Running node-red, Telegraf&#x2F;InfluxDB, Grafana, and HomeAssistant has worked out very well in this box, and so far has proven to be an excellent ‘hub’ communicating to other SBCs running these automation projects.</p><p>The question that always seems to come up when I talk about this device is about performance. While I have not run any serious performance tests, for my somewhat modest needs, it has been more than adequate. The only place I’ve noticed any lag is when viewing very large NextCloud galleries, which I believe is more of a software issue. I have not setup something like Plex, Emby, or Jellyfin (though I have been considering it), so I cannot speak to the application performance there.</p><p>Overall the XU4 CloudShell2 has proven to be a capable little home server, especially for the price. I’ve learned a lot during its setup and use, and it has comfortably become a part of my daily workflow. If I were to do it all again I think I may attempt a cluster of ARM devices much like <a href="https://nikhiljha.com/posts/armclustertutorial/">Nikhil Jha has detailed</a>. This is not because I’m in any way disappointed with this device, but rather you can build up to a very robust machine one piece at a time. However, I am in no hurry to move off the XU4 CloudShell2, and I fully expect it to continue serving my needs for the forseeable future.</p><h2 id="Resources"><a href="#Resources" class="headerlink" title="Resources"></a>Resources</h2><ul><li><a href="https://wiki.odroid.com/accessory/add-on_boards/xu4_cloudshell2/xu4_cloudshell2">The official Odroid Cloudshell-2 wiki.</a></li><li>Dave Burkhardt’s excellent <a href="https://github.com/DaveBurkhardt/cloudshell-nmon">modifications to nmon for the xu4 and CloudShell LCD</a>.</li><li>Nikhil Jha’s blog post about <a href="https://nikhiljha.com/posts/armclustertutorial/">self-hosting on an ARM cluster.</a></li><li>A great <a href="https://mmm.s-ol.nu/blog/self-hosted_virtual_home/">self-hosting rundown</a> from s-ol using Docker and some cool automatic deployment with git.</li><li><a href="https://github.com/Kickball/awesome-selfhosted">Awesome-Selfhosted</a> is a curated list of applications and services that can be hosted locally.</li><li><a href="https://selfhosted.show/">The Self-Hosted Podcast</a> is a fantastic source of ideas and inspiration.</li></ul>]]></content>
    
    
    <summary type="html">For several years I have wanted to setup a Network Attached Storage (NAS) solution.  My thinking at the time was to have a place for local backups, and ease of filesharing amongst devices. There are many solutions available for someone looking to setup a NAS. So much so that I found myself paralyzed by choice. Do you build your own, and if so should it be some Xeon monster or something more modest? Maybe an off the shelf solution is the way to go? Once that&#39;s sorted then what do you run? Open Media Vault, FreeNAS, Yunohost, etc, etc?</summary>
    
    
    
    
    <category term="SBC" scheme="https://electro.pizza/tags/SBC/"/>
    
    <category term="self hosting" scheme="https://electro.pizza/tags/self-hosting/"/>
    
  </entry>
  
  <entry>
    <title>defMON, VICE, and the Pocket CHIP</title>
    <link href="https://electro.pizza/2019/07/defmon-vice-chip/"/>
    <id>https://electro.pizza/2019/07/defmon-vice-chip/</id>
    <published>2019-07-30T03:33:22.000Z</published>
    <updated>2023-11-09T21:45:09.012Z</updated>
    
    <content type="html"><![CDATA[<p><a href="http://toolsforscholars.com/defmon/doku.php?id=start">defMON</a> is a music tracker for the Commodore 64. It is a bit unique in that it does not use references across many tables, as most C64 sound editors do, but rather a single flexible instruments and effects table. Further, it is under semi-active development – its most recent release is from November of 2018 (as of this writing). This is somewhat of a rarity for an application that runs on nearly 40 year old hardware. I initially became aware of defMON through the works of the artist and musician <a href="https://www.goto80.com/performance">GOTO80</a>, who makes heavy use of it both in his recordings and live performances. The sounds he is able to tease out of the Commodore’s SID chip are unlike most C64 music I have heard, making me very curious about this esoteric application.</p><p>After running the program on my own Commodor 64 and reading through what <a href="http://toolsforscholars.com/defmon/doku.php?id=docs:docs">documentation</a> there is, it became clear, like most things, that defMON would take practice, exploration, and experimentation to really grasp its capabilities. Unfortunately my home lab is small and cluttered, and leaving a Commodore 64 setup would take up a lot of precious space. However, a Commodore can be emulated, and a portable device with a keyboard like the <a href="http://www.chip-community.org/index.php/PocketCHIP">Pocket CHIP</a> would make for a handy way to practice defMON (and use the Commodore in general) without being tethered to a desk.</p><img src="/2019/07/defmon-vice-chip/defmon.jpg" class="" title="C64 defMON!"><p>This post details the process I went through to setup and configure <a href="http://vice-emu.sourceforge.net/">VICE</a> (the VersatIle Commodore Emulator) on the Pocket CHIP to run defMON. While my end goal here is to be able to run defMON from the homepage launcher of the Pocket CHIP, you can follow this setup process (ignoring the defMON stuff) to have a working Commodore emulator. This will allow you to run any number of games, applications, or wild demo packages on the Pocket CHIP.</p><h2 id="Vice-Installation"><a href="#Vice-Installation" class="headerlink" title="Vice Installation"></a>Vice Installation</h2><p><a href="http://vice-emu.sourceforge.net/">VICE</a> is available in the APT repositories, so you can install it via the package manager from Pocket CHIP’s command line.</p><figure class="highlight sh"><table><tr><td class="code"><pre><span class="line">sudo apt install vice</span><br></pre></td></tr></table></figure><p>This package does not install the Commodore 64 system ROM due to copyright concerns (I think) and will not run correctly without it. To add the system ROM after running the apt installation, you need to download the full VICE install from <a href="http://www.zimmers.net/anonftp/pub/cbm/crossplatform/emulators/VICE/vice-3.3.tar.gz">http://www.zimmers.net/anonftp/pub/cbm/crossplatform/emulators/VICE/vice-3.3.tar.gz</a>, unpack it, and copy the contents of its <code>data/C64/</code> folder to <code>/usr/lib/vice/C64/</code>. I like working in a <code>~/src/</code> folder for stuff like this, but you can of course download this to wherever you want.</p><figure class="highlight sh"><table><tr><td class="code"><pre><span class="line"><span class="comment"># Create a directory to work from</span></span><br><span class="line"><span class="built_in">mkdir</span> -p ~/src/c64/vice</span><br><span class="line"><span class="built_in">cd</span> ~/src/c64/vice</span><br><span class="line"></span><br><span class="line"><span class="comment"># Download and extract the ROM</span></span><br><span class="line">wget http://www.zimmers.net/anonftp/pub/cbm/crossplatform/emulators/VICE/vice-3.3.tar.gz</span><br><span class="line">tar -vzxf vice-3.3.tar.gz</span><br><span class="line"></span><br><span class="line"><span class="comment"># Copy the C64 system ROM</span></span><br><span class="line">sudo <span class="built_in">cp</span> -rv vice-3.3/data/C64/* /usr/lib/vice/C64/</span><br></pre></td></tr></table></figure><p>You can now verify that this was all installed correctly by running the <code>x64</code> command. Things will look a bit crazy on this initial run, but as long as you see the blue Commodore 64 ‘Ready’ screen (be patient it takes a few seconds), you have successfully installed VICE along with the Commodore 64 system ROM. You can exit VICE by pressing <code>alt+q</code>.</p><h2 id="VICE-Configuration"><a href="#VICE-Configuration" class="headerlink" title="VICE Configuration"></a>VICE Configuration</h2><p>So VICE is installed but looking pretty broken. The emulator will be more or less unusable on the Pocket CHIP until you make some adjustments to the VICE configuration. All of these adjustments will be under the “Settings” menu, which is difficult to navigate to with the touch screen. I’ve found the best way to do this is to touch the top left corner above “File” and then use the arrow keys to navigate to the “Settings” menu. If you don’t see the top menu bar, you can press <code>alt+b</code> to toggle its visibility. If you would rather not mess with walking through the menu, and just want to use the configuration I’m using at this time, you can replace your vice configuration file at <code>~/.vice/vicerc</code> with my <a href="/2019/07/defmon-vice-chip/vicerc.txt" title="configuration file">configuration file</a>.</p><figure class="highlight sh"><table><tr><td class="code"><pre><span class="line"><span class="built_in">cd</span> ~/src/c64/vice</span><br><span class="line"></span><br><span class="line"><span class="comment"># Download, rename, and replace the config file</span></span><br><span class="line">wget https://electro.pizza/2019/07/defmon-vice-chip/vicerc.txt</span><br><span class="line"><span class="built_in">cp</span> vicerc.txt ~/.vice/vicerc</span><br></pre></td></tr></table></figure><p>I am still experimenting with some of the VICE configuration options, but so far the settings I’ve found that work best for the Pocket Chip and for defMON specifically, are as follows:</p><h4 id="Settings-VIC-II-settings"><a href="#Settings-VIC-II-settings" class="headerlink" title="Settings &gt; VIC-II settings"></a>Settings &gt; VIC-II settings</h4><ul><li>Disable “Hardware scaling” <em>(required)</em></li><li>Disable “Double size” <em>(required)</em></li><li>Set “Render Filter” to “Unfiltered”</li><li>Set “Enable fullscreen” in “Fullscreen settings” (or press <code>alt+d</code>)</li></ul><h4 id="Settings-Sound-settings"><a href="#Settings-Sound-settings" class="headerlink" title="Settings &gt; Sound settings"></a>Settings &gt; Sound settings</h4><ul><li>Set “Sound device name” to “alsa” <em>(required)</em></li><li>Set “Output mode” to “Stereo”</li><li>Decrease “Sample Rate” to “22050Hz”<br><em>(playback seems smoothest at this rate, though this could probably be tweaked)</em></li><li>Ensure “Enable sound playback” is enabled</li></ul><h4 id="Settings-Drive-settings"><a href="#Settings-Drive-settings" class="headerlink" title="Settings &gt; Drive settings"></a>Settings &gt; Drive settings</h4><ul><li>Disable “Drive sound emulation”</li></ul><p><em>Be sure to Save your settings before exiting.</em></p><h3 id="A-note-on-the-keyboard"><a href="#A-note-on-the-keyboard" class="headerlink" title="A note on the keyboard:"></a>A note on the keyboard:</h3><img src="/2019/07/defmon-vice-chip/c64-key-layout.jpg" class="" title="C64 Keyboard Layout"><p>By default VICE uses symbolic keybindings, and I’ve found that for the most part it is intuitive to use.  However, there are a few keys that are special to the Commodore 64 keyboard with symbolic mappings that are not obvious. Most notably:</p><table><thead><tr><th>C64 Key</th><th>Position on C64</th><th>Mapping</th></tr></thead><tbody><tr><td><code>&lt;-</code></td><td>Top Left</td><td><code>_</code> <em>(underscore)</em></td></tr><tr><td><code>ctrl</code></td><td>Upper Middle Left</td><td><code>tab</code></td></tr><tr><td><code>Run Stop</code></td><td>Lower Middle Left</td><td><code>esc</code></td></tr><tr><td><code>C=</code></td><td>Bottom Left</td><td><code>ctrl</code></td></tr></tbody></table><p>There is more information about <a href="http://vice-emu.sourceforge.net/vice_2.html#SEC13">VICE’s keyboard emulation</a> and the VICE emulator in general in their very comprehensive <a href="http://vice-emu.sourceforge.net/vice_toc.html">user manual</a>.</p><h2 id="defMON"><a href="#defMON" class="headerlink" title="defMON"></a>defMON</h2><video title="Funny angle, but the glare was hiddeous." loop="true" muted="true" autoplay="false">  <source src="/2019/07/defmon-vice-chip/defmon-boot.mp4" type="video/mp4">  <em>Your browser is having trouble with the video. You can check it out <a href="/2019/07/defmon-vice-chip/defmon-boot.mp4">here</a>.</em></video><p>You can grab the latest defMON release from the <a href="http://toolsforscholars.com/defmon/doku.php?id=download:download">defMON wiki</a>. Once again this is probably best done from the Pocket CHIP command line.</p><p><em>Double check the <a href="http://toolsforscholars.com/defmon/doku.php?id=download:download">defMON wiki</a> for the latest version. You may need to change the filename in the following command to get the newest version.</em></p><figure class="highlight sh"><table><tr><td class="code"><pre><span class="line"><span class="built_in">mkdir</span> ~/src/c64/defmon</span><br><span class="line"><span class="built_in">cd</span> ~/src/c64/defmon</span><br><span class="line"></span><br><span class="line"><span class="comment"># Download and extract defMON</span></span><br><span class="line">wget http://toolsforscholars.com/defmon/lib/exe/fetch.php?media=download:defmon-20181101.zip</span><br><span class="line">unzip defmon-20181101.zip</span><br></pre></td></tr></table></figure><p>While you can select a ROM from the VICE GUI, I’ve found it more convenient to directly point at the ROM when executing the <code>x64</code> command.  So to run defMON:</p><figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">x64 ~/src/c64/defmon/defmon-20181101.d64</span><br></pre></td></tr></table></figure><h3 id="Pocket-Chip-Homepage-Launcher"><a href="#Pocket-Chip-Homepage-Launcher" class="headerlink" title="Pocket Chip Homepage Launcher"></a>Pocket Chip Homepage Launcher</h3><img src="/2019/07/defmon-vice-chip/pocketchip_main.png" class="" title="Pocket Chip Desktop"><p><span style="text-align: right; display: block;"><em>Background Image: <a href="https://www.instagram.com/p/By6EmUEFxAK/">@mr.melville</a></em></span></p><p>Since I am wanting to practice with defMON somewhat regularly, I’d like to add an item to the homepage launcher to quickly fire up the program. If you are unfamiliar with customizing the launcher, you can do so by editing the <code>/usr/share/pocket-home/config.json</code> file. Simply replace one of the entries in the JSON file with a title, icon, and the command you wish to run.</p><figure class="highlight json"><table><tr><td class="code"><pre><span class="line"><span class="punctuation">&#123;</span></span><br><span class="line">  <span class="attr">&quot;name&quot;</span><span class="punctuation">:</span> <span class="string">&quot;defMON&quot;</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;icon&quot;</span><span class="punctuation">:</span> <span class="string">&quot;appIcons/musicsequencer.png&quot;</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;shell&quot;</span><span class="punctuation">:</span> <span class="string">&quot;x64 /home/chip/src/c64/imgs/defmon-20181101.d64&quot;</span></span><br><span class="line"><span class="punctuation">&#125;</span></span><br></pre></td></tr></table></figure><p>Of course, if you’d rather just run VICE without autorunning defMON you could replace the above shell command with <code>x64</code>.</p><h2 id="Thoughts-on-Usage"><a href="#Thoughts-on-Usage" class="headerlink" title="Thoughts on Usage"></a>Thoughts on Usage</h2><p>Generally defMON runs well with this setup, but there are definitely some drawbacks.</p><p>Overall the sound is good, but not as good as running this on an actual SID chip (that’s to be expected). I’ve noticed the audio hiccuping sometimes when running more complex tracks. This hiccuping could potentially be resolved with further adjustments to the VICE settings, but as it is, it’s not too bad.</p><p>The keyboard has proven to be pretty awkward. defMON’s key commands make a lot of sense on a Commodore 64, but not so much when they are mapped to a modern keyboard layout. This, coupled with how awkward the Pocket CHIP’s keyboard already is, makes certain tasks feel clumsy. Therefore, I can’t recommend using this setup for any kind of live performance, or for any long term in-depth work. However, it is an excellent way to get more familiar with how to use defMON, and is proving especially useful in experimenting with and constructing instruments and effects in the SID tab.</p><p>Stepping back from defMON, VICE runs well on the Pocket CHIP. Most games don’t rely as heavily on the Commodore’s special keys, making the keyboard inconveniences less of an issue. The few games I have tried are responsive with smooth gameplay. This setup has also proven to be a fun way to quickly check out various demo scene creations.</p><video title="Sweet C64 demo scene action." loop="true" muted="true" autoplay="false">  <source src="/2019/07/defmon-vice-chip/c64-demo.mp4" type="video/mp4">  <em>Your browser is having trouble with the video. You can check it out <a href="/2019/07/defmon-vice-chip/c64-demo.mp4">here</a>.</em></video><span style="text-align: right; display: block;">_"In Memory of"_<br>_created by: Hollowman_</span>]]></content>
    
    
    <summary type="html">This post details the process I went through to setup and configure VICE (the VersatIle Commodore Emulator) on the Pocket CHIP to run defMON. While my end goal here is to be able to run defMON from the homepage launcher of the Pocket CHIP, you can follow this setup process (ignoring the defMON stuff) to have a working Commodore emulator. This will allow you to run any number of C64 games, applications, or wild demo packages on the Pocket CHIP.</summary>
    
    
    
    
    <category term="C64" scheme="https://electro.pizza/tags/C64/"/>
    
    <category term="Music" scheme="https://electro.pizza/tags/Music/"/>
    
    <category term="SBC" scheme="https://electro.pizza/tags/SBC/"/>
    
  </entry>
  
  <entry>
    <title>LimeSDR Mini with Gqrx on Arch Linux</title>
    <link href="https://electro.pizza/2019/02/limesdrmini-gqrx-arch/"/>
    <id>https://electro.pizza/2019/02/limesdrmini-gqrx-arch/</id>
    <published>2019-02-22T04:07:49.000Z</published>
    <updated>2024-01-08T03:24:09.980Z</updated>
    
    <content type="html"><![CDATA[<p>The <a href="https://myriadrf.org/projects/component/limesdr-mini/">LimeSDR Mini</a> is a newer product from the MyriadRF line of SDRs.  Its ability to both transmit and receive, decent bandwidth, small form factor, and a reasonable price tag make it a very attractive device for experimentation.</p><img src="/2019/02/limesdrmini-gqrx-arch/limesdrmini.jpg" class="" title="LimeSDR Mini"><p>Likely, one of the first things a radio hobbiest will want to do with this device is hook up an antenna, fire up <a href="http://gqrx.dk/">Gqrx</a>, and tune around. Recently I attempted just this, but had some issues getting things setup on an Arch Linux box. It wound up being a bit of a rabbit hole, so it’s worth a note on how I got this setup up and working.</p><p>As Github user <a href="https://github.com/csete/gqrx/issues/668#issuecomment-450529255">alexf91 writes in a related gitub issue</a>, the source of the problem is that the “stable” release of <code>gnuradio-osmosdr</code> is nearly 5 years old and horribly out of date.  This is the version referenced in the <code>community/gnuradio-osmosdr</code> package, and probably the version most folks will install by default.  Thankfully, as alexf91 points out, you can compile a more recent version of <code>gnuradio-osmosdr</code> and then compile <code>gqrx</code> using this newer library, all via AUR.</p><h2 id="Compile-and-Install-Gqrx-and-Dependencies"><a href="#Compile-and-Install-Gqrx-and-Dependencies" class="headerlink" title="Compile and Install Gqrx and Dependencies"></a>Compile and Install Gqrx and Dependencies</h2><p>The order of installation is important here so that the appropriate libraries are available during compilation of the subsequent packages.</p><p>If you’re using an AUR utility (pacaur, yay, etc) you can of course do this all in one command, however I find it useful to break bigger things up to make any problems more visible.</p><h3 id="1-Install-soapysdr-and-soapylms7-git"><a href="#1-Install-soapysdr-and-soapylms7-git" class="headerlink" title="1. Install soapysdr and soapylms7-git"></a>1. Install soapysdr and soapylms7-git</h3><p><code>soapysdr</code> can be found at <code>community/soapysdr</code> so can be installed via pacmam.</p><figure class="highlight sh"><table><tr><td class="code"><pre><span class="line">pacman -S soapysdr</span><br></pre></td></tr></table></figure><p><a href="https://aur.archlinux.org/packages/soapylms7-git/">soapylms7-git</a> is in AUR.</p><figure class="highlight sh"><table><tr><td class="code"><pre><span class="line">pacaur -S soapylms7-git</span><br></pre></td></tr></table></figure><h3 id="2-Install-gr-osmosdr-git-and-missing-libbladerf-git-dependency"><a href="#2-Install-gr-osmosdr-git-and-missing-libbladerf-git-dependency" class="headerlink" title="2. Install gr-osmosdr-git and missing libbladerf-git dependency"></a>2. Install gr-osmosdr-git and missing libbladerf-git dependency</h3><p>If you already have the “stable” version of <code>gqrx</code> and <code>gnuradio-osmosdr</code> installed, you will first need to uninstall them.</p><p>Before installing <code>gr-osmosdr-git</code> (at the time of this writing) you will need to install the missing dependency <a href="https://aur.archlinux.org/packages/libbladerf-git/">libbladerf-git</a> from AUR. If you previously had <code>gnuradio-osmosdr</code> installed, you may be asked if you wish to replace <code>bladerf</code> with <code>libbladerf-git</code>, which you should do. Now you can install <a href="https://aur.archlinux.org/packages/gr-osmosdr-git/">gr-osmosdr-git</a> from AUR. If you previously had <code>gnuradio-osmosdr</code> installed, you may be asked if you want to replace <code>airspy</code> with <code>airspy-git</code>, and again you should do this.</p><figure class="highlight sh"><table><tr><td class="code"><pre><span class="line">pacaur -S libbladerf-git gr-osmosdr-git</span><br></pre></td></tr></table></figure><p>This will kick off gnuradio-osmosdr compiling and it may take a bit while it does so.</p><h3 id="3-Finally-install-gqrx-git"><a href="#3-Finally-install-gqrx-git" class="headerlink" title="3. Finally install gqrx-git"></a>3. Finally install gqrx-git</h3><p><a href="https://aur.archlinux.org/packages/gqrx-git/">gqrx-git</a> can be found in AUR.</p><figure class="highlight sh"><table><tr><td class="code"><pre><span class="line">pacaur -S gqrx-git</span><br></pre></td></tr></table></figure><p>This gets gqrx to compile, this time with all of our updated dependencies.  Like the gnuradio-osmosdr compilation, it may take a while.</p><h2 id="First-Run-and-Initial-Config"><a href="#First-Run-and-Initial-Config" class="headerlink" title="First Run and Initial Config"></a>First Run and Initial Config</h2><p>If you’ve run gqrx before you may need to remove or archive your old config file</p><figure class="highlight sh"><table><tr><td class="code"><pre><span class="line"><span class="built_in">rm</span> ~/.config/gqrx/default.conf</span><br></pre></td></tr></table></figure><p>or</p><figure class="highlight sh"><table><tr><td class="code"><pre><span class="line"><span class="built_in">mv</span> ~/.config/gqrx/default.conf ~/.config/gqrx/default.conf.old</span><br></pre></td></tr></table></figure><p>At this point you should be able to plug in the LimeSDR Mini and fire up Gqrx.  Be sure its plugged into a USB 3.0 port for an optimal experience, and if you’re using a USB cable be sure it’s compatible with USB 3.0. (I was puzzling over why things were weird with my setup for far too long. It wound up being the cable.)</p><p>On the first run you will be confronted by the “Configure I&#x2F;O devices” dialogue.  In the device dropdown you will notice an entry for “LimeSDR Mini”.  I have had no success in using this option, nor have others on the web as far as I can tell. What does work, however, is telling Gqrx to use Soapy with the lime driver. For that you will need to configure as follows:</p><img style="float: left; width: 50%; padding-right: 20px;" alt=" Gqrx Config" src="/2019/02/limesdrmini-gqrx-arch/initial-config.png" /><ul><li>Set device to “Other…”.</li><li>Device string should be <code>driver=lime,soapy=0</code>.</li><li>Initially it may be good to set the bandwidth to 5.00 MHz just to have better visibility of what’s going on, but you should be able to go up to around 30.00 Mhz.</li><li>Everything else should be good as is.</li></ul><p><em>Note: I have occasionally noticed things being a little buggy with subsequent runs of Gqrx, in which case I delete the config file and run it again.</em></p><div style="clear:both;"></div><p>Now you should be in the main Gqrx screen. Before you kick off the DSP you will need to set which antenna to use on the device. Go into “input controls” and set “Antenna” to <code>LNAW</code>, and you’re good to go!</p><video loop="true" muted="true" autoplay="false">  <source src="/2019/02/limesdrmini-gqrx-arch/gqrx.mp4" type="video/mp4">  <em>Your browser is having trouble with the video. You can check it out <a href="/2019/02/limesdrmini-gqrx-arch/gqrx.mp4">here</a>.</em></video>]]></content>
    
    
    <summary type="html">The LimeSDR Mini is a newer product from the MyriadRF line of SDRs.  Its ability to both transmit and receive, decent bandwidth, small form factor, and a reasonable price tag make it a very attractive device for experimentation. Likely, one of the first things a radio hobbiest will want to do with this device is hook up an antenna, fire up Gqrx, and tune around. Recently I attempted just this, but had some issues getting things setup on an Arch Linux box. It wound up being a bit of a rabbit hole, so it&#39;s worth a note on how I got this setup up and working.</summary>
    
    
    
    
    <category term="radio" scheme="https://electro.pizza/tags/radio/"/>
    
    <category term="linux" scheme="https://electro.pizza/tags/linux/"/>
    
  </entry>
  
  <entry>
    <title>USB Powered Bias-T and ADS-B Enhancements</title>
    <link href="https://electro.pizza/2019/01/biast-adsb/"/>
    <id>https://electro.pizza/2019/01/biast-adsb/</id>
    <published>2019-01-02T00:17:35.000Z</published>
    <updated>2023-11-09T21:45:09.012Z</updated>
    
    <content type="html"><![CDATA[<p>Recently I have turned my attention back to <a href="https://en.wikipedia.org/wiki/Automatic_dependent_surveillance_%E2%80%93_broadcast">ADS-B</a>. I realized it is an excellent source for a dynamic near-realtime dataset for use as sample data in some other side projects. The data itself is interesting and fun to visualize, and it’s relatively easy to stand up a recieveing station that is always on. So I pulled out an SBC (Odroid XU3) and an old generic <a href="https://www.rtl-sdr.com/about-rtl-sdr/">RTL-SDR</a> stick I had lying around, and hooked things up to a simple telescoping dipole antenna mounted in the window. This modest setup was enough to pull flight data from nearby aircraft, and for my purposes was completely satisfactory. However, the more I used this setup and got a sense of its receiving range, I became curious. What are some simple modifications I could make to this little station to increase its range, and by how much? Is it possible to push its range without going (too) crazy with radio gear?</p><p>Well sure!</p><img src="/2019/01/biast-adsb/full-kit.jpg" class="" title="Full Kit"><h2 id="Ground-Plane-Antenna"><a href="#Ground-Plane-Antenna" class="headerlink" title="Ground Plane Antenna"></a>Ground Plane Antenna</h2><p>An antenna upgrade seemed like the best place to start. The little telescoping dipole is great for roughly adjusting to a frequency you may be interested in. However, its always a bit of a guess at getting the length just right, and reception is mediocre overall. Since I’m only interested in one frequency (1090MHz for ADS-B), it makes sense to try and construct a purpose built antenna. I settled on a quarter wave ground plane antenna for the build, as folks report good results with it for ADS-B reception. Further, I had the the stuff needed to build one on hand. There are several other antenna options that could work quite well here and <a href="https://www.rtl-sdr.com/adsb-aircraft-radar-with-rtl-sdr/">rtl-sdr.com has a great rundown of the commonly used ones</a>. It’s also an excellent jumping off point if you want to setup your own ADS-B recieving station.</p><p>A quarter wave ground plane antenna is a type of <a href="https://en.wikipedia.org/wiki/Monopole_antenna#Types">monopole antenna</a> with a single conductor element and several evenly spaced ground plane elements (in my case 4). Each of these elements are cut to 1&#x2F;4 wavelength of your target frequency. For this antenna we’re wanting elements around 65mm to hopefully resonate well with our target 1090Mhz signal. However, when constructing a wire antenna like this, its a good idea to cut the leads slightly long, this way you can trim the length back to an exact measurement once the antenna is constructed.</p><img src="/2019/01/biast-adsb/groundplane-construction.png" class="" title="Groundplane Construction"><p>In this construction I cut the elements from solid 22AWG copper wire and soldered them directly to a <a href="https://www.digikey.com/short/jn0j3r">panel mount SMA jack</a>. They were then trimmed them down to exact lengths.</p><h3 id="A-Note-on-Calculating-Wavelength"><a href="#A-Note-on-Calculating-Wavelength" class="headerlink" title="A Note on Calculating Wavelength"></a>A Note on Calculating Wavelength</h3><p>So where did the 65mm element length come from?</p><p>To know what the wavelength is for a given radio frequency, you divide the speed of light (in meters per second) by that frequency (in Hz). For this project we’re shooting for 1090Mhz, that’s (3.0x10<sup>8</sup>m&#x2F;s)&#x2F;(1090x10<sup>6</sup>Hz). To make things simpler you can reduce this to (300&#x2F;1090). That gives us .275m (275mm) for the full wavelength; since we are after 1&#x2F;4 wavelength we divide by 4. So about 68mm.</p><p><em>Wait, what? Didn’t you say <strong>65</strong>mm?</em></p><p>Well, yeah… it turns out it’s a bit more complicated. I’ll try to summarize to the best of my ability. (tl;dr in the blockquote below)</p><p>Electromagnetic waves travel at a constant velocity in free space (3.0x10<sup>8</sup>m&#x2F;s). However, RF energy on an antenna has a slightly lower velocity.  This is because the <a href="https://en.wikipedia.org/wiki/Relative_permittivity">relative permittivity</a> of the antenna material (sometimes called its dielectric constant) is greater than that of free space (or <a href="https://en.wikipedia.org/wiki/Vacuum_permittivity">vacuum permittivity</a>). Since we have this difference in velocity between RF energy in free space and RF energy on an antenna, the antenna’s physical length is no longer equal to its <a href="https://en.wikipedia.org/wiki/Electrical_length">electrical length</a>. In other words, if you were to cut an antenna element to have an <em>electrical length</em> of exactly 1&#x2F;4 wavelength, the <em>physical length</em> of that antenna would be slightly shorter than 1&#x2F;4 wavelength. How much shorter? Again it’s a bit complicated. A large number of things can affect the relative permittivity of an antenna, but the most notable for an antenna made of thin wire is stray capacitance, often called “end effect.” As a general rule of thumb we can say:</p><blockquote><p>End effect for a typical dipole of wire that is thin compared to its length is counteracted by making the physical length about 5 percent shorter than the electrical length…<br><span style="display: block; text-align: right; font-style: italic;">- Practical Antenna Handbook 5th Edition (105)</span></p></blockquote><p>So taking 5% off the 68mm we calculated above will give us about 65mm. To apply this to our original calculation (and be a bit more precise), we can slow the speed of light by 5% (285&#x2F;target freq in MHz) to give us the physical wavelength on the antenna.</p><p>So to belabor our example of 1090MHz:<br>(285&#x2F;1090) gives us a 261mm wavelength, then dividing by 4 for the quarter wavelength gives us 65mm.</p><p>Of course there are many online “antenna length calculators” that will do the math for you, but where’s the fun in that?</p><h2 id="Low-Noise-Amplifier"><a href="#Low-Noise-Amplifier" class="headerlink" title="Low Noise Amplifier"></a>Low Noise Amplifier</h2><p>Around the time I was working on the antenna, I noticed a nice <a href="https://www.rtl-sdr.com/new-product-rtl-sdr-blog-1090-mhz-ads-b-lna/">filtered LNA package</a> specifically designed for ADS-B reception being offered at <a href="https://www.rtl-sdr.com/">rtl-sdr.com</a>. It offered targeted filtering for 1090Mhz, and amplification for the signal touting a 27dB boost. Reviews looked good and the price was reasonable so I purchsed one. An LNA should be positioned as close to the antenna as possible, and requires 3v - 5v power provided inline. Powering something directly through coax is typically accomplished using what is called a bias-t.</p><h2 id="USB-Powered-Bias-T"><a href="#USB-Powered-Bias-T" class="headerlink" title="USB Powered Bias-T"></a>USB Powered Bias-T</h2><p>A <a href="https://en.wikipedia.org/wiki/Bias_tee">bias-t</a> (or bias tee) is a circuit that injects a biased DC voltage in one direction on an RF line, but blocks that DC voltage in the other direction allowing only signal AC to pass through. Typically you put a bias-t directly on the coax between your radio and whatever you want to power (in our case an amplifier). The bias-t will provide power “up” the line to the amplifier, but no DC voltage will be allowed “down” the line to the radio where DC voltage is not welcome.</p><p>Many newer RTL-SDR dongles marketed to radio hobbyists come with a 5v bias-t power source built in. However, since I’m using an old generic SDR stick (originally only intended for TV reception) I have no such luxury. Of course RTL-SDR sticks are fairly inexpensive, so I considered purchasing a new one with a built in bias-t just for this purpose (and I likely will in the future). However, as I started reading more on how a bias-t works and solutions that others had come up with, I decided it might be a fun diversion to attempt to build my own.</p><p>There are two main components that allow a bias-t to work: a capacitor that allows AC to pass through but blocks DC, and an inductor that allows DC to pass through, but blocks AC. These components can be seen in the top 1&#x2F;4 of the following schematic.  All the remaining components are for DC smoothing, power indication, and the power source.</p><img src="/2019/01/biast-adsb/schematic.png" class="" title="Schematic"><p>Component values are chosen based on a number of factors, most notably the target frequency (or frequency range) and the DC voltage being used. It is at this point that I extend a huge thanks to <a href="https://lna4all.blogspot.com/">LNA4ALL</a>.  There you can find a fantastic <a href="https://lna4all.blogspot.com/2014/11/diy-bias-t.html">writeup for a diy bias-t</a> where he outlines a design for a “good enough” wideband bias-t using common component values.  The above schematic is taken directly from that post, adding only a power indicator and a USB power source. It seemed handy to source the 5v from USB, as the SBC that the radio is on has several USB ports to spare, and the RF line was in close proximity.</p><img src="/2019/01/biast-adsb/powertest.jpg" class="" title="Assembled Bias-T"><p>After plugging in a USB cable and doing some sanity tests, the bias-t was working as expected.  5v DC was observed on the right side, no DC voltages on the left, and after placing this inline with the radio and LNA it seemed to work like a charm.  The LNA was getting power and the radio was receiving an AC signal with the DC voltage scrubbed. Excellent! Now admittedly this bias-t is a bit crude.  It could probably use a shielded enclosure, and the components spaced much closer together. I had some concerns that there would be a lot of noise introduced, and at some frequencies that certainly may be the case. However, at 1090Mhz things seem fine. So for my purposes, this will do nicely.</p><h3 id="What’s-Up-With-That-Circuit-Board"><a href="#What’s-Up-With-That-Circuit-Board" class="headerlink" title="What’s Up With That Circuit Board?"></a>What’s Up With That Circuit Board?</h3><p>Now that the price of having a PCB manufactured for you is very low, the quality high, and the turnaround time reasonable, it’s becoming more difficult to justify making your own PCBs. For this experiment however, I only need the one device, I have all the supplies to etch a board, and I find the process both rewarding and enjoyable. I decided to forego the manufacturer this time and just make the board myself.</p><img src="/2019/01/biast-adsb/lamination.jpg" class="" title="Pre-Transfer"><p>For the curious, I use the toner transfer method and etch with ferric cholride.</p><h2 id="Results"><a href="#Results" class="headerlink" title="Results"></a>Results</h2><p>To get a better sense of how things improved I needed a way to measure the range of reception over time. In this way I could get a rough benchmark for the original setup, and note changes with each addition. I decided to use <a href="https://planefinder.net/sharing/client">PlaneFinder’s client software</a> as it offers some nice statistics, and a visual representation of aircraft signals recieved over a 24hr period.</p><p>In the charts below each ring is a 50 mile radius from a rough geolocation of my recieving station. The area in blue represents where the flights were observed over 24hrs. The position of the antenna was the same for all tests.</p><h3 id="Dipole-Only"><a href="#Dipole-Only" class="headerlink" title="Dipole Only"></a>Dipole Only</h3><img src="/2019/01/biast-adsb/dipole-only-20180919.png" class="" title="Dipole Only"><h3 id="Groundplane-Only"><a href="#Groundplane-Only" class="headerlink" title="Groundplane Only"></a>Groundplane Only</h3><img src="/2019/01/biast-adsb/groundplane-only-20180918.png" class="" title="Groundplane Only"><h3 id="Groundplane-with-Filtered-LNA"><a href="#Groundplane-with-Filtered-LNA" class="headerlink" title="Groundplane with Filtered LNA"></a>Groundplane with Filtered LNA</h3><img src="/2019/01/biast-adsb/groundplane-lna-20181102.png" class="" title="Groundplane and LNA"><p>A significant improvement! The new setup’s range tops out near the outskirts of Houston and the Gulf Coast. These flights near the end of reception range are of course are very high altitue cross country flights. Reguardless, I’m quite pleased. It’s interesting to note that the antenna for this setup is hanging in an East facing window. To the West of the station is our house, a hill, and downtown Austin closely followed by a big elevation change at the Balcones Escarpment. This is well represented in the graphs, as reception to the West is greatly diminished. Placing the antenna outside as high as possible could potentially help improve the range in this direction. A weatherproof enclosure and maybe a PoE setup for the SBC would be good next steps for this little project.</p>]]></content>
    
    
    <summary type="html">Recently I have turned my attention back to ADS-B. I realized it is an excellent source for a dynamic near-realtime dataset for use as sample data in some other side projects. The data itself is interesting and fun to visualize, and it&#39;s relatively easy to stand up a recieveing station that is always on. So I pulled out an SBC (Odroid XU3) and an old generic RTL-SDR stick I had lying around, and hooked things up to a simple telescoping dipole antenna mounted in the window. This modest setup was enough to pull flight data from nearby aircraft, and for my purposes was completely satisfactory. However, the more I used this setup and got a sense of its receiving range, I became curious. What are some simple modifications I could make to this little station to increase its range, and by how much? Is it possible to push its range without going (too) crazy with radio gear?</summary>
    
    
    
    
    <category term="ADS-B" scheme="https://electro.pizza/tags/ADS-B/"/>
    
    <category term="radio" scheme="https://electro.pizza/tags/radio/"/>
    
  </entry>
  
  <entry>
    <title>Geek Spinner Build</title>
    <link href="https://electro.pizza/2018/02/geek-spinner/"/>
    <id>https://electro.pizza/2018/02/geek-spinner/</id>
    <published>2018-02-13T02:26:26.000Z</published>
    <updated>2023-11-09T21:45:09.012Z</updated>
    
    <content type="html"><![CDATA[<p>My nephews are fascinated with fidgit spinners.  They each own several and always have one on hand, proudly showing off the various tricks they have mastered. So when I stumbled across a persistence of vision (pov) fidget spinner <a href="http://www.instructables.com/id/Geek-Spinner/">project on instructables</a>, I knew that I had my nephews’ 2017 Christmas gifts in the bag.</p><img src="/2018/02/geek-spinner/electro-spinner.gif" class="" title="Frame rates, amiright?"><p>Ken over at <a href="http://www.makersbox.us/">The Maker’s Box</a> did a fantastic job with <a href="http://www.instructables.com/id/Geek-Spinner/">documentation</a>, even offering a <a href="https://www.tindie.com/products/MakersBox/programmable-pov-fidget-spinner/">tindie kit</a> to take the pain out of sourcing components. I took a few pictures while assembling the project, as well as discovering a few tips and alternatives for the build, so I figure it was worth a build log.</p><h2 id="Build-Tips"><a href="#Build-Tips" class="headerlink" title="Build Tips"></a>Build Tips</h2><h3 id="Solder-the-Bearing-Before-the-Components"><a href="#Solder-the-Bearing-Before-the-Components" class="headerlink" title="Solder the Bearing Before the Components"></a>Solder the Bearing Before the Components</h3><p>Perhaps the trickiest part of this build is soldering the bearing onto the board. The board needs to be centered vertically on the bearing, so you’ll need some kind of spacer to hold the board up while you solder. The build instructions suggest using a couple of coins for this task.  This works well enough, however it is also suggested that the bearing is the last thing to solder to the board. I followed this method when building the first spinner, and I found it difficult to balance the coins beneath the board.  The components kept getting in the way, so for the last two boards I decided to place the bearing first. This made things much easier.</p><img src="/2018/02/geek-spinner/bearing-solder.png" class="" title="Much easier with no componenets."><p>I soldered two locations on the top and two rotated 90 degrees on the bottom of the board. There is so much thermal conductivity in the metal of the bearing that you will need to crank up the temperature of your soldering iron to make this job easier.</p><img src="/2018/02/geek-spinner/bearing-inplace.png" class="" title="Got em in there."><h3 id="Alternative-Parts"><a href="#Alternative-Parts" class="headerlink" title="Alternative Parts"></a>Alternative Parts</h3><h4 id="Texas-Instruments-DRV5023"><a href="#Texas-Instruments-DRV5023" class="headerlink" title="Texas Instruments DRV5023"></a>Texas Instruments DRV5023</h4><p>When ordering components for the board, the specified hall effect sensor (the <a href="https://www.digikey.com/product-detail/en/melexis-technologies-nv/MLX92231LUA-AAA-020-SP/MLX92231LUA-AAA-020-SP-ND/">Melexis MLX92231</a>) was out of stock.  After some looking around and comparing datasheets I decided to give the <a href="https://www.digikey.com/product-detail/en/texas-instruments/DRV5023AJQLPGM/296-41080-1-ND">Texas Instruments DRV5023</a> a try.  It wound up working fine, and is suitable as a drop-in replacement. Remeber to test the orientation of your magnet!</p><h4 id="Bearing-Caps-from-Amazon"><a href="#Bearing-Caps-from-Amazon" class="headerlink" title="Bearing Caps from Amazon"></a>Bearing Caps from Amazon</h4><p>The initial build specifies 3D printed bearing caps. At present I don’t have a 3D printer at my disposal, so I had to look for alternatives.  I took a chance on some <a href="http://a.co/d8O1pVm">simple bearing caps</a> I came across on Amazon.  They wound up working fairly well, however they are quite thin, making it difficult to glue in a magnet.  After some thought, I decided to drill out a hole (slightly smaller than the diameter of the magnet) in the bearing cap and press fit the magnet into the cap.  Overall I’m pleased with the solution.</p><h3 id="Misc-Notes"><a href="#Misc-Notes" class="headerlink" title="Misc Notes"></a>Misc Notes</h3><p>The minimum order from Osh Park is three boards, however I only needed two spinners as gifts. This gave me the opportunity to build a third spinner as an initial testing&#x2F;prototyping device. On the extra board I socketed the chip so that I could easily swap the ATTiny in and out.  This allows me to use a programmer shield I built a while back, and then reseat the chip into the socketed spinner to see how things looked.  It wound up being very helpful in making sure everything in the program looked just right, and in the end I was really glad I built the third spinner.</p><img src="/2018/02/geek-spinner/programmer.gif" class="" title="Free range, artisnal Atmel programming shield."><p>In this shot you can see the press fit magnet in the bearing inserts from Amazon.</p><p>Aside from the bearings and magnet placement, this is a very straight forward build. It would be a great project for anyone new to soldering and wanting more practice. Overall the whole build took me about an hour at a very casual pace.</p><div class="video-container"><iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/Sg0XIFQuFHA?rel=0&amp;showinfo=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe></div>]]></content>
    
    
      
      
    <summary type="html">&lt;p&gt;My nephews are fascinated with fidgit spinners.  They each own several and always have one on hand, proudly showing off the various trick</summary>
      
    
    
    
    
    <category term="arduino" scheme="https://electro.pizza/tags/arduino/"/>
    
    <category term="pov" scheme="https://electro.pizza/tags/pov/"/>
    
    <category term="build log" scheme="https://electro.pizza/tags/build-log/"/>
    
  </entry>
  
  <entry>
    <title>Serial Punch</title>
    <link href="https://electro.pizza/2017/11/punch-python-serial/"/>
    <id>https://electro.pizza/2017/11/punch-python-serial/</id>
    <published>2017-11-12T01:07:02.000Z</published>
    <updated>2023-11-09T21:45:09.032Z</updated>
    
    <content type="html"><![CDATA[<p>In my daily work I use a CLI tool called <a href="http://todotxt.org/">todo.txt</a> coupled with an add-on called <a href="https://github.com/adewinter/punch">punch</a> to track the time spent on chunks of work. Tasks are added and organized by todo.txt, and punch is used to punch in and out of those tasks. Additionally, punch has a few useful reporting and archiving functions.  In combination, todo.txt and punch make for a simple and useful tool that has served me well for several years.</p><p>Useful, but not perfect. A big drawback of punch is that there is no obvious indicator of the timer’s state. To see if the timer is active and the elapsed time, you must issue a cli command. Because of this, I often find myself forgetting to punch in to a new task or out at the end of the day. This obviously leads to some inaccuracies and frustrations in my time keeping. I’ve seen a few solutions to this. The simplest solution would likely be some sort of widget to display the running timer somewhere on your windows manager. However, while messing around with some old <a href="/2017/09/panaplex-testing/" title="Panaplex Display Testing">panaplex displays</a>, I began thinking of using them in a small desktop clock build.  This clock could potentially have a serial input which would allow it to display information from the punch timer. So I’ve found myself thinking about what would it take to implement something like this.</p><h2 id="CP2104"><a href="#CP2104" class="headerlink" title="CP2104"></a>CP2104</h2><img src="/2017/11/punch-python-serial/CP2104.png" class="" title="CP2104"><p>Last year I was interested in finding a solution for simple USB to serial communications. Through that research I stumbled upon the <a href="https://www.silabs.com/products/interface/usb-bridges">CP21x devices</a> from Silicon Labs. Eventually I settled on the <a href="https://www.silabs.com/documents/public/data-sheets/cp2104.pdf">CP2104 USB to UART bridge</a> and ordered a development board. These chips save a lot of work establishing onboard USB.  They appear to an OS as a typical USB device, auto negotiate baud, and simply pass along serial communications to and from the USB port.  There are some advanced configurations available to you if you wish, but by in large the CP2104 is a plug and play chip.</p><p>At the time I wrote a <a href="https://github.com/rh0/cp2104_lcd_test">test in Python</a> to echo keypresses from my computer to the device. It turns out the chip is as easy to use as promised, and is a perfect solution to interface my computer with a microcontroller in a potential desktop clock.</p><p><video src="/2017/11/punch-python-serial/cp2104-test.mp4" type="video/mp4" autoplay loop muted></video></p><h2 id="Python-PoC"><a href="#Python-PoC" class="headerlink" title="Python PoC"></a>Python PoC</h2><p>I thought it would be worthwhile to write a short proof of concept to output data from punch to serial USB. To display this data I used a SparkFun serLCD I had laying around. This wound up being a relatively simple task. I don’t think its useful walking through all of the code, but for the sake of my memory I want to point out a couple things that I learned along the way. If you’re curious you can check out the <a href="https://github.com/rh0/pySerialPunch">complete script on my github</a>.  Please forgive my clumbsy Python. The code can be cleaned up and there is certainly a more elegant solution.</p><p><video src="/2017/11/punch-python-serial/punch-serial-demo.mp4" type="video/mp4" autoplay loop muted></video></p><h3 id="Watchdog"><a href="#Watchdog" class="headerlink" title="Watchdog"></a>Watchdog</h3><p>Punch writes tasks and timestamps to a file, called <code>punch.dat</code> to catalogue time spent on tasks.  In order for my program to be aware of active tasks and elapsed time, it needs to watch this file for changes.  The <a href="https://pythonhosted.org/watchdog/">Watchdog</a> library handled this task nicely.</p><p>Watchdog establishes an API to monitor file system CRUD events. After digging in a bit, I found it to be friendly and effective, and can be summarized in a few lines of code:</p><figure class="highlight python"><table><tr><td class="code"><pre><span class="line">eventHandler = PunchDatEvent()</span><br><span class="line">observer = Observer()</span><br><span class="line">observer.schedule(eventHandler, <span class="string">&#x27;/path/to/watch&#x27;</span>)</span><br><span class="line">observer.start()</span><br><span class="line"></span><br><span class="line"><span class="comment"># When you&#x27;re done watching.</span></span><br><span class="line">observer.stop()</span><br></pre></td></tr></table></figure><p>Observer is a thread class to which you can schedule monitoring of a given path, and assign it an event handler to act on filesystem CRUD events observed in the given directory. Starting and stopping this thread is as easy as firing the respective methods. Most of the heavy lifting is handled by the event handler you extend from the included <code>FileSystemEventHandler</code> class (<code>PunchDatEvent</code> in the above snippet). Watchdog handles everything else. Quite nice.</p><h3 id="Threading"><a href="#Threading" class="headerlink" title="Threading"></a>Threading</h3><p>A thread has been established for the Watchdog observer to handle filesystem monitoring, but what about the serial communications?  While I could likely handle this in the main program loop, I thought it could be a good opportunity to spin off another thread just for this purpose.  Painful memories linger of C&#x2F;C++ multithreading from days gone by, but I have no experience with it in Python. The task here seemed simple enough to dip a toe in and give it a try.</p><p>After spending some time with the core <a href="https://docs.python.org/3/library/threading.html">threading</a> library documentation I was surprised to see just how simple this could be (granted this is a very basic application). To sum up in a couple of lines:</p><figure class="highlight python"><table><tr><td class="code"><pre><span class="line">tickTockThread = Thread(target=eventHandler.tickTock)</span><br><span class="line">tickTockThread.start()</span><br></pre></td></tr></table></figure><p>Instantiate a thread object and give it a target object to run.  In this case the target is a method I’ve defined within the same event handler used with the observer thread. Then simply start it.  It will run until the target method terminates, at which time the thread is destroyed.</p><p>Reading through the docs, I can see how this can get more complex in a hurry. However, I was pleasantly surprised with how simple this was for my small task.</p><h2 id="Fine-for-now…"><a href="#Fine-for-now…" class="headerlink" title="Fine, for now…"></a>Fine, for now…</h2><p>I now have a decent mechanism for sending my time tracker data via serial over USB to an eventual desk clock.  There are a few critical things to add to the code as I move forward with the project, such as:</p><ul><li>Daemonize the script for Systemd.</li><li>Establish some methods of detecting the presence of the USB device.</li><li>Rework the serial packets sent to fit whatever protocol is eventually used for the clock, rather than the one built into serLCD.</li></ul><p>However, for now, this is fine.</p>]]></content>
    
    
      
      
    <summary type="html">&lt;p&gt;In my daily work I use a CLI tool called &lt;a href=&quot;http://todotxt.org/&quot;&gt;todo.txt&lt;/a&gt; coupled with an add-on called &lt;a href=&quot;https://github</summary>
      
    
    
    
    
    <category term="todo.txt" scheme="https://electro.pizza/tags/todo-txt/"/>
    
    <category term="python" scheme="https://electro.pizza/tags/python/"/>
    
  </entry>
  
  <entry>
    <title>Panaplex Display Testing</title>
    <link href="https://electro.pizza/2017/09/panaplex-testing/"/>
    <id>https://electro.pizza/2017/09/panaplex-testing/</id>
    <published>2017-09-28T03:17:41.000Z</published>
    <updated>2023-11-09T21:45:09.022Z</updated>
    
    <content type="html"><![CDATA[<p>In the Spring of 2017 I attended the <a href="http://hamvention.org/">Dayton Hamvention</a>. While browsing through piles of random electronics at the flea market, I stumbled upon a few interesting vintage displays. Among these were pairs of 3-digit, 7-segment panaplex displays. While I recognized the unique metallic segments in these displays from their use in old gas pumps and pinball machines, I knew very little about them. That being said, what better way to understand a panaplex than to attempt to drive it? I purchased a pair.</p><img src="/2017/09/panaplex-testing/pan-lit.png" class="" title="Panaplex Display"><h2 id="What-is-a-Panaplex"><a href="#What-is-a-Panaplex" class="headerlink" title="What is a Panaplex?"></a>What is a Panaplex?</h2><p>Knowing nothing about the requirements of this display, a bit of research was in order. Panaplex is a type of gas-plasma display; they work much like the coveted <a href="https://en.wikipedia.org/wiki/Nixie_tube">nixie tubes</a>. A small chamber is filled with low pressure neon gas. Within the gas filled chamber there is a single common anode, and multiple wire cathodes making up the segments of a digit.  When sufficient power is supplied to the cathodes, they will light up with an orange plasma glow. Panaplex saw widespread use from the 1970’s through the 1990’s, but fell in popularity when low power super-effecient LED displays became ubiquitous.</p><img src="/2017/09/panaplex-testing/pan-split.png" class="" title="Panaplex Closeup"><p>The particular displays I picked up (pictured above) have “Beckman SP-353” etched in the glass on the bottom left corner. As luck would have it, the internet yeilded a <a href="/2017/09/panaplex-testing/beckman-sperry.pdf">datasheet</a> for the very same model. I found it listed in the <a href="http://www.tube-tester.com/sites/nixie/dat_arch.htm">tube-tester.com archive</a>.</p><img src="/2017/09/panaplex-testing/sp-353_detail.png" class="" title="SP-353 Detail"><p>The datasheet revealed what it would take to get this thing glowing. A supply voltage of 160Vdc (minimum) drawing about 330μA would do the trick.</p><p>Wait, 160 Volts minimum?!</p><p>My bench top power supply can only produce 30 Volts. How are we going to power these things?</p><h2 id="Boost-Converter"><a href="#Boost-Converter" class="headerlink" title="Boost Converter"></a>Boost Converter</h2><p>The first solution that jumped to mind was a switched-mode power supply (SMPS), specifically a <a href="https://en.wikipedia.org/wiki/Boost_converter">boost converter</a>. A boost converter will step up a given DC input voltage to a higher output voltage at the cost of stepping down the input current. They are small, cheap, and effecient. Its a great fit for this situation.</p><p>Typically you can find a cheap “good enough” boost converter to fit your needs on ebay, Banggood, or even Amazon. However, after some thorough searching I could not find anything reasonable for voltages as high as this. Attempting to design and build my own SMPS was a possibility.  Their basic function is remarkably simple, but I knew this could quickly lead down a rabbit hole of tuning, testing, and iterating over prototypes. What I needed was an existing solution just to verify these displays were in working order.</p><h3 id="The-de-Smith-SMPS"><a href="#The-de-Smith-SMPS" class="headerlink" title="The de Smith SMPS"></a>The de Smith SMPS</h3><p>After some thought, it dawned on me that nixie tubes have very similar power requirements.  Maybe a solution lurked there. Broadening the search a bit, I started looking through nixie hobbiest communities to see what their solutions were. The “de Smith Power Supply” was frequently mentioned, and after finally landing on <a href="http://www.desmith.net/NMdS/Electronics/NixiePSU.html">Nick de Smith’s page</a> detailing his solution, I was convinced. The de Smith SMPS takes a 12V - 15V input and boosts to a 150V - 220V output.  He gives a detailed explanation of how his SMPS works, the thoughts behind his design and component choices (including a BoM, complete with digikey callouts), and even catalogues some performance testing results.  On top of all this, he was generous enough to include the Eagle cad files for the board. With this information, all that was left to do was place an order with <a href="https://oshpark.com/">OSH Park</a> &amp; <a href="https://www.digikey.com/">Digi-Key</a> and wait.</p><img src="/2017/09/panaplex-testing/pan-desmith.png" class="" title="Not the best solder job, but it" alt="ll work."><p>Everything arrived, and I eagerly populated the components. Now let’s see if this thing works!  I connected my bench power supply to Vcc and GND on the SMPS per de Smith’s instructions.  The bench power supply was set to 14Vdc, and I happily observed around 160Vdc output from the SMPS. There is a small potentiometer on the board that allows you to make adjustments to the <a href="https://www.digikey.com/product-detail/en/maxim-integrated/MAX1771ESA-/MAX1771ESA--ND/947783">MAX1771</a> switching controller chip, thereby controlling the output voltage. Excellent.</p><img src="/2017/09/panaplex-testing/pan-boost_volt.gif" class="" title="Voltage adjustment"><p>After some fiddling, I dialed the power supply in to around 165V and turned my attention back to the panaplex display.</p><h2 id="Does-it-work"><a href="#Does-it-work" class="headerlink" title="Does it work?"></a>Does it work?</h2><p>Everything up to this point was done just to see if these displays were in working condition.  They seemed to be in good shape and the vendor at the hamvention asssured me they were in working order. However, I had no way to verify these claims in a muddy field in Ohio, nor when I arrived home with a measly 30V bench top supply. So, with boost converter in hand, it was finally time to see if I had a working display.</p><img src="/2017/09/panaplex-testing/pan-pin_sweep.gif" class="" title="HUZZA!"><p>Success!</p><p>I used some small jumper wires to connect the 165V output on the de Smith SMPS to the anode of one of the digits, and all of the cathodes to a pin header on a breadboard.  This allowed me to sweep another jumper, connected to ground, across the header pins to test individual segments. I repeated this for each digit of the display on the two displays I had.  Everything worked as expected, and I found myself basking in the warm plasma glow of nearly 50 year old technology.</p><h2 id="What’s-next"><a href="#What’s-next" class="headerlink" title="What’s next?"></a>What’s next?</h2><p>Now that we know everything is working, the next step is to design and build a board to make these displays more friendly to modern extra low voltage digital controllers (Arduino, Raspberry Pi, Odroid, etc).  I’ve begun narrowing down my transistor selection, and sketched some preliminary scematics in <a href="http://kicad-pcb.org/">KiCad</a>. However, that will all have to be fodder for a future post.</p>]]></content>
    
    
      
      
    <summary type="html">&lt;p&gt;In the Spring of 2017 I attended the &lt;a href=&quot;http://hamvention.org/&quot;&gt;Dayton Hamvention&lt;/a&gt;. While browsing through piles of random elect</summary>
      
    
    
    
    
    <category term="panaplex" scheme="https://electro.pizza/tags/panaplex/"/>
    
    <category term="boost converter" scheme="https://electro.pizza/tags/boost-converter/"/>
    
  </entry>
  
  <entry>
    <title>Beaker Browser and The DAT Protocol</title>
    <link href="https://electro.pizza/2017/09/beaker-dat/"/>
    <id>https://electro.pizza/2017/09/beaker-dat/</id>
    <published>2017-09-17T23:00:00.000Z</published>
    <updated>2023-11-09T21:45:09.008Z</updated>
    
    <content type="html"><![CDATA[<h2 id="The-Dat-Protocol"><a href="#The-Dat-Protocol" class="headerlink" title="The Dat Protocol"></a>The Dat Protocol</h2><p><a href="https://datproject.org/">Dat</a> was developed with the idea of making sharing large files or folders securely an easy task.  Without the need to rely on a central “cloud” service (like dropbox) or through semi-cumbersome means like rsync or scp, Dat can make it easy to store, share, and track large volumes of data.  This is accomplished through a peer-to-peer (p2p) network (much like BitTorrent). This brings along several of the benefits of a p2p architecture.  There is no central host where availability (or security&#x2F;privacy leanings) would be a concern, you can share across a local network (LAN), and bandwidth scales with the growth of demand as downloads will be distributed across the peers.</p><p>Scientists and researchers were the initial target audience for Dat, allowing them to easily archive and share data. I first caught wind of Dat in Februrary of 2017 when it came to light that the data stored at <a href="open.whitehouse.gov">open.whitehouse.gov</a> was being inexplicably deleted.  Data from open.whitehouse.gov was scraped and stored in a Dat archive so that the information would not be lost. You can see this and a few other endeavors cataloged on <a href="https://datproject.org/explore">the Dat website</a>.</p><p>You can read more about Dat, and forgo further clumsy explanation from me, in their <a href="https://docs.datproject.org/">documentation</a>.</p><h2 id="Beaker-Browser"><a href="#Beaker-Browser" class="headerlink" title="Beaker Browser"></a>Beaker Browser</h2><p>So Dat is a protocol to serve files. Viewing a website is nothing more than files served to a browser that then renders them. So what if we pipe files recieved via the Dat protocol to a browser for rendering? Well you got a peer-to-peer web goin’!</p><p>Clearly it’s a bit more complex than that, but that is the gist of what <a href="https://beakerbrowser.com/">Beaker Browser</a> does. Beaker is a project developed by <a href="https://twitter.com/taravancil">Tara Vancil</a> and <a href="https://twitter.com/pfrazee">Paul Frazee</a>, and is a self described peer-to-peer web browser.  Its still under very active development, but after some semi-regular use I’ve found it both useable and exciting.</p><p>Recently Tara and Paul did a talk for the local group <a href="https://edgeatx.github.io/">Bleeding Edge Web</a> here in Austin. The talk is enlightening; it gives a window into their vision of the project. If you have some free time, its worth a watch.</p><div class="video-container"><iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/9tk9m_QIi2Q?rel=0&amp;start=2810" frameborder="0" allowfullscreen></iframe></div><p>Paul also has a brief video introduction to Beaker:</p><div class="video-container"><iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/U2B9mwRFE8U?rel=0" frameborder="0" allowfullscreen></iframe></div><p>The peer-to-peer web is, arguably, still in its infancy.  However, seeing and using a working model is exciting, with potentially far-reaching ramifications. Since many of the current “gatekeepers” to the web are taken out of the equation in a peer-to-peer model, I think there is a potential to reclaim a lot of the magic and excitement present in the early internet. In this spirit, I’ve made this site available to Beaker via Dat at <a href="dat://electro.pizza">dat:&#x2F;&#x2F;electro.pizza</a> or<br><a href="dat://485d1f5c6cc1970ee29318f3be66c6c9bd0fb5894e757fdc926785ae6a725346">dat:&#x2F;&#x2F;485d1f5c6cc1970ee29318f3be66c6c9bd0fb5894e757fdc926785ae6a725346</a> if you like hashes.</p><p>While setting this simple site up a few things stood out to me and I’d like to note them here. For the sake of time (and the length of this post), I’m not going to touch on all of the features with both Dat and Beaker. Rather, I will try to limit the focus to what I encountered while setting up and publishing this simple site.  Many of these features are quite interesting and exciting in their own right, and if you are interested I encourage you to check them out on the relavent project pages.  Most notable of these to me are:</p><ul><li>Built in versioning on the history of changes in a DAT site.</li><li>Forking of Dat sites (along with new potential workflows when working with a team).</li><li>New Web API’s in Beaker to build peer-to-peer applications.</li></ul><p>But for now, some Beaker basics:</p><h3 id="Site-Generation"><a href="#Site-Generation" class="headerlink" title="Site Generation"></a>Site Generation</h3><p>Initial creation of a site&#x2F;hash is extremely simple; the dialogues in the browser walk you through things. Beaker handles setting up the <code>.dat</code> folder and keys behind the scenes so you don’t have to futz with it.  If you don’t want to keep the site code in the default location (<code>/home/&lt;user&gt;/Sites</code> in Linux), you need to take the extra step of changing the directory to point at the public files of your site.</p><p>Here is an example of the process:</p><img src="/2017/09/beaker-dat/new_site-hash.gif" class="" title="Creating a New Site&#x2F;Hash"><h3 id="Live-Reload"><a href="#Live-Reload" class="headerlink" title="Live Reload"></a>Live Reload</h3><p>Live reloading should be nothing new to most web developers, however its nice to have this ready to go “out of the box”.  It behaves like you would expect, watching site files for changes and refreshing.  This makes pairing with something like a static site generator in a watch mode quite nice.</p><img src="/2017/09/beaker-dat/live-reload.gif" class="" title="Live Reloading"><h3 id="Publishing"><a href="#Publishing" class="headerlink" title="Publishing"></a>Publishing</h3><p>This was glossed over in the site generation example above, but the publishing mechanism may be the most exciting (in the context of workflow) with Beaker.  As you would expect, when you make changes to site files locally they are reflected locally in Beaker. Traditionally, when you are ready to publish these changes to the web, you would perform a push of the code through various mechanisms, ie. pushing to a CI system or manually scp&#x2F;rsync&#x2F;sftp files to a centralized server somewhere.  However, with Beaker all you need do is click the big green publish button, and the file changes are then propigated through to all peers. No server concerns at all. Refreshing!</p><img src="/2017/09/beaker-dat/publishing.gif" class="" title="Publishing"><p>In this example Beaker is on the left and Firefox on the right. Changes published from Beaker are reflected via a remote peer serving over HTTPS to Firefox.</p><h2 id="dathttpd"><a href="#dathttpd" class="headerlink" title="dathttpd"></a>dathttpd</h2><p>Now wait a minute. Firefox? HTTPS? A *gasp* SERVER!?  Weren’t we talking about a peer-to-peer web? Well we are, but we don’t have a widely adopted peer-to-peer web yet!  So, we need a stop-gap to solve a couple of issues:</p><p>First, electro.pizza isn’t wildly popular. Often my local Beaker Browser installation will be the only peer, thus the only source for anyone to view the site. Therefore, for this site to have constant “uptime”, I would need my Beaker installation to always be running with a network connection.  Not ideal.</p><p>Second, the vast majority of people surfing the web are using more traditional browsers (Firefox, Chrome, Edge, etc.), and I would like those folks to be able to view my site through the (currently) standard HTTPS web protocol.</p><p><a href="https://github.com/Beakerbrowser/dathttpd">Dathttpd</a> solves this problem by acting as both a peer for a Dat site, as well as a small web server.  This allows you to keep a Dat site up without having to leave Beaker running.  Further, you get the added bonus of being able to point DNS at that server which allows for shortnames for your site.  Configuration is simple and detailed on the projects github page.</p><h3 id="Hangups"><a href="#Hangups" class="headerlink" title="Hangups"></a>Hangups</h3><p>I was caught up in a couple of small snags while setting up dathttpd. Nothing crazy, but its probably worth a note.</p><h4 id="Node-Installation-on-the-Server"><a href="#Node-Installation-on-the-Server" class="headerlink" title="Node Installation on the Server"></a>Node Installation on the Server</h4><p>Once the dathttpd config is set up and things seem to be working as expected, it is suggested to use <a href="https://github.com/mafintosh/add-to-systemd">add-to-systemd</a> to daemonize the process.  This works quite well, however I’ve found add-to-systemd works best if nodejs is installed on a system level (rather than something like NVM). Use your distro’s package manager to install nodejs greater than version 6.0.  On distros like Ubuntu, you’ll likely have to add a PPA for the newer nodejs version.</p><h4 id="Firewalls"><a href="#Firewalls" class="headerlink" title="Firewalls"></a>Firewalls</h4><p>After having dathttpd running for a few days then returning to Beaker to make site updates, I found that dathttpd and Beaker had trouble reconnecting with each other to propigate updates. I watched traffic for a bit, and it seemed to be a firewall issue with the server. Turns out the machine that is running dathttpd needs to have port 3282&#x2F;tcp open.  After making this adjustment everything worked as expected. I have a bit of a nagging concern that any machine running Beaker also needs port 3282 opened.  So far this does not seem to be the case, but I’m not completely convinced.</p>]]></content>
    
    
      
      
    <summary type="html">&lt;h2 id=&quot;The-Dat-Protocol&quot;&gt;&lt;a href=&quot;#The-Dat-Protocol&quot; class=&quot;headerlink&quot; title=&quot;The Dat Protocol&quot;&gt;&lt;/a&gt;The Dat Protocol&lt;/h2&gt;&lt;p&gt;&lt;a href=&quot;https</summary>
      
    
    
    
    
    <category term="Beaker" scheme="https://electro.pizza/tags/Beaker/"/>
    
    <category term="p2p" scheme="https://electro.pizza/tags/p2p/"/>
    
  </entry>
  
</feed>
