close-circle
Close
0%
0%

Prometheus Alarm Clock

Possessing both the mysterious old, and the pinnacle of cutting edge, Prometheus is the ultimate alarm clock!

Similar projects worth following
close
This project is a software based alarm clock that will display time using nixie cathode tubes, can wake you up either guns blazing (via any speaker system) or silently (bed shaker). Finally, there is a web server that runs on the Pi that replaces the clunky hardware buttons we are used to to set the alarm, and instead, we can set the alarm through a web UI.

More information is on Github, and I am always happy to help you set up a similar system.

The idea was to have a clock that does everything. The 3 main things I want to integrate in this project are:

1) Connect the clock to a bed shaker so my alarm clock can wake me up discretely without waking up my roommate, but also the ability to wake me up in a super noisy fashion by playing an alarm tone through my speaker system for when I really need to wake up.

2) A way to set the alarm via my phone, iPad, or Browser through a polished and intuitive web-interface controller.

3) Display time using nixie cathode tubes displays.

Implementation

hberg32 has already successfully implemented some of the code as well as the hard wiring for a similar project of his. My project however, will add a full RESTful web server as the control mechanism for the alarm clock, JSON files to store the configuration of the alarms, and a nixie cathode tube clock to display the time.

Merciless Pi Alarm Clock

Web Server

The control interface is implemented via a Express-Node web server running on the Raspberry Pi which can be accessed through the intranet (Although if routed correctly and a login mechanism is implemented, there is no reason this cannot be done as a public site). Node serves a simple HTML page as the Graphical User Interface which contains a snooze button, a upload form to change the alarm sound (any mp3 or m4a file will work), and 4 independently controlled alarms (with options for sound and or vibration). Next, as a primitive database of sorts, I used 4 JSON files which hold the data for the 4 alarms, a time JSON file that gets updated once a minute with the most current time, and a snooze JSON file which gets modified when the user presses the snooze button in the web site. Finally, we have Javascript file (mainly to modify the HTML to match the values saved in the JSON files when the page is initially loaded), and a Stylesheet file (to make everything nice and pretty). (In my Github repository, it can be found found under source/webinterface/) At the point the HTML document loads, the Javascript file hotswaps the values of the various headings and forms to match those stored in the JSON files. In addition, when a form is filled out and submitted, the Node backend will update the JSON files with the new submitted information.

Mockup of Web Interface

Hardware Control Program

The hardware control portion of the clock was implemented in Python 3. The program completely event driven, and uses a library called Pyinotifyer to check for when write/close happens to 3 types of files:

1) Alarm Information

2) Snooze

3) Time

time.json gets updated automatically every minute, and when the program detects this file was changed, it checks to see if any of the alarms share the same time with the current time. If they do not, then nothing happens. If they do, then run the alarm based on the configuration of the alarm configuration. (sound, sound + vibration, or vibration)

If any of the alarm files were modified, then the program would modify the Alarms class variables to match the new information from the JSON files.

When snooze was modified, then the program would see which alarm is currently running, then turn it off, and set that same alarm to run 5 minute from when it was initially set.

The way the alarm plays sound is via the subprocess library, in which it executed the command line program "vlc-nox" to play the sound stored in the web server, and killed when the run alarm loop ended (either snooze it turned on, or the alarm itself is turned off). Next, the program ran the vibration by using the Raspberry Pi GPIO library. (More about that in the hardware implementation section)

Hardware Implementation

For nixie cathode display portion, I decided to purchase the NCS314 kit from GRA and AFCH of Ukraine. They post their source code to Github, and had a good track record of helping people with the software they wrote. Since I was concentrated on the alarm portion of the project, I decided I did not want to get bogged down in the complex details of how to construct...

Read more »

fzz - 6.35 kB - 03/23/2017 at 00:12

download-circle
Download

View all 12 components

  • Working hard to finalize Golang webserver/hardware controller

    Andrew Lee06/13/2017 at 15:28 0 comments

    The updated version of the software component of my project is on the dev branch of my github repository.

    Furthermore, I changed the name from Atomic Clock to Prometheus (due to the numerous inventors cup type events I applied to as Prometheus Clock Project).

    In this version, golang fully takes over the tasks of both the Node web server and the Python hardware controller. The reason I did this is on the previous project log, but to summarize, there are 2 main reasons: 1) golang is faster by a huge margin over python (due to it being statically compiled much like C or C++). Also, but having one executable, it makes it alot easier to package the program, and to set up boot time loading of the program and whatnot.

    Some added features:

    -Every input/button has been converted to ajax calls so that the page doesn't have to reload on the client side (Except the Snooze button [the virtual Nixie Clock at the top of the UI] since the calculation to add 10 minutes to the currently running alarm needs to be done on the server side anyways).

    -Using Vue.js to control the elements of the page much more efficiently (mainly vue-bind and vue-model calls to ensure that the client side only pulls the necessary data initially at load time, and the rest of the time, can recycle the already loaded elements in the vue instance). If you haven't checked out Vue, I highly recommend it. Its a solid front end framework without alot of baggage from 1.x, or a religious adherence to a specific type of application abstraction model.

    -One huge issue I was having was that for some reason, my IP (on the Pi) was getting reassigned every 2 months or so. And since I keep the clock right by my bed, it was a rather tedious task to connect my Pi to hardware display and input devices just to get the new IP. Hence, I implemented an email via smtp task to send the user an email notifying them of an IP change, and the address of that IP. Although the credentials for the sender is saved in plaintext in the main.go file, it is not a huge issue for me since it is a testing account I made specifically for this purpose.

    -Before, the server saved the file as "alarm.mp3" by default. Hence, the only compatible files were mp3 and m4a files that were correctly encoded. However, in the new program, I implemented a regex search to seek out the actual file name,. Hence, when an alarm sound plays, it is format agnostic, and can play most sounds (flac, wma, fla) since the sound player is implemented via the CVLC media player.

    Future fixes

    -Sound is still not working properly. If I hit snooze when sound is playing, the second alarm 10 minutes after does not play sound. This could be an issue regarding how I am calling CVLC and not killing the process thoroughly

    -I haven't not had enough time to test whether the IP emailing functionality will work (since this happens about once every 2 months). Will update when this becomes more clear

    Future Updates (additive, not fixes)

    -Created soldered PCB as well as running the programs on Pi Zero W. I want to use the money I received as part of Hackaday's Seed Funding to purchase the materials to make this a single component electronic system rather than a myriad of sub-components strung together by a breadboard.

    -Incorporate a voltage regulator to be able to use the same power supply to power both the Pi, and the rest of the system.

    -Refractor golang code (At this point in time, I have no special training in golang, and wrote the entire thing using stackoverflow and the api reference (The entire thing is in one main.go file and its a huge mess to try to debug). I believe I can write much better (cleaner) code by learning golang in its entirety (as well as its philosophy on package hierarchies)

  • Reprogram the code in Golang

    Andrew Lee04/08/2017 at 19:22 0 comments

    Hey guys and gals!

    So in order to be able to play music on my speakers through my Pi, I am installing and running a program called Shairport-Sync (Github). It hosts a Airplay server on the Raspberry Pi, and allows the playback of music via the network interfaces on the Pi. (I dropped the idea of using Bluetooth since the technologies didn't play too well on my Raspberry Pi).

    However, then I started getting problems where my server wouldn't stay up for more than 24 hours. Initially, I thought it was my code (although today I figured out it was Shairport-Sync that was causing the issues since I was using the wireless interface to host both the UI for the clock and the Airplay server, and the server was preventing me from using any ssh/http/vnc services through whatever interface it was enabled for. Hence, the quick fix was to disable Shairport-Sync from using wireless connections and make it wired connection only, and now all wireless functionality is restored on my project while retaining the ability for me to play music via an ethernet cable. One caveat is that now I can't use SSH/VNC using a wired connection which is really unfortunate, but a worthy sacrifice)

    Hence, through this misunderstanding, I decided to recode this project in golang. First a background for those of you that don't know about golang. It's a statically compiled modern language invented and used by Google since 2007. And all I can say is that it is AWSOME! Being used to the idiosyncrasies of C++, I was under the impression that all languages that are fast require idiomatic and low level handling. However, golang really removes alot of the formalities associated with compiled languages, and natively supports concurrency, easy syntax, and garbage collection (memory management) built in.

    Hence, I was able to recode both the server functionality was well as about 80% of the hardware functionality in about a day!

    Although I am having some issues, these are probably from my lack of understanding of the language, and I believe in due time I will be able to complete the project.

    If you doubt the speed of golang versus a Python + Node.js setup, here are some benchmarks between the three languages.

    Golang vs Python 3

    Golang vs Node

    Although Golang and Node's performances are comparable (Golang is about 3x faster in most cases) the real kicker is how much faster Go is compared with Python 3 (for most tasks Go is 20x-100x faster than Python!!). Now node is actually also compiled at runtime (Node being another brainchild of Google), but Golang's real performance increases come from the fact that it is compiled to machine code and uses native data types (much like C or C++) which is why an interpreted language like Python never had a chance!

    Furthermore, although my previous code was "good", it was using 2 different programs to do 1 thing. Hence, by combining the functionality into one program, there would also be a performance boost. (In my previous set up, I used JSON files as the intermediate communication medium between 2 programs. Currently, I am only using the JSON files to save the alarm states when the program closes).

    Although I am sure it is possible to write low level code to directly access the GPIO pins, to make my life a little easier, I utilized a package that creates GPIO structs that I can send High and Low commands to (corresponding to outputting true or false).

    Furthermore, I modified the UI to have separate post calls on each On/Off toggle (rather than having to submit all changes in the bottom of the page).

    Overall, I think this efficiency is a good thing (as it would allow me to use the limited computing resources of the Pi for other things on top of running the alarm clock).

  • Modified User Interface

    Andrew Lee03/24/2017 at 02:06 0 comments

    I modified the user interface quite a bit. The overall functionality remains the same, but I added a virtual Javascript clock by Čestmír Hýbl (http://cestmir.freeside.sk/projects/dhtml-nixie-display/) [as required, all the source code to run the clock is saved as is on both the Heroku server that the mockup code is running on as well as the Github repo, under /projectroot/source/webinterface/public/nixie/]

    I removed the standalone "snooze" button, and instead made the virtual nixie clock itself the snooze button. (more aesthetically pleasing, plus it makes sense that the largest button be the snooze button)

    Anyways, check out the new interface at https://atomicalarmui.herokuapp.com/

  • Project Complete

    Andrew Lee03/22/2017 at 23:34 0 comments

    Dear readers,

    If you have been following, thanks for patience through my hiatus through my busy school schedule. I took it upon myself to finish this project to a usable state with all the main components finished. In this usable "prototype," I have added most of the main features I wanted:

    1) usable web interface to control the clock

    2) program to selectively play sound on my soundsystem and or run the bed vibrator (via GPIO) based on the config files that I modified using the web interface

    3) Reliably keep time (via NTP rather than a hardware clock module)

    Hence, all these components are present and I can say that at least the alarm clock portion of the project is complete.

    There are some portions of the projects that I hope to update and work on in the future including:

    4) setting up the Pi as a Bluetooth Audio Receiver so it can both function as the Alarm driver as well as a Media Receiver so I don't have to manually switch inputs on my sound system

    5) Communicating with the NCS 314 Nixie Cathode Clock to receive accurate time from NTP rather than rely on hardware as well we being able to display alarm set/snooze/unset messages to have a hardware feedback system rather than just the web interface.

    I did not complete 4) because despite my efforts, setting up the Pi as a bluetooth audio receiver is combersome to say the least, and although I did get it to work (albeit temporarily), there was no consistent solution that would survive a system reboot, and all the libraries required to accomplish this (Bluez, A2DP, ALSA Audio Routing) do not work very well in harmony, and since I already have a standalone bluetooth audio receiver, I decided I will just merge the audio receiver audio out and the pi audio out into a single Mono stream using cables, then feed that single audio signal into my speakers.

    With 5, I am definitely interested in completing this, but the hardware implementation (written in C by GRA and AFCH from Ukraine) is very complex in itself, and until I have the chance to sit down and really dissect the internal structure of their logic, various call patterns, and what parts are event based and which parts are sequentially executed, I have no way to implement any type of communication between the Pi and the Nixie Clock. Furthermore, this is a minimal issue since the clock itself is pretty much self contained and even contains a hardware clock module that keeps the clock accuracy within a margin of a few minutes every month. Hence, although this is something I plan to do, I believe the clock runs fine without this since the alarm control/alarm running program is completely independent from the clock display mechanism.

    As an added todo, I think it would be cool to implement a virtual nixie cathode clock as the title of the web interface (possibly implemented in Javascript).

    But I just want to thank everyone who has helped me on this awsome project including Hberg32, AFCH, the amazing people at SonicAlert Alarms (from which I used the bed vibrator hardware) for their insights.

    Later today, I will post a video of running the Atom Alarm Clock so you can see what you can do with it.

    But with that, with much love, I am signing out. I hope so see you in my next project.


  • UI Portion of the Project Complete

    Andrew Lee11/27/2016 at 19:14 0 comments

    Happy Thanksgiving everyone!

    So over the course of this week (Since I had some time off from school), I finished the Web UI Portion of the Project.


    Here is a working model of the web server that will run on the Pi: WebUI

    It is a express node.js server that serves an html form file initially. Then the client side javascript modifies the values in the html form to match that of the 4 configuration JSON files. Then if the user submits the form with different values, the web server edits the JSON files, then reloads the page.

    Running on the iPad, the website looks like this:

    Read more about it here: Github For Atom Clock UI

    In other news, I have been steadily working on wiring up the components. I have figured out that I have everything I need, I just need to read more about the Ll293D motor driver (I've fried 3 already! LOL), which will be a struggle because hardware was never my strongsuite. However, I think I am close and I will update you guys as soon as I finish this part.

    Finally, Afch from GRA & AFCH Industries has been helping me modify their Arduino Sketch to include Serial USB communication functionality to display when an alarm is set, or unset. I will be incorporating this into my project, and will keep you guys updated as soon as I get working parts of it done.

    Thanks for staying tuned.

  • Got the standalone clock portion to work

    Andrew Lee11/17/2016 at 20:16 0 comments

    I just got the standalone clock portion to work. Now I need to find a way to use RPi to control the clock.

  • Nixie Clock Kit Finally Here!

    Andrew Lee11/15/2016 at 21:51 0 comments


    Hey guys! It's me Gilgamesh. I just got the main components of the Nixie Clock portion. I ordered the NCS314 Adruino Shield Nixie Clock kit from GRA & AFCH on ebay on October 29 of this year, and Just received it today. I also had to buy a Adruino board (I settled with ELEGOO's Arduino board because it was $10 cheaper than the "official" board and had very positive reviews) from Amazon, which arrived in 2 days (so you can imagine the anticipation I had for receiving the rest of the clock).


    The only issue I see is that the kit does not seem fully compatable with the board i bought and one of the screws does not screw on


    However, this is not so so much of an issue because I was able superglue the end of a ballpoint pen plastic core to the corner so all 4 corners of the clock had support.

    However, I have been trying to get a 12V 1A power source separately to power the Arduino board (which in turn, powers the clock), but got ripped off by an Amazon 3rd party vendor. (Note to my readers: Buying a component in the section labeled "Often bought together" does not always guarantee the product listed is a legit product, so please beware). However, Since the Bed vibrator must also be powered by a 12V 1A current, I plan to just use the same breadboard powering scheme that I will use to power the bed shaker in order to power the nixie clock as well.

    Overall, I am very satisfied with the Nixie Kit as well as the shipping time (it shipped all the way from Ukraine and it only too 2 weeks! The marvels of modern transportation never ceases to amaze me.)

  • Happy Halloween

    Andrew Lee10/29/2016 at 22:33 0 comments

    A few updates. I finally selected the Nixie Cathode clock set-up I will use for this project. I was looking around for some viable kits. I looked at prices, set-up, Arduino Compatibility (more on this later), and Serial communications capabilities. First, because I am on a college campus, I have limited access to hardcore-DIY hardware tools such as solders, power sources, and spare breadboards. Therefore, I needed something that would require minimum set up to start. At the same time, because I am programming the main clock in Python 3, it would be great if I could use Python to communicate various commands to the nixie clock from the RPi (such as updating the clock using NTP, or flashing the display to signify a successful alarm set).

    Next, I wanted to make sure the clock would be compatible with the Arduino specification. This is because I wanted to take advantage of a Python Library for the Raspberry Pi called NanPy. This library allows you utilize the Arduino controller as a "slave" via I2C. Or in other terms, this would allow me to run the nixie clock firmware directly on the Pi, and communicate the directions to the various components on the nixie clock it through serial usb > Arduino > nixie tube interfacing components > nixie tubes. This was necessary because I don't actually want to run a clock independent from my main clock program on the Pi. Using this method, the main clock program can directly modify the variables such as the display time, flashing the display, turning the clock nixie display on/off because the program is running on the Pi.


    I looked at many different clocks, and talked to their manufacturers Although I did not end up buying their product, I feel it is right to mention their names since they were so helpful in my journey to find the right clock. The first clock I was looking at was the Complete Nixie Clock Kit Bundle from PV Electronics based in the U.K. Pete from customer support was very helpful in helping me understand their product. Getting this, I would have to assemble everything scratch, and the only way to communicate the Pi with the clock would be to to "hack" the built in GPS signal, which was designed to take input from a GPS time module (sold by PV Electronics as well) which gave the clock information about location information.

    Next I looked at the kits sold by NixieShop.com. Petro the brand and shop owner was very helpful in getting me information on his clocks (and for anyone trying to work on a similar project as mine, his product is perfect as well). His clocks are pre-assembled and shipped as a complete product. Furthermore, NixieShop has a variety of products, and he has very high reviews on eBay. The clock provided everything I was looking for (Arduino compatibility, moddable firmware that could communicate via serial usb to the Pi). The only thing that made me switch to my final choice was price (But even that was only about a $30 difference, plus Petro's product all come with cases which mine does not).

    The final clock kit I looked at was GRA and AFCH's kits. Their NCS314 Shield Kit came with everything I was looking for, and also was basically a shield for the Arduino rather than a Arduino compatible kit. Furthermore, (unlike other models on the market) the model uses full static displaying mode rather than multiplexing mode (all digits light simultaneously rather than 1 by 1, which makes for easier variable programming). Next, I also appreciated that they uploaded their schematics and firmware openly on on Github. (https://github.com/afch) Finally, they sold the whole kit (minus the Arduino itself) for $90, which came out to be $110 including shipping which was a the biggest selling point for me. Buying the Arduino separately, the whole kit came out to be $140.


    In other news, I managed to draw up a basic implementation chart for the whole clock, which I will upload to the Github page.


    Happy Halloween everyone.

  • Connecting my Pi to WiFi

    Andrew Lee10/18/2016 at 07:01 0 comments

    Oh boy, it seems like I REALLY have to start from the basics. My school recently switched from their own custom ISP services to adopt the eduroam standard, which allows anyone from member universities to continue using their school login to have access to the secured WiFi of any other school while they are there.

    While I am sure this has many benefits, the school disabled ssh and VNC access on the Guest Accounts for security reasons, and I was therefore forced to configure my Pi to connect to eduroam.

    Although the school provided a shell script, which is supposed to automate PEM key authentication, setting up the wpa_supplicant and /etc/network/interfaces files, the shell script failed to set up my Pi to work with eduroam.

    Therefore, I spent all weekend discovering a solution to do connect the Pi to the Internet. If anyone else is having the same problem, I suggest going to the project github page, where I have posted detailed directions for how I got it to work.

    Although tedious, this was a great experience as it allowed me to dive into very Linux-y tools, concepts, and methodologies such as NetworkManager, PEM authentication, and different models of network encryption.

  • Added hberg32's Code to the Github Repo for the Project

    Andrew Lee10/12/2016 at 19:56 0 comments

    Check on Github for the source code by hberg32. His project has inspired mine, and I am definitely planning to use at least some of it.

    He compiled some of his Python into PYC files, so I need to figure out a way to decompile this so I can view the source.

View all 11 project logs

Enjoy this project?

Share

Discussions

hberg32 wrote 03/29/2017 at 23:36 point

Looks good man, congratulations!

  Are you sure? yes | no

Kuro wrote 11/14/2016 at 03:08 point

The divergence meter made me open this project page.

  Are you sure? yes | no

Andrew Lee wrote 11/27/2016 at 19:19 point

クロさんへ、ご投稿ありがとうございます。僕もSteins Gateをきっかけにニクシー管時計に興味を持ち始めました。僕が買ったモデルは実はSteins Gateのモデルを丸パクリした物のようです。(w) しかしニクシー以外にも色々計画済みなので質問があれば遠慮なく聞いてください。

  Are you sure? yes | no

Andrew Lee wrote 11/27/2016 at 19:22 point

(In case you aren't Japanese), Dear Kuro, thanks for the input. I too started to like Nixie Clock after I saw Steins Gate. It seems that the model I got is specifically modeled to look like the one on the show. However, there are other parts outside of the Nixie Clock, so feel free to ask me anything.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates