Previous blog posts for this project:




This post focuses mainly on the build of the enclosure (lots of pictures!), but starts off with installation of some software components to get the web application running.


Setting up the webserver

 

Install the "lighttpd" webserver on the pi:

 

pi@raspberrypi ~ $ sudo apt-get install lighttpd










 

Edit the configuration to enable CGI support with Perl:

 

pi@raspberrypi ~ $ sudo nano /etc/lighttpd/lighttpd.conf










 

server.modules = (
        "mod_access",
        "mod_alias",
        "mod_compress",
        "mod_redirect",
        "mod_cgi",
        "mod_rewrite",
)










 

$HTTP["url"] =~ "^/cgi-bin/" {
        cgi.assign = (
                ".pl" => "/usr/bin/perl" ,
                ".cgi" => "/usr/bin/perl" ,
        )
}










 

Create a test CGI script to verify the correct functioning of the webserver:

 

pi@raspberrypi ~ $ cd /var/www/
pi@raspberrypi /var/www $ mkdir cgi-bin
pi@raspberrypi /var/www $ cd cgi-bin/
pi@raspberrypi /var/www/cgi-bin $ sudo nano test.cgi










 

#!/usr/bin/perl

print "<html>";
print "<head>";
print "<title>A Simple Perl CGI</title>";
print "</head>";
print "<body>";
print "<h1>A Simple Perl CGI</h1>";
print "<p>Hello World</p>";
print "</body>";
print "</html>”;










 

pi@raspberrypi /var/www/cgi-bin $ sudo chmod +x test.cgi










 

Success! The test script works.

Screen Shot 2014-06-01 at 11.23.05.png

 

 

Web app development

 

I started development on the web application in charge of the configuration of the alarm clock.

To have something modern looking and compatible with mobile devices, I used Bootstrap and JQuery.

 

Screen Shot 2014-06-03 at 21.16.02.pngScreen Shot 2014-06-03 at 21.16.22.pngScreen Shot 2014-06-03 at 21.16.32.png

 

Using Perl and the iRail API, I am able to populate the web application with the required information.

 

Here's a test where a dropdown is populated with data retrieved via the API:

Screen Shot 2014-06-08 at 23.56.42.png

 

Enclosure progress

 

I made a lot of progress on the enclosure for my alarm clock.

 

In the last post, I had started cutting the parts of the enclosure. I cut grooves in the four sides in order to be able to add a back panel.

IMG_3741.JPGIMG_3743.JPG

Everything fitted properly, and the result was very clean looking.

IMG_3747.JPGIMG_3748.JPG

It was time to add the electronics to the enclosure. By using some PVC screws which were glued to the bottom panel, I was able to mount the Arduino and Raspberry Pi.

photo 1.JPGphoto 2.JPG

photo 3.JPGphoto 4.JPG

Adding the rest of the components, power connector and wifi USB dongle.

photo 1.JPGphoto 2.JPG

There was still some work to be done on the top panel. I had foreseen to use three buttons and wanted to integrate them in a clean way.

I recently purchased a CNC milling machine which makes use of a Dremel. This was an ideal case to test the CNC.

Screen Shot 2014-06-02 at 21.21.48.pngphoto 3.JPG

 

After milling the top panel, I sanded it a bit and inserted the buttons. I was very satisfied with the result!

photo 4.JPGphoto 5.JPG

In the dark, the unfinished alarm clock lights up like a Christmas tree:

  • blue light from the Arduino
  • red light from the Raspberry Pi
  • green light from the Wolfson audio card
  • white light from the illuminated pushbuttons

photo (4).JPG

 

Next post

 

As the enclosure is nearly finished (frontpanel remains) and most of the electronics are sorted, the next update will focus on the software.