A few months ago, the idea settled in my head that I want to wake up not just with music, but with Internet radio. “Just buy an alarm clock that can do it,” I thought, and put the thought aside. When it came to shopping, I was very surprised at the fact that I could not find suitable models for sale.
Criteria for which I picked up the alarm:
- Be able to play internet radio as an alarm clock.
- Work on Wi-Fi (wpa2, “N” mode, it is desirable to be able to without wps).
- It is advisable to be able to show time and work like a clock.
- It is desirable to be able to customize via phone or computer.
')
I can not say that I demanded too much, because The only requirement was to play Internet radio, but all the devices I met were either too large, too expensive, or morally obsolete.
It is worth noting that in principle I did not consider using the phone as a music player in this scheme, I already had this experience and did not like it, all the more I wanted to separate these components. I initially did not intend to keep this player near the bed, where the phone is charging, but I wanted to move it away to eliminate the possibility of turning off the alarm in sleep state.
I discussed with my friends the problems of the market for modern alarm clocks, they suggested that I need to use any microcomputer for this business. The idea was good, because with a small box with Linux on board, I’m guaranteed to be able to get this device to play any Internet radio on any speakers in the house, and the questions of its configuration are a matter of technology.
Foxconn Banana Pi
When choosing a microcomputer, I was guided by the Raspberry Pi, but I didn’t refuse from its analogs, which now appear quite a lot. This is how Banana Pi got into my hands.
Photo from bananapi.orgBanana Pi is, as stated by manufacturers, an improved and more powerful analogue of the Raspberry Pi, which has a compatible slot for connecting modules. Banana Pi has a dual-core processor with a clock speed of 1GHz, a gigabyte of RAM, a gigabit ethernet port, a sata port for connecting external drives, a microphone, an infrared receiver and the rest of the interfaces inherent in each model.
* At the time of this writing, manufacturers have already introduced a new board called Banana PRO, which is an improved version of Banana Pi.Banana pi supports the installation of Lubuntu, Raspbian, Android, Bananian, OpenWrt, Fedora, ArchLinux and other linux-systems, but for those listed above there are already ready images that need only be downloaded
from the manufacturer’s website and burned to a memory card.
In theory, in this place I have to make a comparative analysis of Raspberry Pi and Banana Pi, but since I didn’t work with the first one, then I’ll tell you about my impressions of the second.
The process of installing the operating system does not cause any difficulties, I just downloaded the image from the site, uploaded it to the USB flash drive and started the system. Having played enough with different operating systems, I stopped at Raspbian, assuming that there would be the least potential problems with it, and various materials on it would be enough. After the first boot using the raspi-config, the following settings were made: the graphics mode is disabled, sshd is always on, and the wifi connection is configured.
The first thing we had to deal with was a small community around this board, if the raspberry is full of modules, manuals and articles, then you have to study the modest Google issue and the
official forum , although the forum is quite lively and basic issues are judged by dates quickly. The acquisition of the case did not become a problem, although I expected to have to order its delivery from China, it turned out that spare parts are already being sold at flea markets. About compatibility with WiFi-modules was read in advance, and the remaining parts for the alarm clock were in any store. So along with the case, I purchased a wifi module, microusb and audio cables.

Alarm clock
The alarm clock is pretty simple, install mpd and mpc, add the radio we like, and set up cron for autorun. In general, it is not necessary to use the radio, I think you can easily organize a service that will form a playlist of tracks that you like on soundcloud or that are in your “audio recordings” on vk.com, but this may be the topic for the following articles.
It so happened that I didn’t have a separate music center at home and I never needed it, I didn’t want to buy large speakers, so first of all I tried to find a small device that is powered from the network and has audio input. I don’t know why, but I went and bought a JBL OnBeat-Micro, everything seemed to be the way I wanted, there is even a charge for the phone and a frequency noise analyzer that will turn off the speaker, if it has extremely quiet music, this is very convenient when the speaker is not buzzing and either plays music or turns off. The joy of a new toy passed an hour and a half later, when I discovered that after half an hour of silence, the smart chips turn off the column completely and need to press a button to turn it on.
As a result, having got rid of JBL, I had to find the old Philips Fidelio DS3000 column. It has an audio input, it has a mechanical power button, it sounds quite nice and its dimensions are, of course, larger than those of the JBL, but still quite modest.
The next problem I encountered is wire guidance, apparently Banana Pi emits electromagnetic interference, as a result of which the speaker at rest gave out too much crackling, this was decided by replacing the wire with a larger and shielded one.
I deliberately did not describe how I set up mpd and mpc, because there are so many materials on this topic, and if I have questions, I will answer them in the comments.
Control
The assembled scheme worked and woke me in the morning with pleasant music, but it was necessary to resolve the issue of managing this system. To manage the current session, I installed an MPoD application on my phone.

It remained only to solve the problem with the management of the alarm clock. Initially there were several ideas, the very first one was to bring up the web interface for cron on Banana Pi, but we could not find any ready-made and beautiful solutions, so I had to put up with the idea that everything would have to be done here on my own. While I was thinking up how to do this, I became more and more convinced that I absolutely did not want to write a web interface for crown and install a web server, therefore the TOR was replayed, and the final system would have to work as follows:
- A script is installed on the external server that provides a simple interface to the tasks.
- Tasks should be configured in a simple way from a preset file.
- The task has two states, on / off.
- The status of tasks is given as a cron-file.
- On Banana Pi, we run a script in cron, which once every n minutes will set tasks for the mpc user. At the same time, the availability of the Internet is not so important to us, since even if we have wrong tasks, the radio will not be able to play anyway.
As a result, over the evening I wrote a
simple service that meets all the requirements of the TZ, added it to my favorites in a mobile phone, and now I can easily control how much the alarm clock starts playing.

Task settings are stored in a
yml file , I decided that I absolutely do not need the ability to edit them on the fly, in 99% of cases I wake up at the same time, and in extreme cases there is an alarm clock in the phone and the ability to edit presets in less than five minutes.
Plans
In the future, I want to study the issue with wireless transmitters for audio channel. Try to make a plex / xbmc client. Teach to play not only radio, but also music from social networks. Finish the service to the possibility of editing tasks, but this is a task for the very distant future.
As for the board itself, I am glad that it was she who got into my hands, and not the malinka, because according to rumors, no update of raspberries is planned for the next couple of years, and at almost the same price, a banana gives a greater supply of resources.