Destroyed my intermediate gear

2015-05-02 14.08.38   2015-05-02 14.08.45   2015-05-02 14.08.28   2015-05-02 17.31.52   2015-05-02 17.31.44   2015-05-02 16.31.11   2015-05-02 16.31.04   2015-05-02 16.30.56   2015-05-02 16.30.52   2015-05-02 12.10.41   2015-05-02 12.10.37   2015-05-02 12.10.32   2015-05-02 12.10.24   2015-05-01 19.33.36   2015-05-01 19.33.29   2015-05-01 19.33.22   2015-05-01 19.33.14   2015-04-30 20.17.50   2015-04-30 20.17.36   2015-04-30 20.16.57   2015-04-30 20.16.44 2015-04-30 20.16.29 2015-04-30 19.57.49

Working on X2 mini mill


Got my Gon Keyboard PCB


Electro Etching

Well I was supposed to do the final part of my AVRDUDE programming thing but I got distracted by life, and electro etching. I plan to finish the last part of that this wknd though….

So anyways I tried this electro etching stuff out and it’s a BLAST. I can’t wait to etch some other stuff. I basically have an unlimited supply of blanks from the trash can at work but here’s a couple samples from my first 2 attempts at etching.

2015-01-15 18.00.21

2015-01-15 19.19.56

2015-01-15 19.19.45

2015-01-15 19.14.35

2015-01-15 19.14.31

2015-01-15 19.14.19

2015-01-15 19.14.02

2015-01-15 18.04.57

2015-01-15 18.04.47

2015-01-15 18.00.44


Upload Arduino Sketch Over Wifi With Openwrt And Avrdude Pt. 3

Obligatory disclaimer:
You can brick your router doing this, you can burn your house down doing this, and you can probably do some other horrible stuff somehow I’m not aware of. So if you’re not sure if you should do something…..DON’T. Openwrt wiki is the definitive source for making and loading custom images to your device. This tutorial merely covers what works on my device at this point in time and space.

Part 1
Part 2

Part 3

Alright I finally got my MPR-A2’s in so I can finish this thing up. In the last part we set up a VM to make a custom openwrt image with avrdude and all the USB stuff we need to talk to our arduino. I added my own compiled images to github in case anyone was unable to compile for whatever reason or they didn’t want to sit around for hours waiting on a build.


Hame MPR-A2 Manual Link

In this part I’ll go over loading openwrt onto your router and configuring it. The plan is to do a very basic configuration where the “router” just gets on your network and grabs an ip from your current dhcp server. First we’ll have to load a ram image and after that we’ll load the squashfs openwrt image. For this part you’ll need an ethernet cable and a computer with an ethernet port to connect to the router. Once you get openwrt and wifi configured you can start using that to communicate with the router.

For this phase you need to connect the ethernet wired from your computer to the port on the router. On the MPR-A2 there is only 1 port so it’s pretty easy to figure out where to put it. Once you’ve got it plugged in you can turn the router on. The MPR-A2 starts up with dhcp on Pointing your browser to should open the routers default home page.

Click on login in the center and a prompt for a password should appear. The default password is hame.
Screenshot - 01032015 - 10:37:14 AMnew

Screenshot - 01032015 - 10:37:48 AMnew

Once you’ve logged in you should be on the initial login page.

Screenshot - 01032015 - 10:38:22 AMnew

Now we need to go to the admin dropdown menu and select upload.

Screenshot - 01032015 - 10:38:41 AMnew

Now we need to select our ram image to upload to the router. I downloaded the whole folder to my local computer. The files you need are in openwrt/trunk/bin/ramips/ folder. The file we need to upload is


Screenshot - 01032015 - 10:38:59 AMnew

Screenshot - 01032015 - 10:40:36 AMnew

Image to upload
Screenshot - 01032015 - 10:39:46 AM

Once you select the file to upload hit apply and your router will load the image and reboot. Wait 5 minutes just to make sure every thing has taken. I changed my ethernet to a static ip of after I uploaded the image. Openwrt defaults to At this point you should be able to telnet into your new openwrt build.


Screenshot - 01032015 - 10:43:50 AM

To connect with ssh to your router you need to set the root password for the router. In order to do this we’re going to use the passwd command. Once you set the root password telnet will be disabled and ssh will be enabled for you to access and administer your router. You won’t see anything that you type while you are entering your new password. After you set the password type exit at the command prompt to exit the telnet connection.

*****enter password 2x*****

Screenshot - 01032015 - 10:44:11 AM

Now you should be able to ssh into your new build.

ssh [email protected]

Screenshot - 01032015 - 10:45:18 AM

Now we need to get our squashfs image on to the router. You can use whatever method you’d like to get the file into the /tmp folder of the router. I personally use midnight commander. Midnight commander makes it easy to navigate folders and move files around between computers. You can use any number of methods to achieve this but I’ll be covering doing it with midnight commander. In ubuntu apt-get install mc will install midnight commander and mc will run midnight commander.


Screenshot - 01032015 - 10:48:20 AM

Once in midnight commander we need to open a shell link to the router. Just open the right dropdown menu and select shell link.

Screenshot - 01032015 - 10:48:00 AM

Enter the ip address and username for the router in the form field and hit enter. This should bring you back out to the terminal where you need to enter your routers root password. Once you enter that it will take you back into midnight commander. Navigate to the /tmp dir on the router (in the right side of the window). On the left side navigate to the directory where you have your openwrt images. We need to upload the sysupgrade squashfs image now.

Screenshot - 01032015 - 10:50:44 AM

Copy the sysupgrade image to the routers /tmp directory

Screenshot - 01032015 - 10:51:10 AM

Now that we have the image loaded in we can do a sysupgrade from the command line on the router.

sysupgrade -v /tmp/openwrt-ramips-rt305x-a2-squashfs-sysupgrade.bin

Screenshot - 01032015 - 10:51:50 AM

Screenshot - 01032015 - 10:52:13 AM

Screenshot - 01032015 - 10:52:38 AM

Once the system has rebooted we have to repeat the passwd process. Telnet into and use passwd to change the root password. Once you’ve done that you will be able to ssh into the server again and do our final configuration to get the router online and be one step closer to having a wifi arduino/avr programmer. If you get the error below when you try to ssh back in just read it and follow the instructions. Just copy the line that looks like this and enter it in terminal.

ssh-keygen -f "/home/lee/.ssh/known_hosts" -R

Screenshot - 01032015 - 10:56:49 AM

I disable the firewall since I don’t need it in my application. Feel free to configure this however you want, but I will be proceeding through this walkthrough assuming you have disabled your firewall on the router.

/etc/init.d/firewall disable
/etc/init.d/firewall stop

Screenshot - 01032015 - 04:07:18 PM

Now it’s time to get the router connected to your network. We just need to change some settings in a couple files on the router and we’re done with this part. The 2 files we need to edit are

I just use vi to edit my files for this. Feel free to use whatever editor you want. I think vi is the only thing on openwrt by default. But I won’t lie I have no idea. I just use Vi.

vi /etc/config/network

Screenshot - 01032015 - 04:08:34 PM

The main thing we need to edit in the file is to comment out the option ifname on the wan interface. proto dhcp should already be enabled.

config interface 'wan'
	#option ifname 'eth0.2'
	option proto 'dhcp'

Screenshot - 01032015 - 04:12:51 PM

Next we need to edit /etc/config/wireless

vi /etc/config/wireless

Screenshot - 01032015 - 04:14:15 PM

In here we need to change the router to STA and put in your wifi network ssid, encryption, and password. You also need to comment out the option disabled 1 line that is below the remove this line to enable wifi.

config wifi-device  radio0
	option type     mac80211
	option channel  11
	option hwmode	11g
	option path	'bcma0:0'
	option htmode	
	#option disabled 1

config wifi-iface
	option device   radio0
	option network  wan
	option mode     sta
	option ssid     your wifi ssid
	option encryption your network encryption type (psk, aes, etc.)
	option key	yourpasswordhere

Screenshot - 01032015 - 04:16:23 PM

That is about all the configuration we need to get this thing going. We just need to enable the wifi/wan interface now. At the command prompt enter

ifup wan

Screenshot - 01032015 - 04:17:31 PM

Now try pinging something to see if you can get out.
I just pinged google.com
Screenshot - 01032015 - 04:18:06 PM

Now that you can get out run opkg update.
Screenshot - 01032015 - 04:40:40 PM

That’s it for now. All the heavy lifting is done now I’ll save the fun of programming the arduino over wifi for the last post. Basically all you have to do is plug a usb cable into your router and into the arduino and you can run avrdude if you don’t feel like waiting for the last post. Here is a line i pass to mine to program a mega2560. I’ll put the final post up tomorrow, barring any emergencies.

avrdude -F -v -p atmega2560 -c wiring -P /dev/ttyACM0 -b115200 -D -Uflash:w:/tmp/Blink.cpp.hex -C /etc/avrdude.conf

Upload arduino sketch over wifi with openwrt and avrdude Pt. 2

OK in the previous post I went over setting up a VM for this custom openwrt build. The same warnings and disclaimers about death, destruction, and the wonderful world of bricked routers still apply to this post. The main reason I’m doing this is to make sure it’s a minimal clean installation that is easy to set up for anyone. There should be no problems associated with someone’s current OS or build setup when using a “new” VM.

This is a WAY better tutorial on building openwrt. If you’d like to know more about building custom openwrt images that’s the place to go. I know just enough to get openwrt do what I need it to.

The definitive source for openwrt on the Hame MPR-A2 is right here. Please make sure you check the openwrt wiki before making any changes to your router. Things change and my blog may not necessarily have the most up to date information for this router or any router. The entire build process is covered in the openwrt wiki. All I’m doing is copying their build process and adding pretty pictures.

Alright so on to setting up the openwrt build. First we need to make a directory to hold all of our stuff for this. You can name the folder whatever you want but all the following steps will be assuming you use the same directory structure that I’m using.

Screenshot - 12222014 - 09:14:27 PM

mkdir ~/openwrt
cd ~/openwrt

Now it’s time to grab openwrt trunk from the svn.

Screenshot - 12222014 - 09:17:07 PM

svn co svn://svn.openwrt.org/openwrt/trunk
cd trunk

Screenshot - 12222014 - 09:17:34 PM

Next we need to edit feeds.conf.default. We’re doing this to enable the old packages where avrdude is at.

Screenshot - 12232014 - 08:07:34 PM

vi feeds.conf.default

I uncommented the line with oldpackages.git then saved the file.

Screenshot - 12222014 - 09:23:48 PM

Now we need to update the feeds.
Screenshot - 12222014 - 09:21:49 PM

./scripts/feeds update -a

I’m lazy and want to make sure I have everything I need for my build so I just install everything.

Screenshot - 12222014 - 09:26:06 PM

./scripts/feeds install -a

Now we can start setting everything up in the openwrt configuration menu.

make menuconfig

Once you’re in the configuration menu the first thing we need to select is the target system for the build. The target system for the Hame MPR-A2 is Ralink RT288x/RT3xxx. Selecting that for the target system automagically selected the Subtarget: RT3x5x/RT5350 based boards.

Screenshot - 12222014 - 09:31:42 PM

Next we need to back up and select our target profile. Which is the Hame MPR-A2

Screenshot - 12222014 - 09:32:05 PM

For the initial install of openwrt on the router we need to create a ramdisk image. So we need to go to Target images and select the ramdisk image option. This will create the files we need to get the first install on.
Screenshot - 12222014 - 09:32:22 PM

Screenshot - 12222014 - 09:32:33 PM

Now it’s time to install the kernel modules we’ll need for USB to talk to the arduino. Spacebar will select an option. If you press it once an M will appear between <>. So an option module will appear like this . If you select an option 2 times an * will be be visible. The * signifies that the module will be built into the kernel. I selected to have the options I chose built in. If you’d like to have the option to install other modules at a later time just designate them as modular. In the USB section I selected ACM at a minimum. I also added the USB modules for the chipsets my USB programmers use. FTDI232R, Cypress, and Siliconlabs.
Screenshot - 12222014 - 09:33:43 PM

You can add I2C support if you like. At a later time I plan on using I2C or serial from the board to send info to the arduino over wifi. You don’t have to enable any of this for what this guide is covering though.
Screenshot - 12222014 - 09:33:53 PM

Screenshot - 12222014 - 09:34:24 PM

Screenshot - 12222014 - 09:34:35 PM

Screenshot - 12222014 - 09:35:17 PM

Now we need to back out and find the utilities section. This is where we’ll select avrdude and I also added usbutils to assist in troubleshooting any USB problems that pop up.

Screenshot - 12222014 - 09:36:00 PM

Screenshot - 12222014 - 09:36:18 PM

That’s basically it for the configuration. You can save now and exit out of the configuration utility. You can add whatever you like but the Hame MPR-A2 doesn’t exactly have tons of room for unnecessary items.
Screenshot - 12222014 - 09:37:00 PM

Now just type in make at the command prompt and go get a beer!


Screenshot - 12222014 - 09:42:44 PM

Screenshot - 12232014 - 05:39:18 AM

If you have any errors you’ll just have to troubleshoot your way through them. I had problems trying to make on a VM with only 1GB of ram. It kept crashing on me during the build. The #openwrt room on freenode is full of very knowledgeable people. It’s a great resource.

That concludes Part 2. I’m waiting for 2 new routers to show up so I can complete the tutorial. Once they get here I’ll post up the process of taking a brand new router and and installing openwrt on it and getting avrdude going. If you don’t want to wait you can just follow the openwrt wiki for the rest of the process.


Upload arduino sketch over wifi with openwrt and avrdude Pt. 1

Part 1: Setting up the VM and dependencies.

Obligatory disclaimer:
You can brick your router doing this, you can burn your house down doing this, and you can probably do some other horrible stuff somehow I’m not aware of. So if you’re not sure if you should do something…..DON’T.

Now in all seriousness probably none of that will happen but, hey if it does I warned you.

So I got some WS2812 led’s on the Xmas tree and I got sick of getting up and hooking up a usb cable to an arduino every time I wanted to change my sketch. So I started looking online to see if I could find some way to upload sketches over wifi. I came a across a couple articles of people mentioning that they had put avrdude on an openwrt router and were using that to upload sketches to their arduino projects. I never could find a good tutorial for how to do the “whole” process. So I’ve decided I’d post this up to help other people…and to help me remember how I did it. I’ve set this up so far using an Asus RT-N16 and a Hame MPR-A2. The Hame is going to be my go to router for all projects at this point. I just happened to have an RT-N16 laying around though and that’s what I used to test everything out on. In this article I’ll cover the process to set up the MPR-A2.

The basic process consists of building a custom openwrt build with avrdude on it and some other requirements then installing that build on the router and uploading your sketches to your arduino. I’m going to cover the whole process from setting up a build VM all the way through pushing a program to your arduino.

If you get hung up setting up the VM there are tons of tutorials all over the internet on setting up a VM. The basic gist of this is just to set up a fresh VM with just the basics for the custom openwrt build.

So the first step is to download Ubuntu server 14.04

Next you need to get Virtualbox. You can use whatever virtualization you’d like for this but I’m going to cover using Virtualbox here.

Now it’s time to set up your VM.start virtualbox

Put in a username


Choose amount of RAM to dedicate to VM. The more RAM you have available the faster you’ll be able to finish your openwrt build. I allocated 4GB to mine. If you’re not in a hurry you can use less.

Screenshot - 12222014 - 08:05:05 PM

Setup Virtual hard drive. Allocate whatever you think you’ll need here. If you’ll just be using this to do this you can probably get away with 12GB. I just gave mine 80GB for some peace of mind.

Screenshot - 12222014 - 08:05:19 PM

Screenshot - 12222014 - 08:05:30 PM

Screenshot - 12222014 - 08:05:48 PM

Screenshot - 12222014 - 08:06:13 PM

Go into the VM’s storage settings and load the Ubuntu server ISO you downloaded earlier into the virtual cdrom. When you power up the VM it will begin the Ubuntu installation process.

Screenshot - 12222014 - 08:08:40 PM

I also changed my network settings for the VM to bridged.

Screenshot - 12232014 - 07:08:09 PM

Go through the install process for Ubuntu server. This will be a “headless” install so I kept it very basic with just OpenSSH installed to administer the VM. We won’t be needing anything else for this machine.

Screenshot - 12222014 - 08:16:47 PM

Screenshot - 12222014 - 08:17:06 PM

Screenshot - 12222014 - 08:17:19 PM

Screenshot - 12222014 - 08:17:43 PM

Screenshot - 12222014 - 08:26:07 PM

Screenshot - 12222014 - 08:26:37 PM

Screenshot - 12222014 - 08:32:22 PM

At this point your VM should reboot and start up with a command prompt for you to login. Go ahead and login and update and upgrade your server.

Screenshot - 12222014 - 09:06:16 PM

This is my update/upgrade shotgun

sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade && sudo apt-get autoclean && sudo apt-get autoremove && sudo reboot

Next we need to get all of our dependencies for building openwrt.
Screenshot - 12222014 - 09:12:20 PM

sudo apt-get install subversion build-essential libncurses5-dev zlib1g-dev gawk flex quilt git-core unzip libssl-dev

At this point we have Ubuntu set up with everything we need for our custom openwrt build. The post is getting a little long so I’m going to continue it on setting up the openwrt build.


MSGEQ7 Graphic Equalizer/Spectrum Analyzer

I finally got back around to messing with the MSGEQ7 LED equalizer/analyzer. I had planned to set this up in the windows in front of the house for Xmas but I appear to be running out of time. 2014-12-02 18.51.06

I’ll have to add a fritzing for this post at some point but I’ll just throw my code up here for now that I used to get this working. I used a couple pots to control the LED strip brightness and color.
At some point I’m going to use RFID cards and a web app to change the colors and brightness. I thought it would be cool to use RFID cards by the Xmas tree color coded so anyone walking by can swipe a card and change the tree color.

Right now it’s just set up for mono but I’m working on making a stereo PCB with 2 MSGEQ7’s. I’ll add more to this including my pcb’s once I’m finished. You could of course just by a MSGEQ7 shield from Sparkfun.


Here are some videos of it in action.

msgeq7 ws2812 led equalizer
#include <Adafruit_NeoPixel.h>
//#include "WS2812_Definitions.h"       //add this if you want
#define LED_PIN         6       //pin for led strip
#define LED_COUNT       49  //# of leds in strip
#define LED_IN_BAND     7       //# of leds per band
#define STROBE_PIN      2       //Strobe pin for msgeq7
#define RESET_PIN       3       //Reset pin for msgeq7
#define ANLG_IN_PIN     A2      //analog input pin for msgeq7
#define BRIGHT_PIN      A1      //pin for brightness potentiometer
#define COLOR_PIN       A0      //pin for color potentiometer
//setup strip values
Adafruit_NeoPixel strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, NEO_RGB + NEO_KHZ800);
/*call out pins for msgeq7*/
int analogPin = ANLG_IN_PIN;    //output pin to read bands for eq7
int strobePin = STROBE_PIN;     //strobe pin for eq7
int resetPin = RESET_PIN;               //reset pin for eq7
int bandValue[7];                               // to hold a2d values
int bandMap[7];                                 //hold mapped values for the band
long lightState[7][7];                  //multidim array to hold light color use later or struct for lights
/*color and brightness  */
int brightPin = BRIGHT_PIN;     //pot pin
int bright = 0;                                 //variable to store value for brightness
int brightVal = 0;                      //brightness value
int colorPin = COLOR_PIN;               //pot for color adj
int color = 0;                                  //variable to store the pot value for color
int colorMap = 0;                               //temp value to store mapped color value
long adjColor[8] = {0xFFFFFF, 0xFF1493, 0xFFFF00, 0x556B2F, 0x48D1CC, 0xFF6347, 0xFF4500, 0x008000};
long colorVal = 0;                              //value for color of led strip
int ledsInBand = LED_IN_BAND;   //leds in band, in defines
void setup()
  //Serial.print("\eSP F");  // tell to use 7-bit control codes
  //Serial.print("\e[?25l"); // hide cursor
  //Serial.print("\e[?12l"); // disable cursor highlighting
  strip.begin();        //      LED strip setup
  strip.show();         // Initialize all pixels to 'off'
  //initialize the msgeq7
  pinMode(analogPin, INPUT);
  pinMode(strobePin, OUTPUT);
  pinMode(resetPin, OUTPUT);
  digitalWrite(resetPin, LOW);
  digitalWrite(strobePin, HIGH);
void loop() {
//read pots for led color and brightness
//read the msgeq7
//put the eq values into array
    for(int band=0; band<7; band++) {
      for (int led=0; led<ledsInBand; led++) {
        lightState[band][led] = (led<=bandMap[band])?colorVal:0;
    for(int band=0; band<7; band++) {
      for (int led=0; led<ledsInBand; led++) {
        strip.setPixelColor(band*7+led, lightState[band][led]);
    for (int i=0;i<7;i++)
      Serial.print(" ");
Function to set strip color and brightness     
void colorbright() {
    bright = analogRead(brightPin);                             //read pot to get brightness for strip
    brightVal = map(bright, 0, 1023, 0, 255);   //map led brightness value for strip
    color = analogRead(colorPin);                               //read pin to find color value from pot
    colorMap = map(color, 0, 1023, 0, 7);               //map pin value to # of available colors set in adjColor
    colorVal = adjColor[colorMap];                              //set color to list of colors above
Function to read the msgeq7
void readMSGEQ7() {
    digitalWrite(resetPin, HIGH);
    digitalWrite(resetPin, LOW);
    for(int i=0; i<7; i++)
      digitalWrite(strobePin,LOW); // strobe pin on the shield - kicks the IC up to the next band
      delayMicroseconds(30); //
      bandValue[i] = analogRead(analogPin); // store left band reading
      bandMap[i] = map(bandValue[i], 0, 900, 0, 6);  //map the band values to light positions
      //right[band] = analogRead(1); // implement later

Some pics of the setup until I can do something prettier

2014-12-02 18.51.39

2014-12-02 18.51.16

2014-12-02 18.51.22