This is how to build the mealtime announcer. The name is after the phrase: "Dinner-is-in-the-Dog". It was originally built as a birthday gift for my father. 0. This uses is an original model B Raspi (256M RAM, rev1). No heatsink fitted. Base = Raspberry Rock (for display). Extra hardware: BLISO board (http://circuitsurgery.com/raspberrypi/bliso.html) [As it only uses 1 USB port, and no ethernet (except for initial setup), a Model A would also work.] NB, use a good PSU and cable, AND bypass all 3 of the polyfuses. Otherwise, the WiFi is really unreliable, and we sometimes get SD card read failures. After doing the bypass, don't hotplug USB devices, as it causes a brownout/reboot. Ensure that the middle link on the BLISO is set for the LED rather than the button. [I soldered mine, rather than using a jumper, because there isn't enough vertical height under the lid of the Raspberry Rock.] 1. Install 2013-07-26-wheezy-raspbian.img, on 8GB uSD card. [Updated: 2015-11-21-raspbian-jessie-lite.img ] 2. On first-bootup, when prompted by the Pi: expand filesystem. Set a password. No boot to desktop. Hostname "raspberry". GPU = 32M. No Overclock (it's unneeded, and we otherwise have SD-card corruption issues sometimes (though this may be polyfuse related). Enable ssh. [Note my password is in passwd.txt, not distributed in the online howto, for obvious reasons!]. [2015 Update: Jessie Lite already has ssh enabled] 3. Copy over ssh key. Apt-get update/upgrade. Set up .bashrc and ~/.inputrc to taste. Install molly-guard. 4. Install wiringpi and wiringpi-python as follows: apt-get install git python-dev python-setuptools git clone git://git.drogon.net/wiringPi ;cd wiringPi ;git pull origin ; ./build git clone https://github.com/WiringPi/WiringPi-Python.git ; cd WiringPi-Python ; git submodule update --init ; sudo python setup.py install Basics: gpio -v; gpio readall Output: gpio -g mode 0 output ; gpio -g write 0 1; gpio -g write 0 0 #for the leftmost LED. Beep: GPIO 21 is the sounder: gpio -g mode 21 clock ; gpio -g clock 21 4000; sleep 0.2; gpio -g mode 21 out #experimentally, the frequency is limited to 4600-18000 - why? PWM led: gpio -g mode 18 pwm; gpio -g pwm 18 512 #0-1023 Write bliso.sh to do some various things. Note that gpio is rather slow taking about 10ms per edge. Mostly this is the process-startup overhead. Examples: time for i in `seq 1 500`; do gpio -g write 4 0; gpio -g write 4 1; done => 10.9s => 10.9ms per edge (mostly process overhead) gpio export 4 out time for i in `seq 1 500`; do echo 1 > /sys/class/gpio/gpio4/value; echo 0 > /sys/class/gpio/gpio4/value; done => 0.41s => 0.41ms per gpio edge. (note that echo is a bash builtin) gpio export 4 out time for i in `seq 1 500`; do /bin/echo 1 > /sys/class/gpio/gpio4/value; /bin/echo 0 > /sys/class/gpio/gpio4/value; done => 9.3s => 9.3ms per gpio edge. (/bin/echo is much slower) 6. Install PHP: apt-get install apache2 php5 libapache2-mod-php5 fping 7. Network. Put this in /etc/network/interfaces: (note that this IS sufficient to configure wpa-supplicant for Wifi, obviously substituting the correct network name and WPA passphrase.), 2013 Original: --- BEGIN: /etc/network/interfaces --- auto lo iface lo inet loopback iface eth0 inet dhcp auto wlan0 allow-hotplug wlan0 iface wlan0 inet dhcp wpa-ssid "OUR_SSID_GOES_HERE" wpa-psk "OUR_WPA2_KEY_GOES_HERE" --- END --- 2015 Updated: according to this: http://raspberrypi.stackexchange.com/questions/10251/prepare-sd-card-for-wifi-on-headless-pi --- BEGIN: /etc/network/interfaces --- auto lo iface lo inet loopback allow-hotplug eth0 iface eth0 inet dhcp allow-hotplug wlan0 iface wlan0 inet manual wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf post-up ifdown eth0 iface default inet dhcp --- END --- --- BEGIN: /etc/wpa_supplicant/wpa_supplicant.conf --- ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 network={ ssid="OUR_SSID_HERE" psk="OUR_WPA2_KEY_HERE" id_str="wifi-n-usb" } --- END --- Note the MAC addresses (ifconfig -a). This particular Pi has: ethernet: HWaddr b8:27:eb:de:1e:53 wlan: HWaddr 00:e0:4c:00:3b:3b We'll need to be able to access the WLan remotely,therefore it needs a DNS entry and repeatably allocated IP. So configure the DHCP server (or Wifi access point) to allocate a reserved/fixed IP, corresponding to the DNS address, of "raspberry". The WiFi Dongle I'm using is an EDUP, identified by lsusb as: Bus 001 Device 004: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter It's not hugely reliable. One suggestion is to disable power management thus: http://www.xbmchub.com/forums/raspberry-pi-discussion/8037-your-wifi-dongle-dropping-connection-mainly-edimax-ew-7811un.html echo "options 8192cu rtw_power_mgnt=0 rtw_enusbss=0" > /etc/modprobe.d/8192cu.conf Check that power-management is off (after restart): cat /sys/module/8192cu/parameters/rtw_power_mgnt [Note that shorting the polyfuses has helped a lot now, most raspi hardware problems are related to power-supply issues, either the PSU itself, the cable, or the polyfuses.] 8. Install the dinnerdog program. This is a matter of installing the files into bin and creating symlinks for Apache in the desired directory: Download the tarball from: http://richardneill.org/src/dinnerdog/dinnerdog.tgz Old way: The files in bin are to be copied into ~/bin. chmod +x. Delete /var/www/index.html (so .php takes priority). Symlink: ln -sf /home/pi/bin/index.php /var/www/index.php; ln -sf /home/pi/bin/images /var/www/images [Note that the webroot for Apache used to be /var/www ] New way: Extract the tarball. cd into the dinnerdog directory. Then use the Makefile: "sudo make install" #to reverse this, do "sudo make uninstall." Delete /var/www/html/index.html (so .php takes priority). Symlink: ln -sf /usr/local/dinnerdog/bin/{index.php,images} /var/www/html/ [Note that the webroot for Apache is now /var/www/html ] 9. Crontab, for automatic start at boot (as the pi user, the command is "crontab -e"): Manually: @reboot /home/pi/bin/bliso.sh init2 @reboot /home/pi/bin/checknetwork.sh Automatically: already done this by "make install" (but the files are in /usr/local/dinnerdog/bin/ and the crontab is /etc/crond.d/dinnerdog)) 10. To use: Setup on network (WiFi, DNS, DHCPD) browse to "raspberry". (if necessary, use IP address, or connect to http://raspberry - the http:// is sometimes explicitly required, or some browsers will wrongly interpret "raspberry" as "raspberry.com"). Click the button. Or, click the bottom-left of the bliso buttons to shut down. Or, click the bottom-right of the bliso buttons to reboot. 11. Resilience: To make it at least a little more resilient against being powered off suddenly, make the filesystem mount synchronously: edit /etc/fstab, and change the mount options to include "data=journal,sync" for the "/" directory. BUT... data=journal prevents it from booting properly (we get the error: "EXT4-fs (mmcblk0p2): Cannot change data mode on remount"). See: https://www.raspberrypi.org/forums/viewtopic.php?t=51742&p=398987 The solution is to avoid the data=journal option in fstab (do keep the sync though), and instead, run: tune2fs -O has_journal /dev/mmcblk0p2 (then reboot) 12. To do in future: - The Raspi *really* doesn't like it when it is non-gracefully shut-down - even if idling, it seems to corrupt the SD card's filesystem. Having the BLiSo's buttons used for graceful shutdown helps, but users still treat the device like an appliance to be simply unplugged when not needed (and there are sometimes power-failures). The solution is to make it read-only (tmpfs and unionfs), according to these: http://blog.pi3g.com/2014/04/make-raspbian-system-read-omly/ http://raspberrypi.stackexchange.com/questions/5112/running-on-read-only-sd-card See also: http://raspberrypi.stackexchange.com/questions/28214/safest-way-to-switch-off-uncleanly http://raspberrypi.stackexchange.com/questions/4719/how-to-shut-down-rpi-when-running-headless/4722#4722 http://serverfault.com/questions/356507/safe-ext4-configuration-for-systems-running-unattended - It would be nice to have a lower pitch. But 4000 Hz seems to be the minimum supported by GPIO. Also, possibly some more imaginative LED flashing patterns. - It might be useful to lock to somehow prevent contention between multiple instances of bliso. (especially in 5 minute countdown mode). [The current workaround isn't perfect]. - bliso.sh has trouble flashing all the LEDs together (each LED needs a new process of gpio, which takes ~ 5ms). It would be faster to avoid the new process overhead, by using echo > /sys/class/gpio/... (echo is a bash builtin). - We could make the onboard green SD-card/"OK" LED act as a heartbeat etc: http://www.raspberrypi.org/phpBB3/viewtopic.php?f=31&t=12530 - It would be nice if we could perfect the vertical spacing of the buttons in the web interface, for multiple screen-sizes. - JS GUI - would be an improvement if multiple presses of the buttons didn't leave competing JS timers running. - Improve the Makefile to automatically install in appropriate Apache subdirectory. We may not want to stomp over an existing main index.html. Should we (a) install in /var/www/html/ (b) install in /var/www/html/dinnerdog (c) leave this to the user? 13. Note that the Glyphish icons included here may be redistributed freely (as in beer), but are not GPL. See 00-readme-license.txt for the details.