Monday, July 7, 2014

Using Raspberry Pi with a Digital Projector in a Teach For India classroom

I am a TeachForIndia fellow now and have been teaching at a low income school in Pune. The school is named Kilbil Public School (kilbil is Marathi for "chattering") and I teach Maths and Geography to 3 classes of 7th Graders. We are a team of 3 TFI Fellows, the other two teach English, Science and History/Civics. We have a facebook page here. The first thing I did is to ask all of my close friend to contribute money to help me buy a digital projector. The idea was that if we are  to use Inquiry-based learning for Geography, History/Civics and Science, we would need to hook the students attention by showing them images and youtube videos. So here's what I got for my setup:

Hardware:

  1. BenQ MS521p DLP Projector with HDMI Input and Analog Stereo output. This cost Rs. 30,000 from Flipkart. My friends contributed hard cash (and Flipkart vouchers - which cannot be bought using international credit cards) for this. Recently I have ordered another projector, so now the two new BenQ projectors together with an existing old one will allow us to deliver awesome instructions simultaneously all three section of 7th grade. The projector decodes the digital audio stream from HDMI and makes it available as analog audio for feeding it into speakers.
  2. Raspberry Pi with case - I had this one lying around. I was scared that I would end up breaking my laptop if I carried it to school everyday. So I thought of using a Raspberry Pi in the classroom instead to play MP4 videos downloaded from YouTube and to teach my kids programming using Scratch
  3. SanDisk SD Card (16Gb 45 MB/s) - I had been using this with my DSLR, I figured that I could put it to better use with my RPi since I was anyway using my Nexus 5 to take photos of my kids instead of the DSLR.
  4. Logitech MK220 Wireless Keyboard and Mouse Combo - I had bought this long ago for general use with my laptop or RPi. Available from Flipkart.
  5. Netgear Wireless USB Micro WNA1000M - USB WiFi Dongle for use with RPi. Buy from Flipkart. This was so that I could access internet using my cellphone as a WiFi hotspot.
  6. HP Stereo Speakers S3000 bought from Croma for Rs. 899, they are available for less here on Flipkart. These can be powered from USB
  7. Nextech Dual USB Charger from Croma for powering the RPi and Speakers simultaneously
  8. A really thin and short HDMI Cable to connect the RPi to the projector
  9. A Micro USB Cable for powering the RPi
  10. A powerstrip to act as an extension board with its short cable replaced with a longer one.
  11. A Square Bucket and Mug to carry everything in - the convenience of carrying things in a bucket cannot be stressed enough!


The dual port charger. This charger has a Europlug.
I needed to create an extension wire which was equal in length to
the power cable of the projector.
See image below.
I used cable ties to tie the charger to the projector power cable.
The extension wire made for the dual port charger made it convenient
to twist the two wires around each other.
Now days you get powerstrip with USB ports builtin for
charging personal communication devices.
If you can get your hands on one of these then perhaps you may
not need a separate dual port USB charger for powering the speakers and the RPi.
Just make sure that the built in charger of the powerstrip is able
to provide enough current to the Speakers and RPi.


The backside of BenQ MS521p projector.
The wires going into it are: power cable for powering the projector,
3.5mm stereo lead from speakers and the thin HDMI cable from the Raspberry Pi.

The speakers

Raspberry Pi with the Logitech wireless mouse next to it.
The wires attached to the RPi are the mircoUSB cable for powering it
and the HDMI cable which goes to the projector.

RPi with the SD card containing Raspbian OS

RPi with the wireless mouse and keyboard


The final setup. Note how I have twisted the cables around each other
so that only three bunches of cable are coming out of the projector.
And this is how I carry the hardware to school everyday.
In a square bucket.
Its makes it easy to carry all the stuff to school and back.
And it takes under a minute to setup or store (no zips to open like in a bag).


Software:
  1. Raspbian as OS for RPi - Download the SD card image from here and write the image to the SD Card
  2. Youtube Downloader HD for Windows - Help you download MP4 versions of videos from youtube. Get from here.
  3. Paragon ExtFS for Windows - When you prepare an SD card for RPi by writing the Raspbian image to it, the card cannot be read by Windows because the card uses the ext3/ext4 files system. This software will allow you to read files from and copy files to the Raspbian SD card from within Windows. Make sure to copy your MP4 files to /home/pi folder. This software is essential in two scenarios - 1) when you do not have any USB port left because the two that RPi has have been used up and so you cannot connect a FAT32 formatted USB flash drive containing the Youtube videos. 2) RPi might not be able to provide enough power via the USB port and it might hang when you do connect a USB flash drive. So its just better to copy the videos to the SD card instead of playing them from a FAT32 formatted USB flash drive. (FAT32 flash drive can be read to and written from Windows as well as Linux). You can play MP4 and videos in other format using omxplayer. Issue the command at the terminal: "omxplayer /home/pi/abc.mp4" 

Issues:
  1. HDMI settings - To make the Raspberry Pi's audio behave properly with BenQ MS521p projector, you will need to make a minor change in \boot\config.txt. You need to uncomment (remove the #) the line hdmi_drive=2. More details here. The BenQ projector will decode the audio from HDMI and make the analog stream available via the 3.5mm stereo jack marked "Audio Out" on its back side. Edit the config.txt file on Raspberry Pi itself using the nano editor. Issue the command 
  2. USB Extension for Logitech Wireless Receiver - Raspberry Pi has two USB port. If you stick a WiFi USB dongle in one and the keyboard receiver dongle in another (these are very close to each other), the WiFi dongle's signals will interfere with the keyboard receiver and the keyboard and mouse will no longer work. To prevent this, just use a USB extension cable with the keyboard receiver to create some distance between the two dongles.
What doesn't work: inserting the Keyboard receiver dongle next to the
WiFi dongle will prevent it from receiving signals

What works: use a short extension cable to move the keyboard
receiver dongle away from the WiFi Dongle




How the setup looks like in the class.
The image is being projected onto a blackboard.
You actually do not need a white screen.

So I realized that I could optimize the setup time even further if
mounted everything on a piece of plywood and carry it as it is to school.
This would also prevent breakage because now all the cables are tucked
away safely and there is no way any kid would trip on it.
And the kids would be more than happy to carry the whole thing
between their class and my car - helps build ownership towards their own classroom.

Improvements:

  1. OMX Remote - Its an android app that can control the OMX Player instance on your Raspberry Pi if both - the phone as well as Raspberry Pi  are connected to the same WiFi