Using Prowl to Announce IP Address of Raspberry Pi on iOS

Prowl on iOSIf you use your Raspberry Pi without a keyboard and monitor, you know how frustrating it can be to use it without knowing it’s IP address. By default, the Raspberry Pi is configured to use DHCP to obtain an IP address. This is great for moving the unit around to different networks but can be annoying when you want SSH to the unit. Typically you can use the zero-config/Bonjour “raspberrypi.local” address but this doesn’t always work. I’ve instead come up with a way to use Prowl to notify me of the current IP address after it boots. As a bonus it works with either an Ethernet or WiFi (or both) connection.

Prowl is a Growl push notification service for iOS. It costs $3 and is available from the iTunes App Store.

1. The first step is to download and install Prowl and setup an account. Next, obtain an API key from Prowl. Copy the API key– you’ll need to insert it into a script below.

2. Next, create two files in your home directory (/home/pi/) called prowl.sh and prowlip.sh. Insert the API key into prowl.sh as shown.


File: prowl.sh from koma5 on github.

#! /bin/sh
# Usage: ./prowl.sh priority(-2 to 2) app event description
# Example: ./prowl.sh 0 "transmission" "torrent has finished" "Coen Brothers Compilation has finised downloading"
app=$2
priority=$1
event=$3
description=$4
apikey=PASTE_YOUR_HEXADECIMAL_API_KEY_HERE

if [ $# -ne 4 ]; then
echo "Usage: ./prowl.sh priority(-2 to 2) app event description"
echo 'Example: ./prowl.sh 0 "transmission" "torrent has finished" "Coen Brothers Compilation has finised downloading"'
else
curl https://prowl.weks.net/publicapi/add -F apikey=$apikey -F priority=$priority -F application="$app" -F event="$event" -F description="$description"
fi


File: prowlip.sh with apologies to original author.

#!/bin/sh

eth=`ifconfig eth0 | awk -F':' '/inet addr/&&!/127.0.0.1/{split($2,_," ");print _[1]}'`
wlan=`ifconfig wlan0 | awk -F':' '/inet addr/&&!/127.0.0.1/{split($2,_," ");print _[1]}'`

if [ "x$eth" = "x" ]; then
eth=""
# Variable is empty
else
eth="eth0: $eth "
fi

if [ "x$wlan" = "x" ]; then
wlan=""
# Variable is empty
else
wlan="wlan0: $wlan"
fi

/home/pi/prowl.sh 0 "Raspberry Pi" "IP Address" "$eth$wlan"


3. Set both files to executable by typing

chmod 755 prowl.sh prowlip.sh

4. Add this line to /etc/rc.local before the “exit 0” line. This will execute the script at startup.

/home/pi/prowlip.sh

5. Reboot your Raspberry Pi and you should receive a push notification from Prowl on your iOS device with the current IP address(s).

Raspberry Pi And A Personal Weather Station

Ambient Weather WS-1090 and Raspberry PiI’ve had the Ambient Weather WS-1090 personal weather station for about a year and it’s worked well. It has a base station receiver that wirelessly receives the data from the sensors outside. The unit stores about 5 days worth of data but goes no further. It would be nice to be able to archive this data and also have real time data accessible from outside the home. It has a USB port and includes software but I’m not keen on keeping a PC on 24/7 just for that mundane task.

Enter the Raspberry Pi, a $35 credit-card sized computer that runs a variant of Debian Linux with HDMI, USB and Ethernet ports built in. A quick search revealed that Peter Mount has done all of the hard work already in a part 1 and part 2 tutorial. The tutorials are excellent, well written and unlike most Linux projects I try, there were no errors. I used a 4GB SD card that I had laying around and began with the Raspbian “wheezy” image from 2012-08-16. I expanded the partition to fill the card and enabled SSH so I could do the work from another machine.

I’m now pushing data every 5 minutes to Weather Underground were it automatically builds historical graphs of the weather from the PWS. I still need to get a proper solar radiation shield for the temperature sensor as it tends to read much warmer on sunny days.