Mar 022013
 

As a result of some discussion on the Raspberry Pi forums, I decided to make my Pi into a dock of sorts for my HTC Desire.

Rather than using WiFi to connect to the Pi, I ended up using USB so that it doesn’t have to rely on anything external.

First thing I had to do was add this line into /etc/network/interfaces

iface usb0 inet dhcp

This let my HTC Desire assign an IP address to the Pi when I activated USB Tethering.
Second thing was to activate USB tethering itself after I plugged the phone into the USB Dock that I had.
Once the phone was plugged in, and USB tethering activated, the phone got an IP address on the usb0 interface.
Running ifconfig usb0 gave me this –

usb0 Link encap:Ethernet HWaddr ee:21:82:8b:eb:d1
inet addr:192.168.42.144 Bcast:192.168.42.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:616 errors:0 dropped:1 overruns:0 frame:0
TX packets:422 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:220596 (215.4 KiB) TX bytes:58184 (56.8 KiB)

As you can see, it has the IP address of 192.168.42.144 which has been assigned by the Desire.
I have installed a VNC server on the HTC Desire which allowed me to access the screen of the Desire, and also allows me to use my keyboard to do typing on the Desire.

The VNC server I used was called Droid VNC Server. Unfortunately it needs a rooted phone, but I had already rooted my Desire so it was no problem for me.
Once the VNC server was started, I used tightvncviewer on my Pi to access the VNC server on the Desire, and as you can see in the picture above, it’s very viewable.
Responsiveness leaves a bit to be desired, but it’s usable enough as long as you’re not playing games.

Share
Feb 192013
 

Just finished my first video tutorial !

This will guide you from a fresh install of Raspbian Server Edition all the way through to getting snapshots in your email.

Would love to hear some feedback on this, positive or negative 🙂

Share
Feb 112013
 

A few months ago, the SD card socket on my original Raspberry Pi broke off to do an unfortunate smelting accident…No, not really. It was just dropped onto the SD card socket and snapped.

After some months of trying a few different fixes, I eventually gave up and bought a 512mb Raspberry Pi instead. But recently with some new ideas, I wanted another Pi to test out a few different things at once. Since I had a Pi lying around already, I decided to have another crack at fixing it.
I found a SD card socket that was almost a perfect fit for the Pi from Element 14 (SKU 2081361)

The old SD Card had already been de-soldered from my earlier attempts, so I just had to line up the pins and solder them down.

The end result came out like this –
SD Card Socket

There are 2 floating pins (on the left in the picture) that are used to detect whether the card is inserted, which are at the opposite end of where they should be, so I ended up just leaving them be, and on the Pi itself soldered the 2 pins that should have been connected there. This means that the Pi will always think that there’s a SD card inserted. Apart from those 2 pins, each and every other single pin lined up perfectly.

My soldering isn’t great so the SD card socket is a bit crooked, but the SD card still fits in beautifully in the case that I also purchased off Element 14.

After soldering, I inserted an SD card, and successfully booted up the Pi with the new SD card 😀

Share
Feb 102013
 

So, I figured out why wlan0 doesn’t get an IP address when hostapd starts up.
ifplugd messes about with the interfaces when they go up and down, so the simplest solution is to disable ifplugd for wlan0 !
in /etc/default/ifplugd, the default configuration is this

INTERFACES="auto"
HOTPLUG_INTERFACES="all"
ARGS="-q -f -u0 -d10 -w -I"
SUSPEND_ACTION="stop"

Simply changing it to this

INTERFACES="eth0"
HOTPLUG_INTERFACES="eth0"
ARGS="-q -f -u0 -d10 -w -I"
SUSPEND_ACTION="stop"

will ensure that wlan0 will not lose it’s static IP address that’s configured in /etc/network/interfaces when wlan0 goes up.

Share
Feb 102013
 

As a follow up this this post, the script that I used had a few issues running on the server that I was using it on.
For some reason, on my server, the http interface would randomly die on me and then the script would not be able to stop or start motion.

So I modified the old one to this one, but it necessitated some modifications to the startup script for motion as trying to start motion via a shell script did not work due to the paths used within the startup script.

In the startup script /etc/init.d/motion, the full path is not used for start-stop-daemon. This means that when motion is started from a shell script, the command start-stop-daemon is not found. To rectify this, add /sbin/ to all instances of start-stop-daemon. The following example shows one of the instances of start-stop-daemon. The example begins on line 50, and the start-stop-daemon command is the last line of the example.

case "$1" in
start)
if check_daemon_enabled ; then
if ! [ -d /var/run/motion ]; then
mkdir /var/run/motion
fi
chown motion:motion /var/run/motion

log_daemon_msg "Starting $DESC" "$NAME"
if /sbin/start-stop-daemon --start --oknodo --exec $DAEMON -b --chuid motion ; then

In the updated script, I have added a few checks to ensure that the http interface is still running, and if it isn’t the script will kill motion altogether, and then restart motion to get everything up and running again.

The updated script is below –

#!/bin/bash
PeopleAround=0
people=( 192.168.2.72 192.168.2.117 192.168.2.129 )

wget -o getlog -O /usr/scripts/status http://localhost:8080/0/detection/status
if [ -f /usr/scripts/status ]; then
echo "SettingMotion"
MotionStarted=`cat /usr/scripts/status | sed -e 's/<[^>]*>//g' | tail -n 3 | head -n -2`
else
echo "Status file not available"
echo "Attempting to start motion"
/etc/init.d/motion start
exit
fi

sleep 5

if [ -f /usr/scripts/status ]; then
echo Checking Size
StatusSize=$(stat -c%s /usr/scripts/status)
if [[ $StatusSize -eq 0 ]]; then
echo Size is zero
MotionStarted=`pidof motion | wc -l`
if [[ $MotionStarted -eq 1 ]]; then
echo Motion web interface failed. Restarting motion
killall -9 motion
echo "HTTP interface has failed. killing motion and restarting" | mail -s 'Motion killed'
/etc/init.d/motion restart
else
echo Motion not started.
echo Starting Motion
/etc/init.d/motion start
fi
fi
else
echo "Status file not available"
exit
fi

for ip in "${people[@]}"; do
PersonAround=`ping -c 1 $ip | grep '64 bytes' | wc -l`
if [[ PersonAround -eq 1 ]]; then
PeopleAround=1
break
fi
done

if [[ $PeopleAround -eq 1 ]]; then
if [[ "$MotionStarted" =~ "ACTIVE" ]]; then
wget -O /usr/scripts/pause http://127.0.0.1:8080/0/detection/pause
echo "People around, stopping motion" | mail -s 'Motion stopped'
echo "People around, stopping motion"
fi
else
if [[ "$MotionStarted" =~ "PAUSE" ]]; then
wget -O /usr/scripts/start http://127.0.0.1:8080/0/detection/start
echo "No One around, Starting motion" | mail -s 'Motion started'
echo "No One around, Starting motion"
fi
fi
if [ -e /usr/scripts/status ]; then
rm /usr/scripts/status
fi

Share