Thursday, 18 July 2013

Python Arduino DAQ on the Mac

Kevin Hughes created a basic DAQ system in python to read Arduino analog voltages and display them on screen. He told me it should be platform independent, so I decided to try it on my mac. Steps to getting there [including mistakes where I slipped up]:

Get the arduino sketch running. This was simple, although I dropped the serial data rate to 57600 because that works with all the other stuff in my ecosystem.

[This was probably a huge mistake, as it looks like many libraries only work with python 2.7. Restored machine state and started again. Install python 3.3.2 for the mac, because that's the latest. After the install I still got python 2.7.2 from a terminal command line, even after a restart, but 'python3' gets 3.3.2.]

Serial Communications

Rely on the installed python 2.7.2 on the mac and install pySerial using Adafruit tutorial.

tar -xzf pyserial-2.6.tar.gz
cd pyserial-2.6
sudo python setup.py install

I confirmed pyserial was functioning by creating serialTst.py

import time
import serial

ser = serial.Serial('/dev/tty.usbmodemfa13131', 57600)

while True:
    message = ser.readline()
    print(message)
    time.sleep(0.5)

and it echoed output being written by the Arduino with Serial.println.

matplotlib

[The packaged matplotlib doesn't seem to work with the Apple release of Python. (matplotlib-1.2.1-py2.7-python.org-macosx10.6.dmg) from http://matplotlib.org/downloads.html gives an error saying "matplotlib 1.2.1 can't be installed on this disk. matplotlib requires System Python 2.7 to install.]

Following http://penandpants.com/2012/02/24/install-python/ (or maybe better http://penandpants.com/install-python/ and some of http://www.tapir.caltech.edu/~dtsang/python.html) provided alternatives after installing the xcode command line tools:

ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
brew doctor

brew install pkg-config
brew install freetype
brew install libpng

sudo easy_install pip
sudo pip install matplotlib

The matplotlib install produced a huge number of warnings, but reported successful installation at the end.

wxPython

Install wxPython (wxPython2.8-osx-unicode-py2.7) from http://wxpython.org/download.php. To get the install to work you need to allow installs from anywhere in system settings. see http://trac.wxwidgets.org/ticket/14523 and http://www.toolfarm.com/blog/entry/installing_osx_10.8_mountain_lion_please_read

Continuing

After all that installing, serialTst.py still works. Got the Arduino running Kevin's ArduinoDAQ on a fresh port tty.usbmodemfa13141. Changed the port in daq.py  and ran, but it fails on loading wxPython 2.8 with no 64 bit environment. wxPython 2.9 claims to be OK with both 32 and 64 bit, so I installed it and then python daq.py runs!

It generates repeating warnings if the Arduino environment is still running, but quitting it and rerunning python daq.py works great.


Tuesday, 4 June 2013

Things I wish I knew about python and the WebIDE right away...

Python is interpreted, so you need to feed your source code to the interpreter program, typically with a command like python MyProgram.py. or you can just run python then start typing in commands the same as they would appear in your code. It takes me back to the bad old days of MS/BASIC. Alternately, if the first line in the .py file is #!/usr/bin/env python and you have changed the mode of the .py file to allow execution (chmod +x MyProgram.py) then you can run the file directly by name.

Indentation defines extent the way {} do in C, so whitespace matters.

The first thing you need to do is import the libraries you want to use in your code:

import sys
import RPi.GPIO as GPIO

imports the whole sys library, imports the RPi.GPIO library but lets you refer to it as GPIO for function calls like GPIO.setup(RST, GPIO.OUT)

from time import sleep

just imports the sleep function from the time library. Python finds all of these somewhere in the system libraries by following the path. You can add to the path like this:

sys.path.append("/home/pi/Examples")

so that

import Nokia.RWSpypcd8544 as nokia

will find the code in /home/pi/Examples/Nokia/RWSpypcd8544.py as long as /home/pi/Examples/Nokia/__init__.py also exists, even if it is empty. The code in the init file will run before importing the code from the named file. Note the use of a period rather than a slash. Now you can call things from RWSpypcd8544 with function calls like nokia.showFlower().

Running a WebIDE python program on system boot


It's pretty straightforward to use the WebIDE to write and run python programs from a web connection. Once those programs are working, you might want to run one of them automatically when the Pi starts up. /etc/rc.local is a script that will run as the final part of the boot sequence, so you can add a command to this script. The command I added was

sudo /usr/share/adafruit/webide/repositories/my-pi-projects/BlinkButtons/flashyNokia.py &

to run the program in background. Running it with sudo is required to give full access to the hardware features. To make the script run you will need to

sudo chmod +x /etc/rc.local

in order to make rc.local executable. You'll also have to run chmod +x against the .py file created by the IDE. You only need to do all of this once, even when you modify the program in the IDE.

Tuesday, 16 April 2013

Same Desktop on HDMI and VNC

I wanted to have my Pi connected to a big HDMI TV on the other side of the room and control the desktop from a VNC window on another computer. It took me quite a while to find out how to do this, so I'm repeating it here. The secret was to use x11vnc instead of the tightvncserver I started off with. Install it, then store a password as the user you want to have access and it will be in ~/.vnc/passwd

sudo apt-get install x11vnc

x11vnc -storepasswd

Start the GUI on the HDMI first then run the x11vnc from the command line as the same user (either on the main desktop or remotely via ssh).


x11vnc -rfbauth ~/.vnc/passwd -display :0

Then run a VNC client like Real VNC and log in remotely on port :0.

Interestingly enough, it looks like x11vnc runs right alongside tightvncserver, allowing me to have one VNC window on port :0 (x11vnc) going to the HDMI desktop and another on port :1 (tightvncserver) with a new, independent desktop.

Wednesday, 13 March 2013

Occidentalis WiFi Drop Problems

Further Update: A full installation based on 2013-02-09-wheezy-raspbian.img with samba, apache, Adafruit webIDE, etc. recovers from a network outage seamlessly both over a wired connection and wireless. Problem Solved!

Update: Ran blink with a 2013-02-09 Raspbian unmodified and the wireless was able to recover from a wireless drop. Ran rwspi with the Occidentalis distro updated as previously described and it doesn't recover from a wireless drop, but it recovers OK from a disconnected wired net connection on eth0, showing much the same sequence in the log -- thus the problem is wireless related.

The pi's lose their network connections when the wireless glitches and they fail to get it back. This has been happening every few days, apparently at random with the pi's attached to the Bell modem/router/wifi. I'm trying to figure out why. So now a test:

blink on BELL989 with keyboard and mouse and hdmi and ssh from imac
rwspi on BELL989 headless and ssh from imac
macbook on BELL989
imac on cable

depower and repower BELL989 at approx 17:06

The macbook shows loss of network at 17:05:49 and reconnection with no intervention by 17:07:03. The log looks nothing like the pi logs.

blink loses the connection at 17:05:52 then redetects the link beat by 17:06:43, but everything has run its course by then. /var/run/wpa_supplicant still exists as the directory created by root at boot time back at 13:11. The log looks just like the previous failures. Deleted the wpa_supplicant and the ifplugd.action script ran, but found no DHCP offers -- ran it again and it failed with the wpa_supplicant error again.


Mar 13 17:01:17 blink dbus[2195]: [system] Successfully activated service 'org.freedesktop.ConsoleKit'
Mar 13 17:05:52 blink ifplugd(wlan0)[1600]: Link beat lost.
Mar 13 17:06:03 blink ifplugd(wlan0)[1600]: Executing '/etc/ifplugd/ifplugd.action wlan0 down'.
Mar 13 17:06:03 blink dhclient: Internet Systems Consortium DHCP Client 4.2.2
Mar 13 17:06:03 blink ifplugd(wlan0)[1600]: client: Internet Systems Consortium DHCP Client 4.2.2
Mar 13 17:06:03 blink dhclient: Copyright 2004-2011 Internet Systems Consortium.
Mar 13 17:06:03 blink ifplugd(wlan0)[1600]: client: Copyright 2004-2011 Internet Systems Consortium.
Mar 13 17:06:03 blink dhclient: All rights reserved.
Mar 13 17:06:03 blink ifplugd(wlan0)[1600]: client: All rights reserved.
Mar 13 17:06:03 blink dhclient: For info, please visit https://www.isc.org/software/dhcp/
Mar 13 17:06:03 blink ifplugd(wlan0)[1600]: client: For info, please visit https://www.isc.org/software/dhcp/
Mar 13 17:06:04 blink dhclient: 
Mar 13 17:06:04 blink dhclient: Listening on LPF/wlan0/48:02:2a:6c:41:1b
Mar 13 17:06:04 blink ifplugd(wlan0)[1600]: client: Listening on LPF/wlan0/48:02:2a:6c:41:1b
Mar 13 17:06:04 blink dhclient: Sending on   LPF/wlan0/48:02:2a:6c:41:1b
Mar 13 17:06:04 blink ifplugd(wlan0)[1600]: client: Sending on   LPF/wlan0/48:02:2a:6c:41:1b
Mar 13 17:06:04 blink dhclient: Sending on   Socket/fallback
Mar 13 17:06:04 blink ifplugd(wlan0)[1600]: client: Sending on   Socket/fallback
Mar 13 17:06:04 blink dhclient: DHCPRELEASE on wlan0 to 192.168.2.1 port 67
Mar 13 17:06:04 blink ifplugd(wlan0)[1600]: client: DHCPRELEASE on wlan0 to 192.168.2.1 port 67
Mar 13 17:06:04 blink dhclient: suspect value in host_name option - discarded
Mar 13 17:06:04 blink ifplugd(wlan0)[1600]: client: suspect value in host_name option - discarded
Mar 13 17:06:04 blink ifplugd(wlan0)[1600]: client: Reloading /etc/samba/smb.conf: smbd only.
Mar 13 17:06:04 blink avahi-daemon[2222]: Withdrawing address record for 192.168.2.27 on wlan0.
Mar 13 17:06:04 blink avahi-daemon[2222]: Leaving mDNS multicast group on interface wlan0.IPv4 with address 192.168.2.27.
Mar 13 17:06:04 blink avahi-daemon[2222]: Interface wlan0.IPv4 no longer relevant for mDNS.
Mar 13 17:06:04 blink ifplugd(wlan0)[1600]: Program executed successfully.
Mar 13 17:06:06 blink ntpd[2747]: Deleting interface #2 wlan0, 192.168.2.27#123, interface stats: received=312, sent=316, dropped=0, active_time=10144 secs
Mar 13 17:06:06 blink ntpd[2747]: 216.194.70.2 interface 192.168.2.27 -> (none)
Mar 13 17:06:06 blink ntpd[2747]: 192.95.20.208 interface 192.168.2.27 -> (none)
Mar 13 17:06:06 blink ntpd[2747]: 199.85.124.148 interface 192.168.2.27 -> (none)
Mar 13 17:06:06 blink ntpd[2747]: 192.75.12.11 interface 192.168.2.27 -> (none)
Mar 13 17:06:06 blink ntpd[2747]: peers refreshed
Mar 13 17:06:38 blink ifplugd(wlan0)[1600]: Link beat detected.
Mar 13 17:06:38 blink ifplugd(wlan0)[1600]: Executing '/etc/ifplugd/ifplugd.action wlan0 up'.
Mar 13 17:06:39 blink ifplugd(wlan0)[1600]: client: ioctl[SIOCSIWAP]: Operation not permitted
Mar 13 17:06:39 blink ifplugd(wlan0)[1600]: client: ioctl[SIOCSIWENCODEEXT]: Invalid argument
Mar 13 17:06:39 blink ifplugd(wlan0)[1600]: client: ioctl[SIOCSIWENCODEEXT]: Invalid argument
Mar 13 17:06:40 blink ifplugd(wlan0)[1600]: client: ioctl[SIOCSIWAP]: Operation not permitted
Mar 13 17:06:41 blink ifplugd(wlan0)[1600]: client: rfkill: Cannot open RFKILL control device
Mar 13 17:06:41 blink ifplugd(wlan0)[1600]: client: ctrl_iface exists and seems to be in use - cannot override it
Mar 13 17:06:41 blink ifplugd(wlan0)[1600]: client: Delete '/var/run/wpa_supplicant/wlan0' manually if it is not used anymore
Mar 13 17:06:41 blink ifplugd(wlan0)[1600]: client: Failed to initialize control interface '/var/run/wpa_supplicant'.
Mar 13 17:06:41 blink ifplugd(wlan0)[1600]: client: You may have another wpa_supplicant process already running or the file was
Mar 13 17:06:41 blink ifplugd(wlan0)[1600]: client: left by an unclean termination of wpa_supplicant in which case you will need
Mar 13 17:06:41 blink ifplugd(wlan0)[1600]: client: to manually remove this file before starting wpa_supplicant again.
Mar 13 17:06:41 blink ifplugd(wlan0)[1600]: client: Failed to bring up wlan0.
Mar 13 17:06:41 blink ifplugd(wlan0)[1600]: Program executed successfully.
Mar 13 17:06:42 blink ifplugd(wlan0)[1600]: Link beat lost.
Mar 13 17:06:43 blink ifplugd(wlan0)[1600]: Link beat detected.


sudo /etc/init.d/networking restart didn't work. Tried with stop and then start, but that didn't connect either. In each case the activity looked just like when it's booting, except it didn't get the DHCP offer. I wonder if it has to do with some of the network services like samba, the web ide and apache not getting shutdown?


Mar 13 17:36:13 blink ifplugd(wlan0)[1600]: Link beat lost.
Mar 13 17:36:19 blink ifplugd(wlan0)[1600]: Link beat detected.
Mar 13 17:36:31 blink ifplugd(wlan0)[1600]: Link beat lost.
Mar 13 17:36:34 blink ifplugd(wlan0)[1600]: Link beat detected.
Mar 13 17:36:47 blink ifplugd(wlan0)[1600]: Link beat lost.
Mar 13 17:36:51 blink ifplugd(wlan0)[1600]: Link beat detected.
Mar 13 17:37:03 blink ifplugd(wlan0)[1600]: Link beat lost.
Mar 13 17:37:06 blink ifplugd(wlan0)[1600]: Link beat detected.
Mar 13 17:37:17 blink dhclient: Internet Systems Consortium DHCP Client 4.2.2
Mar 13 17:37:17 blink dhclient: Copyright 2004-2011 Internet Systems Consortium.
Mar 13 17:37:17 blink dhclient: All rights reserved.
Mar 13 17:37:17 blink dhclient: For info, please visit https://www.isc.org/software/dhcp/
Mar 13 17:37:17 blink dhclient: 
Mar 13 17:37:18 blink ifplugd(wlan0)[1600]: Link beat lost.
Mar 13 17:37:18 blink dhclient: Listening on LPF/wlan0/48:02:2a:6c:41:1b
Mar 13 17:37:18 blink dhclient: Sending on   LPF/wlan0/48:02:2a:6c:41:1b
Mar 13 17:37:18 blink dhclient: Sending on   Socket/fallback
Mar 13 17:37:18 blink dhclient: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 6
Mar 13 17:37:19 blink ifplugd(wlan0)[1600]: Link beat detected.
Mar 13 17:37:24 blink dhclient: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 10
Mar 13 17:37:31 blink ifplugd(wlan0)[1600]: Link beat lost.
Mar 13 17:37:34 blink ifplugd(wlan0)[1600]: Link beat detected.
Mar 13 17:37:34 blink dhclient: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 21
Mar 13 17:37:46 blink ifplugd(wlan0)[1600]: Link beat lost.
Mar 13 17:37:48 blink ifplugd(wlan0)[1600]: Link beat detected.
Mar 13 17:37:55 blink dhclient: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 16
Mar 13 17:38:01 blink ifplugd(wlan0)[1600]: Link beat lost.
Mar 13 17:38:02 blink ifplugd(wlan0)[1600]: Link beat detected.
Mar 13 17:38:11 blink dhclient: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 8
Mar 13 17:38:15 blink ifplugd(wlan0)[1600]: Link beat lost.
Mar 13 17:38:18 blink ifplugd(wlan0)[1600]: Link beat detected.
Mar 13 17:38:20 blink dhclient: No DHCPOFFERS received.
Mar 13 17:38:20 blink dhclient: Unable to obtain a lease on first try.  Exiting.
Mar 13 17:38:31 blink ifplugd(wlan0)[1600]: Link beat lost.
Mar 13 17:38:34 blink ifplugd(wlan0)[1600]: Link beat detected.
Mar 13 17:38:47 blink ifplugd(wlan0)[1600]: Link beat lost.
Mar 13 17:38:50 blink ifplugd(wlan0)[1600]: Link beat detected.


rwspi loses the connection and is incognito.


Mar 13 17:05:52 rwspi ifplugd(wlan0)[1495]: Link beat lost.
Mar 13 17:06:02 rwspi ifplugd(wlan0)[1495]: Executing '/etc/ifplugd/ifplugd.action wlan0 down'.
Mar 13 17:06:02 rwspi dhclient: Internet Systems Consortium DHCP Client 4.2.2
Mar 13 17:06:02 rwspi ifplugd(wlan0)[1495]: client: Internet Systems Consortium DHCP Client 4.2.2
Mar 13 17:06:02 rwspi dhclient: Copyright 2004-2011 Internet Systems Consortium.
Mar 13 17:06:02 rwspi ifplugd(wlan0)[1495]: client: Copyright 2004-2011 Internet Systems Consortium.
Mar 13 17:06:02 rwspi dhclient: All rights reserved.
Mar 13 17:06:02 rwspi ifplugd(wlan0)[1495]: client: All rights reserved.
Mar 13 17:06:02 rwspi dhclient: For info, please visit https://www.isc.org/software/dhcp/
Mar 13 17:06:02 rwspi ifplugd(wlan0)[1495]: client: For info, please visit https://www.isc.org/software/dhcp/
Mar 13 17:06:02 rwspi dhclient: 
Mar 13 17:06:02 rwspi dhclient: Listening on LPF/wlan0/00:e0:4c:10:47:f1
Mar 13 17:06:02 rwspi ifplugd(wlan0)[1495]: client: Listening on LPF/wlan0/00:e0:4c:10:47:f1
Mar 13 17:06:02 rwspi dhclient: Sending on   LPF/wlan0/00:e0:4c:10:47:f1
Mar 13 17:06:02 rwspi ifplugd(wlan0)[1495]: client: Sending on   LPF/wlan0/00:e0:4c:10:47:f1
Mar 13 17:06:02 rwspi dhclient: Sending on   Socket/fallback
Mar 13 17:06:02 rwspi ifplugd(wlan0)[1495]: client: Sending on   Socket/fallback
Mar 13 17:06:02 rwspi dhclient: DHCPRELEASE on wlan0 to 192.168.2.1 port 67
Mar 13 17:06:02 rwspi ifplugd(wlan0)[1495]: client: DHCPRELEASE on wlan0 to 192.168.2.1 port 67
Mar 13 17:06:03 rwspi ifplugd(wlan0)[1495]: client: Reloading /etc/samba/smb.conf: smbd only.
Mar 13 17:06:03 rwspi avahi-daemon[2071]: Withdrawing address record for 192.168.2.24 on wlan0.
Mar 13 17:06:03 rwspi avahi-daemon[2071]: Leaving mDNS multicast group on interface wlan0.IPv4 with address 192.168.2.24.
Mar 13 17:06:03 rwspi avahi-daemon[2071]: Interface wlan0.IPv4 no longer relevant for mDNS.
Mar 13 17:06:03 rwspi ifplugd(wlan0)[1495]: Program executed successfully.
Mar 13 17:06:05 rwspi ntpd[2801]: Deleting interface #2 wlan0, 192.168.2.24#123, interface stats: received=896, sent=904, dropped=0, active_time=152721 secs
Mar 13 17:06:05 rwspi ntpd[2801]: 208.79.216.225 interface 192.168.2.24 -> (none)
Mar 13 17:06:05 rwspi ntpd[2801]: 192.75.12.10 interface 192.168.2.24 -> (none)
Mar 13 17:06:05 rwspi ntpd[2801]: 199.19.167.36 interface 192.168.2.24 -> (none)
Mar 13 17:06:05 rwspi ntpd[2801]: 142.4.209.106 interface 192.168.2.24 -> (none)
Mar 13 17:06:05 rwspi ntpd[2801]: peers refreshed
Mar 13 17:06:45 rwspi ifplugd(wlan0)[1495]: Link beat detected.
Mar 13 17:06:45 rwspi ifplugd(wlan0)[1495]: Executing '/etc/ifplugd/ifplugd.action wlan0 up'.
Mar 13 17:06:45 rwspi ifplugd(wlan0)[1495]: client: ioctl[SIOCSIWAP]: Operation not permitted
Mar 13 17:06:45 rwspi ifplugd(wlan0)[1495]: client: ioctl[SIOCSIWENCODEEXT]: Invalid argument
Mar 13 17:06:45 rwspi ifplugd(wlan0)[1495]: client: ioctl[SIOCSIWENCODEEXT]: Invalid argument
Mar 13 17:06:45 rwspi ifplugd(wlan0)[1495]: client: ioctl[SIOCSIWAP]: Operation not permitted
Mar 13 17:06:45 rwspi ifplugd(wlan0)[1495]: client: rfkill: Cannot open RFKILL control device
Mar 13 17:06:45 rwspi ifplugd(wlan0)[1495]: client: ctrl_iface exists and seems to be in use - cannot override it
Mar 13 17:06:45 rwspi ifplugd(wlan0)[1495]: client: Delete '/var/run/wpa_supplicant/wlan0' manually if it is not used anymore
Mar 13 17:06:45 rwspi ifplugd(wlan0)[1495]: client: Failed to initialize control interface '/var/run/wpa_supplicant'.
Mar 13 17:06:45 rwspi ifplugd(wlan0)[1495]: client: You may have another wpa_supplicant process already running or the file was
Mar 13 17:06:45 rwspi ifplugd(wlan0)[1495]: client: left by an unclean termination of wpa_supplicant in which case you will need
Mar 13 17:06:45 rwspi ifplugd(wlan0)[1495]: client: to manually remove this file before starting wpa_supplicant again.
Mar 13 17:06:45 rwspi ifplugd(wlan0)[1495]: client: Failed to bring up wlan0.
Mar 13 17:06:45 rwspi ifplugd(wlan0)[1495]: Program executed successfully.
Mar 13 17:06:46 rwspi ifplugd(wlan0)[1495]: Link beat lost.
Mar 13 17:06:47 rwspi ifplugd(wlan0)[1495]: Link beat detected.


http://bradfortner.wordpress.com/2013/01/03/how-i-set-up-my-raspberry-pi-lesson-3-demystifing-wi-fi-setup-for-my-raspberry-pi/ doesn't cover it, but points out some useful commands.


sudo ifup wlan0 – wakes up wireless interface at wlan0
iwconfig – shows connected network interfaces

More about startup

man init
/etc/rc?.d
/etc/profile.d
/var/log/syslog

Monday, 11 March 2013

Thermocouple breath sensor

Somebody asked on G+ about sensing the breath that would blow out candles. I took up the challenge and figured I would try with a thermocouple, as the wire is cheap! A two junction system senses the difference in temperature between the two ends, requires no excitation voltage, but produces an output less than a millivolt, so major amplification is required.


This video shows the performance with the the thermocouple run through 2 AD 8221 instrumentation amps like I used for the load cells, each with gain set around 1000, so the output is saturating. The voltage will be low if the left junction is warmer and high if the right one is warmer.

Tuesday, 19 February 2013

Adafruit Web IDE

Update: With the IDE installed on two separate pi using the same bit bucket account it seems to share the source code back and forth OK as long as you don't try to use both of them at the same time.

Having tried the manual instructions and failed (see below), I checked the "easy install" shell script and found it had provisions to use port 3000 if port 80 was already in use (e.g. by apache) so I just ran:

curl https://raw.github.com/adafruit/Adafruit-WebIDE/alpha/scripts/install.sh | sudo sh


[verbosity...]
**** Create webide user and group ****
**** Adding webide user to sudoers ****
/etc/sudoers.tmp: parsed OK
/etc/sudoers.d/README: parsed OK
**** Adding default .bashrc file for webide user ****
**** Installing the WebIDE as a service ****
**** (to uninstall service, execute: 'sudo update-rc.d -f adafruit-webide.sh remove') ****
update-rc.d: using dependency based boot sequencing
OK
**** WARNING: PORT 80 IN USE. FALLING BACK TO 3000. ****
**** TO CHOOSE A DIFFERENT PORT USE THE FOLLOWING COMMAND: ****
**** redis-cli HMSET server port 3000 ****
**** AND RESTART THE SERVER ****
**** Starting the server...(please wait) ****
**** The Adafruit WebIDE is installed and running! ****
**** Commands: sudo service adafruit-webide.sh {start,stop,restart} ****
**** Navigate to http://rwspi.local:3000 to use the WebIDE

Then I created a bitbucket account for sellensr based on my google id. I created a couple of files, then did a reboot on the Pi. The apache server still works with rwspi.local and the webIDE with rwspi.local:3000. The files are stored at:

/usr/share/adafruit/webide/repositories

and belong to user and group webide, thus I can't copy files over to there as pi on a vnc file manager screen. Oddly the easy way to move files from ~/pi into the ide is to enable the samba share, then upload the files from the share through the IDE. Odd, but works really well.

I've been doing all this in Safari, which isn't explicitly supported, but seemed to be working OK until I left the IDE and some other stuff broke. Probably best to run the IDE in a supported Chrome window and other things in Safari.

Some of the assumptions I made about directory structure are no longer valid if I move .py files to the IDE, but that shouldn't be a surprise.

webide added itself to the /etc/sudoers file and takes over the hardware. As a result, www-data couldn't use the serial port until I put it back in the /etc/sudoers file.

Trying to do the manual version was a bad plan


Building New Pi Base Images

So what happens if I brick the rwspi SD card? I want to be able to get back to somewhere like where I was, and also to be able to help others get the the same place. So I set out to make a clean install with all the good stuff I've added to rwspi so far, and none of my mistakes or personal data. I got really vexed in the process, because I couldn't get the hardware to work the way it did the first time I set up. The wifi was not behaving. It looks like the upgraded firmware was somehow not working with the old Occidentalis distribution, which shouldn't be a surprise once you get to it. 

So I eventually followed these steps to make a clean image on a 4 GB SD. The wifi worked when it was done. The processing took several hours to complete processing, so I have saved the unpersonalized image as OcciGen130219.img and a personalized version as FreshPi130219.img with my networks and passwords in it. Part of the time was consumed by figuring out that the errors were a result of the Raspbian site being down this morning rather than anything I was doing.

Update: A different wifi adapter requires a reconfig from start, so I repeated the process to create blink130305.img that runs with the B-LINK all black USB wifi dongle.

Also created an OcciClean130304.img image with no wifi installed.

Started from 2013-02-09-wheezy-raspbian.img to create RaspiClean130323.img with all the services below, but no wifi, no wpa file edits. Had to run sudo apt-get install git-core before the firmware update would run properly. Initialized a new blink image from there and added wireless from config utility on desktop. Did the same for an rwspi image.

Feel free to step through the same process to build a copy. I'd share, but I don't have an easy way to share something that big without writing it to an SD.

# make the raw image on SD by running this on the mac (the rest is on the Pi)
# sudo dd bs=1m if=Occidentalis_v02.img of=/dev/rdisk2

# boot with net cable attached and use raspi-config to expand the file system
#      set the keyboard, timezone, enable ssh and desktop, then finish and reboot

# get the latest upgrades
sudo apt-get update
sudo apt-get upgrade

# get the latest firmware, then reboot (needs to be repeated for new Pis)
sudo wget https://raw.github.com/Hexxeh/rpi-update/master/rpi-update -O /usr/bin/rpi-update
sudo chmod +x /usr/bin/rpi-update
sudo rpi-update

# use raspi-config to update raspi-config, then set GPU split to 32 MB and reboot


# install samba for file sharing on the network
sudo apt-get update
sudo apt-get install samba
sudo apt-get install samba-common-bin
# set password as 'raspberry'
sudo smbpasswd -a pi
sudo nano /etc/samba/smb.conf
#   Uncomment or change these lines in /etc/samba/smb.conf
#   security = user
#   socket options = TCP_NODELAY
#   [homes]
#   readonly = no
#   valid users = pi


# install the tightvncserver if not already there

sudo apt-get install tightvncserver

# install the apache web server -- it will occupy port 80
sudo apt-get install apache2 php5 libapache2-mod-php5
# mysql password set to 'raspberry'
sudo apt-get install mysql-server mysql-client php5-mysql
sudo service apache2 restart
sudo nano /etc/inittab
# comment out the ttyAMA0 line at the end of /etc/inittab
# T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
# make tty devices available to the web server to use serial port
sudo adduser www-data tty


# install the Adafruit WebIDE -- it will go on port 3000 since 80 is taken
curl https://raw.github.com/adafruit/Adafruit-WebIDE/alpha/scripts/install.sh | sudo sh

# install some python -- some of this may be redundant
sudo apt-get install python-dev
sudo apt-get install python-rpi.gpio
sudo apt-get install python-smbus
sudo apt-get install i2c-tools
sudo apt-get install python-pip
sudo pip install feedparser
sudo easy_install -U distribute
sudo pip install RPi.GPIO
sudo apt-get install python-serial



# get the latest upgrades just to check all up to date
sudo apt-get update
sudo apt-get upgrade

# shutdown and back to the mac to run
# sudo dd if=/dev/rdisk2 of=OcciGen130219.img bs=1m
# then create a new SD with 
sudo dd bs=1m if=OcciGen130219.img of=/dev/rdisk2

# then back to the Pi and personalize the installation as freshpi.local
# network files copied from rwspi to work with 165 Bagot networks
sudo smbpasswd -a pi
sudo nano /etc/network/interfaces
sudo nano /etc/wpa_supplicant.conf
sudo nano /etc/hostname
sudo nano /etc/hosts
#reboot to be freshpi
passwd 
sudo passwd mysql
tightvncserver :1


# all works, so shutdown and back to the mac to run
# sudo dd if=/dev/rdisk2 of=FreshPi130219.img bs=1m