Evolution of a Blog

This blog has evolved as I have as a maker. It starts at the beginning of my journey where I began to re-tread my tires in the useful lore of micro electronics and the open-source software that can drive them. While building solutions around micro-electronics are still an occasional topic my more recent focus has been on the 3D Printing side of making.

Monday, March 18, 2013

Arch Linux on the Raspberry Pi - Part 2

It took some fumbling around as I wanted to see if I could get Gnome to work but decided it either would not or would be just to hard.   I don't need it anyway!   So I asked Google what the best GUI was for Arch Linux on the RPi and he/she told me to install LXDE - Lightweight X11 Desktop Environment.  

I got the steps below from a great recipe provided by sudo!Xanthippe for an LXDE install. Here are the steps that we need condensed from his tutorial:

pacman -Syu
pacman -S xorg
pacman -S xorg-xinit xorg-twm xterm


At this point sudo!Xanthipp added a user but we have already done that in the previous post.

I also installed two different VNC servers, tightvnc and tigervnc but am not sure about either at this point.  Both seem to crash now and again and both need post installation customization that might be user error.

At this point I feel that I have a pretty good base image replicating most of what comes in Rasbian "Wheezy" (plus some essentials).   Given this I am going to start forking a couple different images.   One for the 'bot of course (that is the title of the blog after all) and another for my BirdCam / RodentCam / WaterFowlCam (that is actually getting more attention right now)

On to Part 3

Saturday, March 16, 2013

Arch Linux on the Raspberry Pi - Part 1

As part of diagnosing my camera issues (previous post) I decided to try an installation of Arch Linux on the RPi.    My first two observations are that it is a LOT more complicated than Wheezy.   My second observation is that it boots REALLY FAST.   I decided at that point that I needed to try it for the 'bot where speed matter.

Here is my install procedure (in multiple installments):

Log in to the system as root, password root, upgrade your base system and catalogs to current revision levels:
pacman -Syu

This is crucial for finding the later packages to be installed!   I ran this from the console as it takes a while.   Once this is done you can use dfconfig to find the ip address so you can ssh in from your normal workstation.

Now configure some base stuff starting with an ftp server first (and have it start automatically):

pacman -S proftpd
systemctl enable proftpd.service

Then let's add the pi user:
useradd -m -g users -G \
audio,lp,optical,storage,video,wheel,games,power,scanner,ftp \
-s /bin/bash pi
passwd pi

Install sudo so we can use pi rather than root and maybe save our selves some future pain:
pacman -S sudo

Now run visudo and add pi with all rights.   Escape : x to save the file.
##
## User privilege specification
##
root ALL=(ALL) ALL
pi ALL=(ALL) ALL

Now for the wireless network to auto start.   First install the network configuration tool:

pacman -S netcfg

Edit /etc/conf.d/netcfg as shown below (using your names of course!):

# Network profiles are found in /etc/network.d
NETWORKS=("ethernet-eth0" "wlan0-Daysleeper")

# Specify the name of your wired interface for net-auto-wired
WIRED_INTERFACE=("ethernet-eth0")

# Specify the name of your wireless interface for net-auto-wireless
#WIRELESS_INTERFACE=("wlan0-Daysleeper")

Create a network profile (in my case wlan0-Daysleeper) in /etc/network.d:
CONNECTION='wireless'
DESCRIPTION='Automatically generated profile by wifi-menu'
INTERFACE='wlan0'
SECURITY='wpa'
ESSID=Daysleeper
IP='dhcp'
KEY=Password

As you can see, this profile was generated by wifi-menu which is part of the netcfg package and can be run as "sudo wifi-menu wlan0" to build a profile for a wireless network.

Now make sure that the network configuration we have just created starts automagically:
sudo systemctl enable netcfg

More at https://wiki.archlinux.org/index.php/Netcfg#Net-Profiles

Time for a backup.   More to come as I continue to build an Arch Linux image to replace my current Wheezy image that runs the 'Bot.

On to Part 2

Friday, March 15, 2013

Backups Revisited

One of my early posts talked about doing backups of the RPi SD card.   At least part of that post was crap so I thought I would revisit with an explanation of what I am doing now which is simply to use dd.

I take my backups of both partitions of the SD card using the inverse of the restore commands shown below.

A restore is then done to an SD card formatted to the same specifications as the backup (assuming it is not the original).

For SD cards that I use for testing I am using 4gb cards as they backup and restore faster.   I might get some 2gb cards for that matter!

Restore commands:

    sudo dd bs=4M if=2013-08-03-base-image-1.img of=/dev/sdc1
    sudo dd bs=4M if=2013-08-03-base-image-2.img of=/dev/sdc2

RPi as a Remote Control for a Canon DSLR - Part 1

In the quest to play with more gadgets, and to get better image quality for my birdcam, I am going to try and integrate my Canon 500D with a Raspberry Pi.   The RPi will provide a wireless remote capable of motion detection and also for populating a web server with captured images.

I am going to base this on gphoto2 with the help of a Python binding that I found here.  The first step is to get gphoto2 working on the RPi in it's command line state.  Then I will download the Python binding and see if it works.

So, first, here is a condensed version of the build process from the various bits and bobs that I found across the above (and other) sources:
  1. Download the tarballs for libgphoto2 and gphoto2 from the gphoto2 website and expand them on the RPi.
  2. Install the precursor software that you will need automake, autoconf, gettext, (pkgconfig, make on Arch) for the builds
  3. The following should also be installed:      libusb-1.0-0-dev, libexif-dev, libpopt-dev, libfuse-dev, mono-devel, monodoc-base, mono-gmcs, python-pyrex, libtool, [libusb on Arch].
  4. Build libgphoto2 (./configure --prefix=/usr/local, make, sudo make install).  There are switches that will allow you to pick cameras to include.   If you just take the default for all cameras you can have a cup of tea during the make step!
  5. Now install the precursor software that you will need for the build of gphoto2 (assuming you are want the client even though most folks can not seem to get it to work (more later on my work around)!   Note that libpopt-dev, which is needed to the build here, was not found on Arch Linux?
  6. And build it (autoreconf -is, ./configure, make,  sudo make install).  Note that the instructions for building from the tarball did not say that you needed to do the autoreconf but I found it necessary.
  7. But...don't go and try and run gphoto2 unless you want to get this error message: "gphoto2: error while loading shared libraries: libgphoto2.so.6: cannot open shared object file: No such file or directory".   Edit /etc/ld.so.conf and add the line "/usr/local/lib" then run ldconfig as root.
  8. At this point you should be able to run "gphoto2 --auto-detect" and have it find your camera, or, "gphoto2 --capture-image-and-download" to take a picture.
I got through all of the above and then got an error doing a capture that I believe is due to the infamous RPi USB issues discussed at length on the Raspbery Pi Forums.

There are some references to possible work arounds on the web so I am going to do  some investigation.

Here are apt-get command lines for the precursor needs on wheezy:
sudo apt-get install -y automake autoconf gettext
sudo apt-get install -y automake autoconf  gettext libusb-1.0-0-dev libexif-dev libpopt-dev libfuse-dev mono-devel monodoc-base mono-gmcs python-pyrex libtool

Monday, March 4, 2013

Distracted! AGAIN!

Am still chasing the instability I mentioned in an earlier post and frankly it is not as much fun as trying new things.   This time it is setting up a Raspberry Pi as a webcam located in our bedroom and looking out at the Thames.   We just bought our place at the end of last year and much of our view of the river is sheltered during the summer by a big willow.   Last week the willow got a haircut and we now have an onobstructed view of the river from the 1st floor.   Hence the need for a webcam to bring this view down to my study!

I have struggled a little with getting one of the webcam solutions to work on my RPi.   I did finally get motion to work following the instructions here.  Unfortunately I can only seem to get a low resolution (320x240) to work.   Will update this post as I make progress.

Solved my resolution issue with the help of the RPi Forum and user Gomoto in particular.   As an aside I have to say how impressive the RPi Forum is in terms of the rapidity and quality of responses to a post.   In any case, here is a link to the solution.  Note this only applies to Python captures and does not seem to work for command line applications.

With resolution now working I was able to get my motion sensitive BirdCam to take these photos:


The motion detection in these photos is provided by a simple function that calculates the mean differences between two images (absdiff from opencv).   Given the simplicity of my requirement it works pretty well.   I do have to adjust for the threshold at which point I declare the motion to be interesting but it weeds out most of the chaff from wind movement and changing light.

I am still distracted by this line of interest.   In my next post I will describe the integration of the above technology with an SLR in the pursuit of improved image quality.

Sunday, February 24, 2013

Chasing a 'Bot Instability

My 'Bot has developed a bit of emotional instability.   Or instability anyway.   It runs for a while and then without fail loses it's network connection.   It seems to have started with the introduction of the LCD...but...the LCD is connected to the Arduino not the RPi!   I have also added another GPIO function but the network crash seems to happen with or without the GPIO functioning.

I have started a series of tests to try to narrow down the source of the problem.  So far I have tried running with and without the GPIO functionality and with and without the LCD functionality.   I have also let the RPi run without my Python code but with the camera and some other processes running.   In the former two cases we had a failure in the latter we were stable.

Friday, February 22, 2013

Robot Kill Switch - GPIO

Now that the robot starts auto magically it seemed like it would be a nice idea to have a way to abort that auto start or to stop the robot...without a terminal or web session.  Since I have already exposed the GPIO bus it was easy to implement this desire.  

The picture shows the hardware.   The push button is wired to pin 14 of the GPIO bus (blue wire).  A 10k resistor connects that lead to ground (brown wire).   The 3v power supply is connected to the other side of the push button.  If the button is depressed during start-up the 'Bot will abort prior to starting any of it's modules.   If it is pressed any time while the 'Bot is running it will shutdown cleanly.

Here is the code for the abort of start-up:
# *****
# Abort startup if the kill switch is pressed
# *****
GPIO.setmode(GPIO.BCM)
GPIO.setup(intercom["pins"]["startRobot"], GPIO.IN)
GPIO.setwarnings(False)
if GPIO.input(intercom["pins"]["startRobot"]):
    logger.critical("Aborting startup - kill switch pressed")
    sys.exit(1)