Introduction: Morning Buddy

Some people have very busy schedules, which makes it easy to forget a thing a or two. With this alarm clock you can set multiple alarms to keep you on schedule. The clock runs on 24-time and all you have to do is program it to go off at the different times of the day that fit your schedule. When your doing this the times that you have set will pop up on the LCD screen, so that you can check to make sure they're right and serve as an extra reminder.

Step 1: Brainstorming the Idea

When we were trying to solve the issue we used the fishbone method to come up with an idea and resulted with our alarm clock.

Step 2: Sketching and Materials

During this step we tried to make a list of all the things we thought we would need for the electronics and outer casing. Then we came up with a sketch of what we wanted the alarm clock to look like and how we would assemble its outer casing.

Step 3: Creating the Outter Casing

For the first prototype I just wanted to see how the finger joints would fit together, so I used a shoe box and did not use exact measurements.

Step 4: Laser Cutting the Outer Casing

For the second prototype I wanted to get exact measurements and had to create a pdf to send to the laser cutter. In order to do this I used a box maker app website, https://boxdesigner.connectionlab.org. On that website I then entered the 3-D dimensions of the box, thickness of our material, the measurement units, and what type of file I wanted it create. The boxes dimensions were 7.5 in x 3 in x 5 in and I used an 1/8 in thick acrylic material. The finger joint notches measurements were then automatically configured to be 0.46875 inches. I selected the pdf version because that is the type of file that a laser cutter reads and I wanted to make some changes in adobe to the file. I changed the line colors to red, so that the laser cutter would know to cut them out instead of engraving the shape, and I added a rectangle box with dimensions of 3.92 in by 1.56 in on what was going to be the front piece of the box. I also added a rectangle cut out with dimensions of 1in by 0.5in in on the right side piece at the bottom to serve as an opening for the cord connected to the alarm clock. Last I added three circular openings at the top for the two buzzers and the button. The buzzer openings had a diameter of 0.5 in and the button opening was 0.375 in.

Step 5: Putting It Together

When all the pieces were cut out I used a syringe and acrylic glue to seal it together. I held the pieces together and dripped the glue in between the notches to make the sides together, but the top was not glued down.

Step 6: Code

Introduction:

This project was coded using the language c++ on Arduino IDE software. The micro-controller used was the NodeMCU with the ESP8266. For this project we would need a way to accurately keep time, a buzzer to sound, an alarm system to cause the alarm to buzz, and a screen to display the time all and the alarm times. For the full code refer to this link https://github.iu.edu/rwtow/E101-Morning-Buddy

Importing Libraries

First things first, we need to import the necessary libraries.

#include "RTClib.h"
#include "Wire.h"
#include <LiquidCrystal_I2C.h>
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

Initiating Variables

Next we need to initiate variables for later, assign the pin layout for the buzzer buttons, set up the RTC, and set the LCD display's I2C address.

LiquidCrystal_I2C lcd(0x27,20, 4); 
const int buzzer1 = 12;
const int buzzer2 = 0;
const int button = 2;
RTC_DS3231 rtc;

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}

int starttime;
int activetime;
int prevoustime = 0; 

char ahours1[3];
char amins1[3];

int hour1 = 0;
int min1 = 0;

char ahours2[3];
char amins2[3];

int hour2 = 0;
int min2 = 0; 

char ahours3[3];
char amins3[3];

int hour3 = 0;
int min3 = 0;

int alarm = 0;
int ByteReceived; 

char recievedChar;

const byte numChars = 32;
char receivedChars[numChars]; <br>

Setup

Next, we need to have a function that starts all the necessary processes. In this function, we need to start up the LCD and print initial times, make a smaller function that gives the RTC real time if it doesn't already have it, and start the serial monitor.

void setup() {
#ifndef ESP8266 
  while (!Serial);
#endif
  if(! rtc.begin()) { 
  Serial.println("Couldn't find RTC");
  while(1);
}
  if (rtc.lostPower())  { 
  Serial.println("RTC lost power, lets set the time!"); 
  rtc.adjust(DateTime(F(__DATE__), F(__TIME__)))
} 
lcd.init(); 

lcd.backlight(); // makes Baklight ON.
lcd.clear();            // Clears LCD 
lcd.print("00:00");     //display on LCD after code upload 
lcd.setCursor(10, 0); 
lcd.print("00:00"); 
lcd.setCursor(0, 1); 
lcd.print("Time"); 
lcd.setCursor(10, 1); 
lcd.print("Alarm 1"); 
lcd.setCursor(0,3); 
lcd.print("Alarm 2"); 
lcd.setCursor(0,2); 
lcd.print("00:00"); 
lcd.setCursor(10,3); 
lcd.print("Alarm 3"); 
lcd.setCursor(10,2); 
lcd.print("00:00"); 
rtc.begin(); 
pinMode(button, INPUT); //Set a pin for the silence button 
pinMode(buzzer1, OUTPUT); // set a pin for buzzer output 
pinMode(buzzer2, OUTPUT); // set a pin for buzzer output 
Serial.begin(9600); 
Serial.println("Input time of alarms in HHMM format with no space inbetween alarms"); 
starttime = millis()/1000;
}

Receiving Data

Now, we need to be able to receive the alarm times. To do that we created a function to receive the data from the serial monitor and store it in an array.

void recvWithEndMarker() {
  static int ndx = 0;   
  String timein = Serial.readString();
  for(ndx = 0; timein[ndx]; ndx++){     
    receivedChars[ndx] = timein[ndx];   
  } 
  receivedChars[ndx] = '\0';
  Serial.print(receivedChars); 
}

Setting Alarms

The next step is being able to set alarms. Here is the code for alarm 1. For alarm 2 and 3 the same process was repeated with a few number changes.

/* Alarm 1*/    
recvWithEndMarker();    
int h, m;
for (h = 0; h < 2; h++) {        
ahours1[h] = receivedChars[h];     
}    for (m = 2; m < 4; m++) {        
amins1[m-2] = receivedChars[m];    
}    
ahours1[h] = '\0';    
amins1[m-2] = '\0';        
Serial.print(ahours1);    
Serial.print(amins1);    
hour1 = atoi(ahours1);    
min1 = atoi(amins1);   
Serial.print(hour1);    
Serial.print(min1);        

Buzzer/Button

With that done, we need to make the buzzer go off when real time and alarm time are equal. Also in this step we make a snooze like button that stops the buzzer while you hold it.

/* Silence Button */  
int silence;  
int b;  
b = digitalRead(2);  
if (b == LOW) {  
silence = 1;  
}  
else {  
silence = 0;  
}    
/* Start Alarm */  
if (hours == hour1 && mins == min1)  
{    
alarm = 1;  
}  
else if (hours == hour2 && mins == min2)  
{    
alarm = 1; 
}  
else if (hours == hour3 && mins == min3)  
{    
alarm = 1;  
}  
else  
{    
alarm = 0;    
silence = 0;  
}  
if ( alarm == 1 && silence == 0 ) {      
tone(buzzer1, 4000, 1000);      
tone(buzzer2, 4000, 1000);      
delay(1000);      
noTone(buzzer1);      
noTone(buzzer2);      
delay(1000);  
}

Printing Times

Finally, we need to print the alarm times and real time to the LCD screen.

DateTime now = rtc.now();  
int hours = (now.hour());  
int mins = (now.minute());  
/* Alarm time in 00:00 format */ 
lcd.setCursor(10,0);  
lcd.print(ahours1);  
lcd.setCursor(13,0);  
lcd.print(amins1);
lcd.setCursor(0,2); lcd.print(ahours2); lcd.setCursor(3,2); lcd.print(amins2); lcd.setCursor(10,2); lcd.print(ahours3); lcd.setCursor(13,2); lcd.print(amins3); /* Display Time from RTC */ lcd.setCursor(0,0); lcd.print(hours); lcd.print(":"); lcd.print(mins);

Step 7: Electronics

There are multiple pieces to the electronics of this project, as seen in the bill of materials. The First image is a schematic of the projects final electronics. The Second image is our final electronic design. The Third image is of our project in the midst of the second prototype.

To begin attach your NodeMCU to the far end of your breadboard. You will then need to connect all of your other electronics to the NodeMCU and breadboard. Begin by connecting your LCD screen to pins D1 for SCL and D2 for SDA. The LCD will allow the user to see the current time and the set alarm times. Now have a wire connect your buzzers to pins D3 and D6. The buzzers will allow the alarm to alert the user when the time set has been reached. You must now attach a button to allow the alarm to be stopped. Attach this button to pin D4. Now you will attach your Real-time clock to the breadboard. Wire the Real-time clock so it uses the same SDA and SCL pins used for the LCD display.

Step 8: Final

If you have followed the information given your project may look like the image above. We wish you luck in your attempts to recreate this project and when you have completed your project we encourage you to share pictures and remarks with us in the comments. Thank you and good luck fellow Makers.