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.
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.
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:
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.
Everything fitted properly, and the result was very clean looking.
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.
Adding the rest of the components, power connector and wifi USB dongle.
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.
After milling the top panel, I sanded it a bit and inserted the buttons. I was very satisfied with the result!
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
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.
Top Comments