Particle Photon Clock

3.5K120

Intro: Particle Photon Clock

In this project we will be making an alarm clock that syncs its time with the cloud and once the alarm sounds it will switch on the lights.

Materials:

  1. Particle Photon
  2. Breadboard
  3. LCD display and necessary potentiometer https://www.adafruit.com/product/181
  4. Piezo Buzzer
  5. Micro Servo https://www.adafruit.com/products/169
  6. About 20 jumper wires

You can ignore the two AA batteries as I was trying to include the onboard Real Time Clock that the photon has but was unsuccessful.

STEP 1: Connecting Your Photon to the Internet


Here is a great tutorial video straight from Particle teaching you how to connect your Photon to the internet.

https://docs.particle.io/guide/getting-started/sta...

STEP 2: Connecting the LCD

Wiring up the LCD is fairly simple. Follow the included diagram and you should get through it in no time.

STEP 3: Wiring the Piezo Buzzer and Servo

Next, you will want to wire up the piezo buzzer and servo so that when the photon recognizes that the alarm should be going off the buzzer will sound and the servo will rotate, which will turn on the lights.

The positive side of the buzzer will be connected to D7 and the negative side to ground.

The servo's left most wire will be connected to ground, it's middle wire will be connected to VIN, and the right wire will be connected to D1.

STEP 4: Writing the Code

I have attached the code that I wrote for this project in this step as a .text file. You can change it how you see fit. Currently, the code is written so that when the current time is equal to the time set as the alarm the buzzer will sound for 5 seconds after the servo has turned on the lights.

To use this code you will want to go to build.particle.io and paste the code into a new app. You will then need to import the SparkTime and LiquidCrystal libraries from the libraries tab on the website.

If you wish to set different preset alarm times you will need to write them under "int clk(String comand) {" and write them in the format:

if(comand == "NameOfAlarm")

{

alarm = true;

alarmhour = 6;

alarmmin = 0;

}

Where alarm always stays true, alarmhour is the hour that you want the alarm to sound and alarmmin in the minute you want the alarm to sound.

You may also need to change the time zone in setup if you are not in the central time zone.

STEP 5: Connecting to IFTTT

I only know how to do this via an Android phone. I do not know if it will work for iPhones or window phones.

If you don't already have one you will need to make an IFTTT account and download the IFTTT app on your phone.

  1. Open the IFTTT app and go to My Applets and click the plus sign on the top right.
  2. Click on the plus next to "this" and search for the "Button widget"
  3. Choose the Button widget and the trigger "Button Press"
  4. Then click on the plus next to "that" and search for particle
  5. Choose the trigger "Call a function" which will bring you to screenshot above.
  6. If your photon is online and you flashed the code you should be able to click the down arrow where it says "The Call 'Function Name'" and choose set()
  7. Then you can type in the desired alarm time into the second input line where it says "with Input" in military time. (In this example the alarm will be set for 2:50 pm)
  8. After clicking on the check mark in the upper left-hand corner you will need to go back to a home screen and create a new widget. (on my phone you do it by holding an empty space on the home screen and the option to add widgets appears on the bottom of the screen)
  9. Search for the 1x1 IFTTT widget and add it to your home screen.
  10. It will then ask you which applet you would want to run, choose the one you just made.
  11. Click the widget and wait 5-15 seconds for the LCD to update and display the alarm time you chose.
  12. Repeat at least one more time for the function clk(Off) so that you can have another widget that turns off the alarm whenever you don't want it.

You now have an alarm clock that you can set the time for using widgets on your phone, and once you attach the servo to a light switch, an alarm clock that turns on your lights once it sounds.