Installing Golang (go) on the Raspberry Pi 3

As of Golang 1.6 they are distributing ARM v6 versions of the compiled binary. So now it’s simple:


tar -C /usr/local -xzf go1.7.linux-armv6l.tar.gz
export PATH=$PATH:/usr/local/go/bin

export GOPATH=$HOME/go

Posted in computing, linux, robot | Tagged , , , | Leave a comment

How to setup a Ruby on Rails environment in Windows

I’ve recently had to setup a couple of RoR dev environments/toolchains in Windows. I suggest not doing this wholly inside windows, but you can still orchestrate the whole process from inside windows. Obviously OSX is a much more clean way to do rails development, but here we are. Most everyone who is anyone develops RoR using OSX, and most everyone else uses Linux. Ruby technically supports Windows, but it’s really not reccomended you go down that route. It’s easier to just setup your dev machine as  Linux VM and call it a day.

This tutorial was built with Ruby v 2.2.3 and Rails v 4.2.4 in November 2015 on Lubuntu 15.10.

I’m going to assume you can walk yourself through downloading and setup of the Virtualbox, Atom, Putty installers and at least a basic competence. Getting these packages to talk to eachother is where the real challenge fun begins, and integrating your Linux toolchain back to your Windows box (you clicked on this google search result because you’re a Windows user, right?)

We will be doing this as a high level overview

A) Setup Linux Box VM
B) Setup Putty/Atom/rmate in Windows
C) Setup Ruby on Rails in Linux
D) Setup Remote Desktop Server in Linux

So, you will need

  1. A way to virtualize an ubuntu box. This can be something fancy like a home VM lab, but more often you will see people running VirtualBox. I’ll leave this part up to you. Virtualbox is very convenient. I used a Hyper-V VM but as long as you can ping it’s hostname you are good to go.
  2. Linux ISO. I reccomend lubuntu (low-end Ubuntu) but you can roll with whatever you want. In this case I am using Lubuntu 15.10 desktop. Generally I like server ISOs but rails likes serving to localhost so it is convenient to be on the desktop of the localhost with a GUI editor like Atom and a browser like Firefox (preferably Chrome), so pick a desktop “distro”. Ubuntu is built on top of Debian and between Debian and Ubuntu there’s enough documentaiton on the web now that you can work through any problem by simply pasting your error message in to google.
  3. A command line tool for Windows. Putty works great.
  4. A text editor. I like Notepad++ but Atom is the new gun in town and has support for things like the package remote-atom so you can edit files on your local PC.

A) Setup Linux box VM

Install Virtualbox. Create a new VM, under “network adapter” set the adapter type to “allow bridge”. Give the VM LOTS of RAM and max out the number of CPUs you can give it (typically 2-4). More memory & more cpu = faster install, better GUI response, etc. Start VM, install Lubuntu from ISO. ( )

B) Setup Putty/Atom in Windows, rmate in Linux

On your new Lubuntu VM, install SSH server from the GUI (start->System Tools->LX Terminal)

sudo apt-get install screen # this is super helpful in keeping your session alive
sudo apt-get install openssh-server vino -y
curl -o /usr/local/bin/rmate
sudo chmod +x /usr/local/bin/rmate
mv /usr/local/bin/rmate /usr/local/bin/ratom
Install Putty on Windows ( )

From here: ( )
Launch putty, insert hostname, then from the Left Nav choose “SSH”, “Tunnels”, Add new forwarded port:
Source Port: 52698
Destination: localhost:52698
Choose radio buttons: Auto, Remote
Save your putty session (suggested)
Connect, login with your Linux user/password

Install Atom on Windows ( )

Install Atom package “remote-atom”
Go to Packages->Remote Atom->Start Server

In Putty type rmate test.txt
If everything has been setup correctly, your should be able to see the opening file in Atom on your Windows desktop.

C) Install Ruby

On linux box from Putty:

From here: ( )

sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev
git clone git:// .rbenv
echo ‘export PATH=”$HOME/.rbenv/bin:$PATH”‘ >> ~/.bash_profile
echo ‘eval “$(rbenv init -)”‘ >> ~/.bash_profile
git clone git:// ~/.rbenv/plugins/ruby-build
echo ‘export PATH=”$HOME/.rbenv/plugins/ruby-build/bin:$PATH”‘ >> ~/.bash_profile
source ~/.bash_profile
cp .bash_profile .bashrc

rbenv install -v 2.2.3
rbenv global 2.2.1
ruby -v
echo “gem: –no-document” > ~/.gemrc
gem install bundler
gem install rails
rbenv rehash
rails -v
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

Ruby on Rails is installed! Let’s build a test app and see if it works

cd ~
rails new testapp
rake db:create
ip addr show eth0 | grep inet | awk ‘{ print $2; }’ | sed ‘s/\/.*$//’
rails server –binding=server_public_IP

Browse to: http://server_public_IP:3000

NOTE: to end your webserver type ctrl+c

D) Setup remote desktop (so you can use your VM from your windows box easily)

From here: ( )

sudo apt-get install xrdp
sudo nano /etc/xrdp/ # just confirm the last line says this: . /etc/X11/Xsession
. /etc/X11/Xsession
sudo nano ~/.xsession # type in this: lxsession -e LXDE -s Lubuntu
lxsession -e LXDE -s Lubuntu
sudo service xrdp restart # will make it pick up changes
Connect to your host using RDP (remote desktop) and login using your linux username and password


Posted in computing, linux | Tagged , , , , , , | 1 Comment

More microcontrollers, ESP8266, Raspberry Pi A+

ESP8266 size comparisonI have been working on electronics a bit more, I thought I would write up what I have been working on.

Most recently I have been working with NodeMCU on the ESP8266. The goal is to have a “captive wlan” with a message board. The ESP8266 is a neat little 80mhz microcontroller that costs about $4 and uses about 60ma of power @ 2.5-3.5v and perhaps most importantly, has a fairly strong 2.4ghz wifi antenna attached. It also has about 3.4MB of avalible flash memory, although that’s over shadowed by the meager ~64KB of RAM. It can run as an AP (wifi access point) or a client, or both at the same time, doing one of many things, such as a wifi bridge, or create a chain of wifi bridges.

NodeMCU is interesting in that it runs a version of Lua, so I have been learning that. This is psuedo-embedded programming so things like “web server” have big chunks of http protocol hard-coded in to the program itself, hard-coded exceptions, etc etc. There are no ini, xml, config files since everything in this tiny world of 96KB-RAM is purpose built – there are no multi-taskers here – variables take up too much space. I definitely see why someone ported the ESP8266 over to the Arduino environment.

So the plan is to attach the ESP8266 running NodeMCU, and then also have a DNS server that points all requests back to the webserver that’s also running locally. Luckily someone has already begun the first step and written that, here’s the github link. He’s using a custom firmware with the DNS stuff turned on. It looks like he’s using 0.9.5 which uses about 16KB more ram, and they’ve added this feature in 0.9.6, but he hasn’t reconciled the differences as of this writing.

Anyways, it seems like it should be fairly straightforward to rip out the basic html games, and replace it with a sort of form post method, which then writes to the top of a file, and then the “server” reads from the top of the file and feeds it in to a CSS-formatted “wall” of sorts. And then also probably a cleanup script that moves older posts to a 2.html, and every 10KB or so worth of text, adds an additional N.html, and if N-100 exists, delete n-100.html.

The ultimate idea would be to have an ESP8266 running off of a 26650 or pair of 18650s, charged via a 5v 500ma solar panel facing south, with a 5v->4.2 lipo/li ion charging circuit (with 2.7v cut-out), and then an LDO down to 3.3v regulated. Supposedly the ESP8266 will run for 1-2 days on an 18650 and you only need about 3 hours of direct sunlight to fully charge the 18650, so I am thinking a 4000mah 26650 should last 2 full days between charges.

Anyways, it’s a neat idea. A self contained, anonymous, community message board that is self powered. The whole thing could fit inside of a waterproof junction box with a neodymium magnet, and then put a blob of epoxy on the back so it becomes permanent and stick it to the back of an east-facing street sign, so that the solar panel is west-facing. Given 1000 charge-discharge cycles it could, in theory last between three and six years.

I was able to flash the ESP8266 over the weekend, I’ve become quite proficient at it. I wrote a thank you note over at the ESP8266 forum. It turns out if you over-volt any part of the ESP8266 it has bad effects on the NAND flash memory (winbond 4mb module) and scrambles the data and also the firmware. Re-flashing the old AI Thinker 0.9.5 SDK firmware seemed to fix most of the problems. Apparently if you are not able to send data, but you’re getting garbage data back from the ESP8266, that means you should just go ahead and flash, even if you can’t decode the data (I tried all available baud rates, no luck). Flashing firmware direct over serial and pulling pins high/low to the power rail(s) was a new experience for me. I definitely feel much closer to the hardware now than I ever did with an Arduino.

Flashing the ESP8266 with NodeMCU 0.9.6

Anyways this is what I wrote, for future generations:

Anyways, this is what worked for me.

I am flashing direct from a raspberry pi A+ (3.3v serial logic level) to an ESP-12

This is what worked for me, building on top of your instructions. You’ll have to make sure you have esptool and picocom installed, which probably requires pySerial.

Rpi GPIO 14 (pin 08) -> esp GPO RX
Rpi GPIO 15 (pin 10) -> esp GPO TX
Rpi GND (pin 06) -> esp GND

VCC -> 3.3v power source
VCC -> GPO CH_PD (*)

GND -> GND power source

To flash
Disconnect VCC -> 3.3v power source
Disconnect VCC -> GPO CH_PD (*)
Connect GND -> GPIO 0
VCC -> 3.3v power source

Run “sudo python –port /dev/ttyAMA0 write_flash 0×00 nodemcu-master-7-modules-2015-09-06-22-54-05-integer.bin”

IMMEDIATELY (~0.5 seconds) Connect VCC -> GPO CH_PD (*)

Should flash
Disconnect VCC -> 3.3v power source
Disconnect GND -> GPIO 0
Connect VCC -> 3.3v power source

Run “sudo picocom /dev/ttyAMA0 –b 9600 –omap crcrlf –imap crcrlf ”

I was NOT able to re-flash NodeMCU 0.9.6 over top of itself. I had to reflash the AI Thinker 0.9.5 SDK (stock) firmware. Reflashing the old AI Thinker 0.9.5 SDK firmware “revived” a bunch of previously “bricked” ESPs.

I will have to get in to how POST messages work, as they have to be manually handled by the Lua script. That’s a task for tomorrow. And then also coming up with CSS to frame everything with. I found some example code I think I can leverage off of and go from there.

I did manage to fry one of my ESP8266, on my HP dual power supply the knobs allow you to go from 0-20v, and the knobs rotate in the opposite direction as the analog voltage meter sweeps. As I went to test to see how the ESP8266 recovers from voltage cutout, I dialed it to “0″, and was agape when I saw the needle bury at 20v instead of 0v. oops. To my suprise, I was able to massage it back to life and flash it a couple of times, but every time I tried writinga 56kb file to the NAND memory, it would corrupt and become unresponsive. Maybe I can set it up as a temp sensor or something. Who knows.

This is the death scream of a serial device when you accidentally feed 20 volts directly in to it’s puny 3 volt brain. ( “AhhA!!)!!!!!1ù” ) RIP #ESP8266  I was able to reflash it and get it to boot, but the flash memory wouldn’t hold for very long. I think the NAND is more voltage-sensitive than the CPU.

This is the death scream of a serial device being overvolted

One idea I had for a temp sensor was, since with NodeMCU you can modify the SSID so easily, read the temp sensor, and set the SSID as something like “T_85F_H_54P” where 85F is the temp and 54P is the relative humidity. That way anyone within broadcast range can check the temp without having to login to the device. I guess you could encode another 24 bytes of information in the MAC address too but that’s not human readable.

Oh right, I’ve been using my Raspberry Pi A+ to talk to the ESP8266. The Pi and the ESP both have 3.3v logic level so no converter is necessary, just the RX, TX pins and a common ground. I’ve been using picocom to monitor the serial output, and a combination of esptool to burn firmware, and then luatool and nodemcu-uploadertool to upload files. I like luatool because you handle the serial port in the commandline rather than digging around in the .py file to set it, but the uploadertool supports unlimited(?) file size (largest I’ve done is I think 100kb?) and more importantly multi-file upload. It’s not nearly as fancy as the ESP SDK on windows, but I like that I can talk to the Pi and the ESP over wifi from anywhere in the house, and I’m not tied to a workbench somewhere with the ESP’s fairly fragile flashing setup (I’m just using breadboard and jumpers).

I also have a Raspberry Pi based robot using bluetooth and wifi and motor controller on a modified Shrimpbot chasis. I will have to put up a seperate post about that when I get a chance.

Posted in computing, linux, Mechanical, robot | Tagged , , , , , , | Leave a comment

Tinkering with Microcontrollers, Arduino + Beaglebone, frustrations

Two primary lessons I’ve learned

  1. Don’t work on the wiring aspect of electronics past 1am or so. The chances of you shorting something out approach 100% as you get closer to 3am
  2. Servos have more torque than you think and consume a ton of instantanious amperage

I’ve been tinkering around with Microcontrollers since about February of this year, my main interest is in servo control but also I own more than a couple of 1″ OLED displays, some GPS modules , etc etc. First I started out with the Intel Galileo, but it turned out that it had terrible PWM (they’ve since fixed this with a dedicated PWM chip) and for some reason it would send my servos in to a haywire arrangement that I couldn’t understand. I had a birchwood articulated arm laser cut and shipped to my house, but without being able to resolve the problems with the wild servos I gave up and looked for something with more reliable PWM. I sold it to someone else and bought a Beaglebone black.

This is basically a cell phone with a bunch of pinouts for sensors (like on a cell phone) but also does PWM which is good for servo control, etc. I ran in to issues with the sensors however, they were 3.3v and the Beaglebone only takes, I think, 1.8v max input. This isn’t a difficult problem to solve, but required learning how to split the voltage. In trying this, at 4am, a wayward wire scraped across the BBB and shorted something out. I had to wait almost four months for a replacement. This was shortly after I had finally gotten Debian working on the device and sortd out the CapeMgr, etc that makes servo control in python fairly easy.

In the mean time I ended up ordering an arduino, which I’ve had better luck with. But as it turns out, those servos pull a ton of amperage and they really need to be on their own power circuit to keep from “browning out” the microcontroller, which in retrospect was probably was what was causing the erratic behavior.

In other news, I bought a dedicated PWM controller that talks over I2C, but I did something that caused the motor to overtorque and damage the potentiometer, looks like that servo may become a continuous rotation servo, now.

Posted in computing, Mechanical | Tagged , , , , , , , , | Leave a comment

Converting Bitnami VMDK to Hyper-V VHDX files

I scoured the internet looking for an answer on how to run a Bitnami Virtual Appliance in Microsoft Hyper-V. I’ve had some luck using TurnKey Linux, but the hostnames in TurnKey don’t resolve well (or at all) using windows/OpenWRT so I’ve been looking at Bitnami. Since Windows Pro comes with Hyper-V, I thought I’d give it a try. Unfortunately, while TurnKey provides raw ISOs, Bitnami only provides files (or “stacks” as they call them) that are useful for VMWare and VirtualBox users.

After a couple hours of bouncing around the internet I finally came across a solution – Microsoft Virtual Machine Converter. Except that all of the tutorials referenced mvmc.exe, which is no longer included! It has been recompiled as MvmcCmdlet.dll or some other directly-inaccessible vector and the only exe left is Mvmc.Gui.exe.

Turns out you can call the cmdlet via powershell if you know how to load it. Further googling resulted in this, which I posted to Bitnami’s forums in the hopes of helping out others. I decided to use the Minecraft bukkit bitnami stack as a fun example.

Continue reading

Posted in computing, windows | Tagged , , , , , , , , | Leave a comment

Bicycles and Cats, and why bicycles self-steer themselves (and cats always land on their feet)

I’m curious, how does stem length impact steering feel?

I realize that steering feel is almost 100% impacted by trail (how far the contact patch is behind the line of the head tube) but for example, on my project bike, the old quill stem is 70mm, which puts the handlebars (3 inches) behind the hub; the new quill stem is 150mm which should put it in line with the hub.

I was looking in to wheel trail and came across this experiment again on bicycle stability, but apparently now there’s a Wikipedia page on it, and also a very good video with description of how it works (the wiki page sucks). Basically the idea is to remove things like gyroscopic forces (wheel stability), trail (front wheel auto-stabilization) and see if the bike will keep going in a straight line.

Basically what they decided is that since the front wheel has a non-zero mass, since the fork/wheel is smaller it actually rotates at a faster rate than the rest of the frame. As a result the steering motion causes the bike to self-right despite the fact that it has negative trail.

Ok, so what does that mean exactly? Well fortunately someone as smart as me already went ahead and put this in to a visual frame of reference. With Cats. The internet loves cats. How cats rotate from upside down to right side up in free fall is an interesting part of Physics minutia, but basically the long and short is that once the cat knows what way is up, they pull in their legs in the front and twist, then extend the front legs, retract the rear legs and twist again. Boom, instant reorientation using two sets of angular momentum. That probably made no sense so here’s the video.

Posted in bicycles, Mechanical | Tagged , , , , , , , , , | Leave a comment

NIC Teaming on Windows 8.1 (really)

So there is a way to get NIC Teaming to work in Windows 8.1. WS2012 R2 has dead-easy way to team any two nics (effectively giving you 2 gigabit eithernet if the other end also has at least 2 gigabit capacity). And during the Windows 8 developer preview, Microsoft had forgotten to turn off NIC Teaming, so there are a ton of (outdated) articles explaining how to turn it on. The retail version of Win 8 did not ship with this feature, nor did the retail version of 8.1, not even Pro or Enterprise.

As it turns out, Intel includes NIC Teaming in the PRO version of all their Ethernet cards. Intel pretty much owns the server Ethernet card market so they’re both cheap and plentiful. The driver-level (as opposed to Microsoft’s OS-level NIC Teaming) teaming works between any two Intel PRO Ethernet cards (I think) and, more importantly, works on Windows 7, Windows 8 and Windows 8.1 (and more than likely, someday, Windows 9). For your convenience, Intel makes dual gigabit Ethernet cards for less than fifty bucks which is awfully nice of them. The new version runs about $150, but supports VT-c which is greatly improved for boxes hosting lots of virtual machines, it allows direct hardware pass-through to the VM improving performance and also power consumption/heat.

So how do you get this $50 wonder card to work with Windows 8.1? I’m glad you asked, someone wrote-up this how-to, and that’s what I’m here to share

Continue reading

Posted in computing, windows | Tagged , , , , , , , , , , , | 7 Comments

Intel’s Galileo Ardunio and Powershell

Intel’s Galileo is a pretty neat piece of kit. However it won’t always connect on the same COM port (typically COM3 or COM4). The only way the tutorials tell you to check this is via a menu deep inside the Control Panel if you’re on Windows. The good news is that there’s a pair of simple commands in Powershell that give you access to what you need.

Get-WMIObject Win32_SerialPort | Select-Object Name,DeviceID,Description

This will give you the device number, description and COM port.

However, the device is half baked. Buggy firmware that won’t take new sketches after 5-10 uploads, lack of even a basic tone() library, and serveo library support so bad it might as well not even be there. Had it for 48 hours and I’m returning it for a Beaglebone Black. On the upside, I got to wander around the house talking about stuff like “pulse width modulation” and feeling smart while I complain about how bad the Galileo is.

As cool as the project is, Intel, you really let me down this time. The board has been out for four months, since October, and there hasn’t been a single firmware or Linux software update. It’s February for crying out loud. Round 2 is with TI and their Beaglebone..

Posted in computing, linux, Mechanical | Tagged , , | Leave a comment

Red Green Show now on YouTube (Legally) in all it’s glory

Friend of mine sent me this:

I listed out all the play lists for my dad for the red green show because youtube’s ui on the playlists is kinda funky, here it is, every episode by season play list.

91 season,
92 season,
93 season,
94 season,
95 season,
96 season,
97 season,
98 season,
99 season,
00 season,
01 season,
02 season,
03 season,
04 season,
05 season,

if you put these on and then connect to chrome cast it will just play the whole play list even if you shut your laptop off which is awesome.

Posted in Mechanical | Tagged , , , | Leave a comment