Pi Filling

So I’ve been very lucky early this year to attend the Raspberry Pi and Google collaborated PiAcadamy training.  I’m now a certified RaspberryPi educator!. You may be sayings so what is that about?

Well firstly a little background. I’ve been involved for the last four years helping out as a mentor at several Coderdojo events, where I’ve looked after a ever growing collection of Raspberry Pi.

This has been very rewarding, seeing youngsters of all levels discovering computing in the form I grow up with (ie a blank canvas, where you write the game/ program). But I have a real passion for physical compete interaction, I don’t just want to sit in front of a mouse/keyboard/joy pad, I want to wire stuff up and build things.

Playing with computers and electronics has been the key to success in so much of my life, and I want others who maybe like minded, more practical than just academic, to experience this learning journey.

Enough background, so hows pi academy helped?

Well thanks to a great team in pi towers and many of the other pi educators, there are lots of resources out in the wild, which I’ve spent time digesting, but what I was in need of some structure. 

Following the structures the pi academy team went through and more importantly working with teachers as well as fellow volunteers has helped. Both from a confidence and technique point of view.  I especially liked the concepts of not being afraid to not get things working and a project orientated learning methodology.

Although I’m still on a journey, when it comes to implanting what I’ve learned, I have found a renewed level of confidence. I specifically tuck a holiday from work a last month to help out at pi and codebug robot orchestra schools workshop. Which I really enjoyed, and was encouraged by.
I also have lots of new projects in mind for the two regular CoderDojo groups I help with. So watch this slow to be updated blog space!

Voice My IP : Headless Raspberry Pi

A little while ago someone showed me how their Raspberry Pi emailed them the DHCP assigned IP address, which is really useful for when running headless in a environment where you have no control over DHCP.  Now there are some alternatives, including running a Apple Zeroconf specification (like Bonjour), by installing “avahi-daemon”, but you need support on your client machine, which  needs a agent installing or other apple software (on Windows).

The main problem I had with the email method, is that unless you can find a open email relay (not a good idea), you need to include your email password (I’m sure with a little more time I find away of securing this, or using some kind of token).  So this set me thinking of what other presentation methods I could use to extract the IP address on boot.  Here are some of my ideas (If you search the web you’ll probably find these are not original) :

  • Take control of the Power LED and flash it according to the IP address.
  • Post the IP address to a website
  • Plug in a Serial cable into the pi to get a console and just read the IP
  • Connect a Display of some kind
  • Read the IP address out of the audio jack

If you search the web you should find the info on controlling the Power LED, which I did consider this a good approach, but I finally settled on using the Audio out via some headphones.

Here is how I did it:-

  1. Create a python script that reads the IP address:-
    • I made sure the audio player “aplay” is installed and working (Make sure the audio is set to come out the audio jack!)
    • Then I recorded a wav file for each number 0 – 9 and the decimal, ie 0.wav, 1.wav .. point.wav (had a little fun getting my Windows machine to record the right format; to to write raw wav)
    • Then  I wrote the following python to get and read the IP address (note I read the address used by the Ethernet port, as wireless would need you to connect to a access point first, but will work once the wireless config is established use ‘wlan0’ instead)
      import socket
      import fcntl
      import struct
      import os
      Import time
      
      def get_ip_address(ifname):
          s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
          return socket.inet_ntoa(fcntl.ioctl(
              s.fileno(),
              0x8915,  # SIOCGIFADDR
              struct.pack('256s', ifname[:15])
          )[20:24])
      
      #print get_ip_address('eth0')
      myip = get_ip_address('eth0')
      
      #myip = '10.10.100.32' # test
      
      
      for i in myip:
              time.sleep(1)
              if i == '1':
                      os.system('aplay /home/pi/readmyip/1.wav')
              elif i == '2':
                      os.system('aplay /home/pi/readmyip/2.wav')
              elif i == '3':
                      os.system('aplay /home/pi/readmyip/3.wav')
              elif i == '4':
                      os.system('aplay /home/pi/readmyip/4.wav')
              elif i == '5':
                      os.system('aplay /home/pi/readmyip/5.wav')
              elif i == '6':
                      os.system('aplay /home/pi/readmyip/6.wav')
              elif i == '7':
                      os.system('aplay /home/pi/readmyip/7.wav')
              elif i == '8':
                      os.system('aplay /home/pi/readmyip/8.wav')
              elif i == '9':
                      os.system('aplay /home/pi/readmyip/9.wav')
              elif i == '0':
                      os.system('aplay /home/pi/readmyip/0.wav')
              elif i == '.':
                      os.system('aplay /home/pi/readmyip/point.w$
  2.  Call the Script at boot
    • Add the following to  “/etc/rc.local” file that which calls the  python script on boot.
      sudo python /<Python Script location>/<Python Script Name>.py
  3.  Connect your headphones and restart your Pi.

You can refine this a little, especially if the Pi doesn’t get a IP address.

Raspberry Pi 2 B (next gen)

So now I have another even more powerful sub £25 computer with a connector desperate to be plugged into, what should I do with it?

Well first I had to circumvent RaspberryPi.org struggling website to download the latest NOOBS sdcard image.

So what next….

IMG_20150204_122531

The pi on right is the new pi 2 B.

Just found out my pibow case doesn’t fit :(Network chip is a fraction lower than the old one, so gets caught on the case)