About 50 years ago, I built an AM radio using a crystal. For a kid in the 60s, this was very cool. OK, that's a lie. It was very nerdy, but it was cool to me.
Background
More than 10 years ago I bought a Sony Radio Alarm Clock. For the time, it was an excellent device.
After years of abuse, tuning to an FM station became problematic. In 2017, the buttons stopped working. I could have fixed these, but I thought it would be more fun to replace the guts with a raspberry pi. However, the final build is larger than the original case. So, I tossed the case.
Of course, all of the functions of a Radio Alarm Clock can be accomplished with a SmartPhone.
There is no point in building a Radio Alarm Clock. A home built alarm clock radio costs way more than buying one and it took a crazy amount of time to build. But this project made me feel like a kid again and I learned a lot.
Features
The alarm clock radio has the following features:
Set an alarm
Play FM over-the-air radio
Store a list of favorite stations
Play Internet radio
Play songs from my library
Use a touch screen interface rather than the buttons
Select an FM Radio station
Select an FM or internet station
Select a mode (FM, Internet, Songs)
Set or clear an alarm
Change the volume
As an added bonus, the Raspberry Pi USB ports are used to charge my kindle and iPhone
Music Players
There are several excellent music players running on the Raspberry Pi including: Mopidy, Volumio, Moode, RuneAudio and Pi MusicBox. In sticking with my focus, Mopidy and Peppy are the only ones running on python. I have an old speaker and I am not an audiophile. So, I am not worried about the best audio performance. I am not sure which audio player is best. I spent a while investigating each of these solutions, but eventually gave up thinking it would be easier to just build my own. Of course, I was wrong.
Parts
Raspberry Pi 3 B+
AdaFruit 2.8 inch capacitive resistance PiTFT display
female-female jumper cables
male-female jumper cables
FM Receiver Si4703 Board
Earbuds (temporary)
Icstation's LM386 Mini Mono Audio Amplifier Power Amp Module 5V-12V for over-the-air FM Receiver
For the speakers, I used cabbaged parts from some unknown device. If you don't have a speaker this is recommended by the the Peppy build:
3.5mm male-to-male audio cable
12V barrel plug power supply for the HiFiBerry AMP2 and the rest of the project
HiFiBerry Amp2 amplifier for internet radio and songs
USB cords for iPhone and Kindle charging
Tools (all reusable)
Soldering Iron Station, jig saw, drill, monitor with HDMI input, USB wireless keyboard and mouse, voltmeter, prototype board,
CAUTION: Speakers have very large magnets and some small magnets. Both are capable of erasing a microSD Card, destroying a raspberry pi and the FM Receiver. Keep the components far away from the magnets I was almost done with this project when I accidentally allowed the microSD Card to touch a magnet, and I had to toss the SD card.
Step 1. Setup Raspberry Pi
Step 2. Add HiFiBerry AMP2
Step 3. Create over-the-air FM Radio Receiver
Note: The 3.5mm male-to-male audio cable acts as the antenna for the FM Receiver
Step 4. Add 2.8 inch capacitive resistance PiTFT display
Step 5. Wiring
There are a lot of connecting wires in this project. Step 3 adds a perf board, which simplifies the wiring and reduces 5v noise in the FM audio.
On the perf board, each of the headers in a block are soldered together. The transistor and capacitor provide a simple filter for the 5v input from the Raspberry Pi.
The other steps should contain all the wiring diagrams required. Let me know if anything is missing and I will add.
The HiFiBerry, PiTFT and FM Receiver all use I2C. I read a lot I2C and thought this was going to take me a while to figure out. When I hooked everything up with no resistors, it just worked. and I am not sure why.
Step 6. Download acr.py
The python3 crontab module is required for the alarm clock. Install using:
$ pip3 install python-crontab
Download acr.py
$ wget https://raw.githubusercontent.com/dumbo25/tkinter-alarm-clock-radio-gui/master/acr.py
Step 7. Start on boot
NOTE: This step worked for a while. Now, I get an unhandled errno 121. Something to do with I2C. I removed the line from autostart. I need to use a USB mouse and keyboard to start the script (python3 radio/acr.py). Arrgh
I want acr.py to start on boot
$ chmod +x acr.py
Add acr.py to autostart
$ nano /home/pi/.config/lxsession/LXDE-pi/autostart
and add the line at the end:
@python3 /home/pi/radio/acr.py
It takes a few minutes for the acr.py to start, be patient
Step 8. Put it all in a case
I attached each of the board to a sheet of plexiglass to keep them in place.
The case is up to you, because the size and shape depend on the size and number of speakers. I built mine out of plywood and then painted it glossy black.
When I put the alarm clock radio on my night stand, I wondered if I could add an iPhone and Kindle cords to the Raspberry Pi's USB ports. I tried the iPhone and it started charging. I do not know yet if there are side-effects from doing this, or what the charge time is, but it seems to work.
Appendix
I built the Alarm Clock Radio in steps. Some of the steps are shown above, but some are not. The unshown steps were not required. For example, when I was done, I combined several individual scripts into acr.py. Some of the steps below are creating a GUI, adding internet radio and songs.