Introduction: Remote Controlled Raspberry Pi Alarm Clock

I have awful trouble getting up in the morning, standard alarm clocks just can't cut it as I simply turn it off and go back to bed. My issue is just getting out of bed, once I'm up and out the room I'm normally wide awake, I've tried putting the alarm in another room but then I often can't hear it. For a while now I've been meaning to make my own system so I don't rush around like a headless chicken in the mornings.

I've eventually got around to building it and this quick instructable should give a good overview of my process should you wish to build your own.

The concept is simple, the alarm goes off in your room for 10 seconds alerting you that you need to get up (I'm normally awake at the point the alarm goes off or easily woken making it even worse that I just stay in bed). It then goes silent for 2 minutes letting you go and get the IR remote from another room to turn off the alarm. You are now up and ready to get on with your day! If you don't get up after the 2 minutes elapse the alarm will go off continuously until you go get the remote.

So lets get on with the making...

Step 1: What You Will Need

· Raspberry Pi Zero, other models would be suitable but would result in a larger case

· 5V Power supply

· Pin Header for Raspberry Pi - male or female doesn't matter, it just alters the type of jumper cables required

· Min 4 GB Micro SD Card

· Usb to Microusb adapter - for set up only or if you want to have permanent internet connection

· Wifi dongle or Ethernet cable - for set up only or if you want to have permanent internet connection

· Selection of jumper cables and some wire

· Buzzer

· 1 x ~220ohm Resistors

· Momentary push button – www.adafruit.com/products/1477

· Character LCD Plate – www.adafruit.com/products/1115

· MCP9808 Temp Sensor – www.adafruit.com/products/1782

· RF Receiver - https://www.adafruit.com/products/1096

· RF Keyfob - https://www.adafruit.com/products/139

· Breadboard - for prototyping

· Some stripboard for when you're happy after prototyping

· A Case of sorts – I 3D printed mine, see the Case section for details

· Solder

· Soldering Iron

Total cost ~ £50

Step 2: The Code

Most people seem to leave the code last in Instructables, but for me, it was the most important bit, I finished the code before I even ordered the parts making sure what I wanted to do was possible before committing to any money.

I'm fairly new to python programming so it was also a bit of a learning curve for me. I'm sure I could do things in a much better way, but this code worked for me, I can always revisit it later. I would appreciate feedback from readers if they have any suggestions.

I've created 2 scripts, AlarmClock_Alarm.py and AlarmClock_Screen.py. The two scripts run in parallel on the pi sharing variables using pickle. Alarm.py controls the alarm function, setting it off at the right time. The screen.py controls the LCD screen and passes the alarm time and actual time to the alarm.py script.

To download the code please clone my repository.

https://github.com/chrisbeardy/AlarmClock.git

You will need to set the two scripts running on startup, to do this I used crontab with the @reboot command. you will need to use sudo at the start of the Screen.py script to allow it to access the pickle data.

If you don't know how to use crontab, see this form the pi website:

https://www.raspberrypi.org/documentation/linux/us...

Step 3: Pi Setup

Before you can begin testing you need to ready the Pi.

Download and burn the OS to the SD card

The first step is to burn the latest image to the SD card, for instructions to do this please download the image and follow the link on the Raspberry Pi downloads page:

https://www.raspberrypi.org/downloads/raspbian/

I used the Jessie Lite build.

Set up wifi

There are many ways to do this, from directly writing to the config file on the sd card to plugging the pi into a monitor. As I have easy access to an ethernet port I plug the pi into this and scan my IP network to find its IP address then set up the wifi over SSH. A good guide to set up wifi over command line can be found here:

https://www.raspberrypi.org/documentation/configur...

setting up a static IP:

https://www.modmypi.com/blog/how-to-give-your-rasp...

If you wish to use any other methods, google is your friend here!

Dependencies

To use the parts from my parts list you have to download and install some bits (thank you Adafruit for your very handy python libraries!). Enter the following commands into the raspberry pi console. These instructions will install everything for both python 2 and 3.

sudo apt-get update

sudo apt-get install i2c-tools build-essential python-dev python3-dev python-smbus python3-smbus python-pip python3-pip git

sudo pip install RPi.GPIO

sudo pip3 install RPi.GPIO

git clone https://github.com/adafruit/Adafruit_Python_CharLCD.git

cd Adafruit_Python_CharLCD

sudo python setup.py install

sudo python3 setup.py install

cd

git clone https://github.com/adafruit/Adafruit_Python_MCP9808.git

cd Adafruit_Python_MCP9808

sudo python setup.py install

sudo python3 setup.py install

Step 4: Some Assembly

The parts from Adafruit and the Raspberry Pi require you to bust out the soldering skills.

None of it is tricky but the LCD plate was a bit fiddly. I used a PCB Vise that I 3D printed.

Character LCD Plate

Follow the link below for instructions on how the assemble the LCD screen:

https://learn.adafruit.com/adafruit-16x2-character...

You will need to solder on the headers for the Pi Zero and the temperature sensor too.

Step 5: Breadboarding

With this basic setup, you are now ready for prototyping to make sure it's all working before we finally put it together.

Using a breadboard connect up the alarm in the following manner:

Connect the Pi, IR receiver, screen and temp sensor to the power strips, they all work off 5V. You can work out the pinout of the screen easily as it is meant to sit as a hat on the pi.

Connect the Pis, screens and temp sensors I2Cbus together. (SCL and SDA).

Connect the IR receiver, buzzer and button to GPIO of your choosing.

You should start the code by running the Alarm.py script first then the Screen.py script.

To set an alarm, press the left button in the LCD, use the up and down buttons to set the hour and minute and the select button to confirm them. Press the Up button on the LCD to enable the alarm.

Step 6: The Case

I'm lucky enough to own a 3D printer so I printed my case, I used the free online modelling software Onshape, a link to the case can be found here so you can customise it any way you like:

https://cad.onshape.com/documents/6f03009499d4b24e...

The LCD case should press fit into the slot, but I just added a bit of glue to keep it in place. If you use a similar concept to me, make sure to put the buttons in the case first so you can get them in.

Step 7: Final Assembly

When you have all the parts and it has been tested, it's time to put it all together.

Using the stripboard and by cutting the jumper cables up, wire up the circuit again soldering in all the connections.

As I was planning on stuffing all the electronics in the case with no real finesse I used a glue gun to coat the back of the stripboard with glue essentially isolating it. I did the same with the pushbutton too.

When it's all wired up, stuff it in the case, power it up and voilà, you now have an alarm clock which guarantees to get you out the bed in the morning.

I hope you enjoyed this brief instructable, let me know if you have any questions.

Comments

About This Instructable

1,223views

13favorites

License:

More by chrisbeardy:Syncing Folders With PythonRemote Controlled Raspberry Pi Alarm ClockProgramming Raspberry Pi With CODESYS
Add instructable to: