Sunday, August 12, 2012

TeensyTyper - A Teensyduino USB Keyboard

There are plenty of tutorials showing the basics of having an Arduino or similar device act as a USB device of different types, which was only made easier with the Arduino Leonardo or the Teensy 2.0.
I had a problem that needed a solution and decided to spend the day with one of the Teensy 2.0's I got in yesterday to create it.

At work, I have to log into a bunch of different systems that do not normally have keyboards attached that have differing schemas and handling of passwords. It is a pain to have to dig out a keyboard, type in a convoluted user id and password or head back to my office to grab the password list to figure out which one it is currently.

I wanted to make a device that would fit in my pocket that I could use to plug into a system, select a script to run, and let it handle all the typing for me. I have seen several other similar solutions, but most of those just have multiple buttons for each command. For this project, I wanted to give it a simple but scale-able user control. It also had to be easily fit into my pocket and not collect lint.

The end result is this:


My USB Key TeensyTyper
Note: This device is 1.5 inches x 1.75 inches.
While it first into a small tin, I had to use a bigger one to get the USB Cable in.

The top button selects between scripts. The bottom button runs that script. The 7 segment display shows which script number you will be running. The dot on the 7 segment display pulses to tell you it is on and stays lit when running a script.

Software-wise, I have some passwords set as part of the program. I have another set stored in the Program Memory area. Since one of my passwords changes monthly, I store which password of that set to use in the EEPROM memory.

When I need to access a system, I plug it in. I select a script and execute. No more having to retype that one blasted password 5 times in a row holding my keyboard with one hand and pecking out the password with the other. No more having to remember what this months password is for the other piece of software. No more having to remember if it is "?Pass&*word99Z" or "?Pass&*Word99Z" or "?pass&*word99Z".

Source code and wiring diagrams are on my Github page. The wiring diagram is cluttered on a breadboard because I wired this thing on both sides of my PCB to keep it compact and to keep the control functional.

This is what it looks like with the tin case cut.

Saturday, May 26, 2012

The Road Ahead



As the first Guild Wars 2 Beta weekend ground to an end, Frank and I had been in a lot of close quarter areas fighting monsters non-stop with explosions and warcries echoing. When we peaked the top of a hill the serene calm of the swooshing grass of a green field, my jaw dropped  and we stopped in our tracks.

I can't wait to journey there again so that we can continue the adventure. (Next time maybe Lain won't get bored and watch Halo videos instead of playing with us.)

Tuesday, April 24, 2012

Raspberry Pi - Day 2, 3 and 4

I spent Day 2 about 350 miles away from my RPi, having to go to a convention for my day job. Days 3 and 4 were wrapped around trying to get the Debian kernel to find the uvcvideo module. On a whim, I went ahead and tried the ArchLinux build and low and behold, uvcvideo was cooked in. I moved my scripts over from the Sheevaplug that I was prototyping on and got to work.

Things that I have installed that worked without issue:

* motion - gets 6 GPS with movement processing
* uvcvideo - Mounted my 4 USB cameras without an issue
* MySQL
* git
* opencv
* python2

Things that partially worked:
* audio - The mp3 player I was using, mplayer, is panicking the kernel due to issues with the kernel that are in process of being resolved. TBE worked much better, but has a weird problem that the process hangs for a few seconds after the stream ends.

Wednesday, April 18, 2012

Raspberry Pi - Day 1

After a long wait, a quick rush to order at 1 AM, and another slightly shorter but long wait, my first Raspberry Pi showed up on my doorstep. I have been prototyping a system to basically create a home sentry system (aka Turret from Portal 2).

Up until this point, I have been using a SheevaPlug with a USB soundcard, a USB camera, and an Arduio with a Motor control shield. I ran the ARM version of Debian, which the RPi has a release already created as well. On top of that, I use the OpenCV library in a Python script to handle the webcamera feed and detect movement. If no movement occurs after a long time, the bot starts talking to itself. When it detects movement, it  plays sounds from the "Detect Movement" bank and runs the motor to open the arm sockets. When it detects noise, it plays sounds from the "Detect Noise" bank. After a interval, if noise or movement stops, it goes back into a Caution state and plays caution sounds for a while and retracts the arms, then goes back into a sleep state. I did a quick prototype prior to digging into OpenCV using a great app called "motion".

A rather simple project, but one that involves computer vision, motor control, audio files, and is possible to do extremely inexpensively, especially due to the RPi being $40.

Code will be posted when I get to at least an Alpha state of the project.

Tonight, I was able to load my SD-card with the Debian install, expand it out to the full size using a GParted Live disk in a VirtualBox window on my Windows 7 PC, and accessed the RPi via SSH. I then loaded motion, opencv and python-opencv. Python is already installed. It looks like the uvcvideo module is not installed and I am having problems grabbing the kernel sources to import it myself.

So, I guess this puts an end of my first day of this.

Friday, April 6, 2012

Pogoplug+: From Out of the Box to Media Grabbing and Slinging Machine

This guide will walk you through modding a Pogoplug to handle grabbing media from Usenet to serve out to the rest of your home network.

We will be installing:

  • ArchLinux|ARM for the Operating System. (The current V3/Classic/Pro kernel is 2.6.31.6_SMP_820.)
  • Sickbeard and Couchpotato will be used to grab media through Sabnzbd.
  • Samba to serve files to your Windows PCs and Media Boxes

Other things you can install:
  • NGINX to wrangle all the ports into easy to remember urls and accessibility from the Internet
  • MiniDLNA or MediaTomb to transcode to devices like the PS3

I used a Pogo-B01 (aka Classic) on 4/4/2012, changes to the OS or Apps used may change after this date and require different instructions. The packages involved should be available for your Pogoplug. The only major difference being the initial loading of ArchLinux|ARM. Also, this fits a few of my personal tastes in setup

What you need:

Only have your OS drive plugged in until later. This way, you won't accidentally wipe out anything you give a care about.


Steps:
1. Set up ArchLinux|Arm on the system per your particular Pogoplug’s revision http://archlinuxarm.org/platforms
  • For the V3/Classic/Pro: At the step 14, before running depmod, you may need to set up the modules.builtin file first:
    cd /lib/modules/2.6.31.6_SMP_820 && find . | grep ko | cut -f 2,3 -d \. | cut -f 2- -d \/ > modules.builtin
  • For the V3/Classic/Pro: At the step 16, where the instructions say to update packages using pacman, it will ask to update pacman first, tell it NO! Also, if it asks you to remove udev-oxnas for udev, tell it NO! It will only ask if you try to update pacman first before updating everything else. Replacing udev-oxnas will udev will cause your plug to no longer boot. If you somehow have still went ahead and did that, see the “Help! It stopped working!” part at the bottom of the http://archlinuxarm.org/platforms page for your box to start recovery of the OS.

27% of diskspace on a 2 GB memory stick already eaten up

2. Create a swapfile:
dd if=/dev/zero of=/swapfile.img bs=1M count=512
mkswap /swapfile.img
swapon /swapfile.img
echo "/swapfile.img   none   swap   sw   0   0" >> /etc/fstab

We may be able to get away with 256, but I want to play it safe when this thing will be doing large unrar operations.

3. Install SABnzbd:
pacman -Sy sabnzbd

4. Configure SABnzbd to listen for remote machines and require a login:
nano /etc/conf.d/sabnzbd

Change the below line, replacing 127.0.0.1 with your boxes IP address:
SABNZBD_IP="127.0.0.1"
Example:
SABNZBD_IP=”192.168.1.107”

Change the below, adding in a login name and password with a colon separating the name and password and an @ after the password:
SABNZBD_USPW=""
Example:
SABNZBD_USPW=”john:password@”

Press Control-
5. Start SABnzbd:
rc.d start sabnzbd

6. Log in to SABnzbd to make sure it works.
http://192.168.1.107:8081

Don’t load any files just yet or you will run yourself out of diskspace quick.

7. Get yaourt to install other apps:
pacman -S yaourt

8. Install Sickbeard:
yaourt -AS sickbeard

Respond No to “Edit PKGBUILD?”
Respond No to “Edit Sickbeard.Install?”
Respond Yes to “Continue Install?”
Respond Yes to “Install Sickbeard?”
Respond Yes one more time for the “Proceed with Installation?”

9. Let’s fix a very out-of-date sickbeard:
cd /usr/lib
mv sickbeard sickbeard-bak
wget --no-check-certificate https://github.com/midgetspy/Sick-Beard/tarball/master
tar -zxvf master
mv midgetspy-Sick-Beard-xxxxxx my-sickbeard-install
chown -R sickbeard:sickbeard sickbeard
rm -rf sickbeard-bak

The xxxxxx will be something like acaf5ca, just look at the output from the “tar” command.

10. Start up SABnzbd.
rc.d start sickbeard

11. Log in to SABnzbd to make sure it works and click the “Update” button at the top.
http://192.168.1.107:8080

Don’t load any shows just yet or you will run yourself out of diskspace quick.

12. Install CouchPotato:
pacman -S couchpotato-git

13. Start up CouchPotato.
rc.d start couchpotato

14. Log in to CouchPotato:
http://192.168.1.107:5000

Don’t load any movies just yet or you will run yourself out of diskspace quick.

15. Install Samba using this guide: http://archlinuxarm.org/support/guides/applications/samba


16. Run “df”. You should now be setting at around 77% of a 2 GB drive used. This is why I wanted to make sure you weren’t using up drivespace with downloads. We need to set each tool to use a different drive than your USB stick for their storage needs.

17. Plug in your USB hard drive now. If you had done the udev-automount from the ArchLinux|ARM instructions in step one and your drive was already formatted in Windows using the FAT32 or NTFS file systems, it should have just mounted on your Pogoplug.  If you need to format it or want to format it in a Linux format like EXT3, do this now. I figure many of us have a drive already formatted in Windows and would like to be able to take it other places. If you do, format FAT32.

17. Run “df” again. You should now see /dev/sdb1 mounted on /media/hd-sdb1.

18. First, let’s make a good spot for SABnzbd to dump stuff and link it to the default location. This will protect you from a problem with your OS drive overfilling if your storage drive goes AWOL.

mkdir /media/hd-sdb1/sabnzbd
rm -rf /opt/sabnzbd/Downloads/
ln -s /media/hd-sdb1/sabnzbd /opt/sabnzbd/Downloads
rm -rf /opt/sabnzbd/logs
ln -s /media/hd-sdb1/sabnzbd /opt/sabnzbd/logs

19. Feel free to change the log location for sickbeard to the storage drive as well. You can do it at:
http://192.168.1.107:8081/config/general/

20. You are ready to rock and roll. Configuring your Apps is dependant on the services you use. There are wonderful guides for these tasks at:
http://www.ainer.org/