With everything getting automated these days I think it’s only fair to give good old school bell a touch of automation. So I thought to design and develop Automatic school bell system using Arduino development board. This system activates the School bell at predefined time each day. Add this project comes with a manual switch to activate the bell. This will give the liberty to the user to activate it manually when required.
SCHEMATIC DESIGN OF AUTOMATIC SCHOOL BELL SYSTEM:
DS1307 RTC MODULE:
DS1307 is an Real time clock chip that is used in many Embedded applications for adding real time to the system. Timing generated using Microcontroller delays are not precise as real time so when comes to time sensitive applications like Alarms, Timers usage of RTC chips is very much necessary. This RTC chip will communicate with Arduino using I2C communication protocol to provide real time input. Arduino can use this real time input to perform the desired operation, in our case it’s ringing of School bell.
WORKING OF AUTOMATIC BELL PROJECT:
The working of this Automatic School bell system starts with Real time clock module DS1307. This module feeds Arduino with real time and keeps track of it. Through the process of polling Arduino will frequently get the time and date values from this chip. Also user has been given five button inputs which they can use to set the Hours, minutes, Date, month and year in the RTC chip. Continuous toggle of these buttons will vary the corresponding values and register them in RTC chip. The automatic bell timer is activated by means of a Relay which is controlled via a transistor switch. The transistor switch is very much necessary since Arduino cannot source enough current to operate the relay directly. Adding a flywheel diode D1 will act as a protection to the rest of circuit when the relay is turned OFF.
CODE:
You need to install two Arduino libraries for this to work – DS1307 library and Time library , thanks to Paul Stoffregen I have commented the code almost every line for better understanding and the coding part is pretty simple as well.
#include <LiquidCrystal.h> #include <TimeLib.h> #include <DS1307RTC.h> #include <Wire.h> LiquidCrystal lcd(13,12,11,10,9,8); /* lcd pinouts initialising */ int datetime[7]; /* stores the Time and date values */ /* setting up the input pins */ //int Hour, Min, Sec,Day,Month, Year; tmElements_t tm; void setup() { for(int i=3;i<8;i++) { pinMode(i,INPUT); } pinMode(2,OUTPUT); /* pin for the bell */ lcd.begin(20,2); /* powering up the lcd */ tm.Hour=9; tm.Minute=0; tm.Second=0; tm.Day = 1; tm.Month=1; tm.Year = 20; //RTC.set(19,3,19,0,9,59,50);//d,m,y,sem,h,m,s - sets the time and date } // this will run forever till you die or till power goes off void loop() { //DS1307.getDate(datetime); /* get date */ setSyncProvider(RTC.get); lcd.setCursor(0,1); /* move the cursor down */ lcd.print("Time: "); Print(tm.Hour); /* print hour on the lcd */ lcd.print(":"); Print(tm.Minute); /* print minute */ lcd.print(":"); Print(tm.Second); /* print seconds */ lcd.setCursor(0,0); /* move cursor back ontop */ lcd.print("Date: "); Print(tm.Day); /* day */ lcd.print("/"); Print(tm.Month); /* month */ lcd.print("/"); Print(tm.Year); /* add 20 to it making it 2019 */ Print(datetime[0]); /* Print Year */ /* validating minutes, seconds and months for LCD printing and to avoid errors */ if(digitalRead(7)) { tm.Minute++; if(tm.Minute>59) tm.Minute=0; /* if minute is 59 */ RTC.set(tm.Minute); while(digitalRead(7)); } if(digitalRead(6)) { tm.Hour++; if(tm.Hour>23) tm.Hour=0; /* if hour has reached 24, making it 24 hours max */ RTC.set(tm.Hour); while(digitalRead(6)); } if(digitalRead(5)) { tm.Day++; if(tm.Day>28&&tm.Month==2) tm.Day=1; /* Setting the days in a month */ else if(tm.Day>30&&(tm.Month==4||tm.Month==6||tm.Month==9||tm.Month==11)) tm.Day=1; else if(tm.Day>31) tm.Day=1; RTC.set(tm.Day); /* update the date and time */ while(digitalRead(5)); } if(digitalRead(4)) { tm.Month++; if(tm.Month>12) tm.Month=1; /* if 12 months reached */ RTC.set(tm.Month); /* update the date and time */ while(digitalRead(4)); } if(digitalRead(3)) { tm.Year++; if(tm.Year>99) tm.Year=0; /* Years */ RTC.set(tm.Year); /* update the date and time */ while(digitalRead(3)); } /* give it some time */ delay(5); /* checking the time to sound the bell */ if(tm.Hour==10 && tm.Second==00) { digitalWrite(2, HIGH); /* sound the bell */ delay(10000); /* let it ring for 10 seconds */ digitalWrite(2, LOW); /* mute the bell */ } if(tm.Hour==11 && tm.Second==00) { digitalWrite(2, HIGH); /* sound the bell */ delay(10000); /* let it ring for 10 seconds */ digitalWrite(2, LOW); /* mute the bell */ } if(tm.Hour==12 && tm.Second==00) { digitalWrite(2, HIGH); /* sound the bell */ delay(10000); /* let it ring for 10 seconds */ digitalWrite(2, LOW); /* mute the bell */ } /*Repeat the above four lines of code with altered Hours and Minute values to make the bell ring for more time periods */ } /* convert array to a value that can be displayed on the LCD */ void Print(int number) { lcd.print(number/10); lcd.print(number%10); }
NOTE:
- You need too look for the current rating of your electric Bell and choose the Relay and switching transistor accordingly.
- Keep this unit hidden and limited to be used by authorized personal.
- Repeat the four lines of code from 84 to 89 and use it with altered hours and minutes values for more time period.
Sir.. I done upload the program sucessfully.. But my input buttons not working.. Anybody help me….
Hey Sanjay, Try removing the resistors and see if the input buttons will work
I have done everything.
But I’m having challenges
1. Setting the time on the LCD using the buttons
2. Setting more intervals.
hello I’m Tushar Bhardwaj and i was seeking here for program and circuit for the arduino base bell but i could not get the circuit beacuse some symbols were that i have never seen please somebody help me to get over the problem
Thanks and regards
I edited code according to library examples. and i get rit off errors. Can anyone test the code please?
” https://drive.google.com/file/d/1vGGCwRdZd27cLzQlHtYodk7GAXDxsfsj/view?usp=sharing “
Hi Murat,
This took longer for us to fix. The problem is that there are couple of libraries available to use for DS1307 and when someone installed a different library from what we used to build our code they will encounter these errors. The library you need to use for this code is DS1307RTC and Time by Paul Stoffregen. I have added the link above.
I have edited the code based on these two libraries. Give them a try.
Also you should know I haven’t tested the code, my Arduino seems missing. If you or someone else in our community have the set up. Kindly test and post your results.
Thank you so much
still no explanation about library error?
sir i need this project report
Hi Sarath,
We have the full documentation of this project but not in the form of report. You can use this documentation to create report.
Arduino: 1.8.10 (Windows 10), Board: “Arduino/Genuino Uno”
C:\Users\ravali\Documents\Arduino\smartbell\smartbell.ino: In function ‘void setup()’:
smartbell:14:7: error: expected unqualified-id before ‘.’ token
DS1307.begin(); /* the Real Time datetime Module */
^
smartbell:15:9: error: expected unqualified-id before ‘.’ token
DS1307.setDate(19,3,19,0,9,59,50);//d,m,y,sem,h,m,s – sets the time and date
^
C:\Users\ravali\Documents\Arduino\smartbell\smartbell.ino: In function ‘void loop()’:
smartbell:20:7: error: expected unqualified-id before ‘.’ token
DS1307.getDate(datetime); /* get date */
^
smartbell:40:8: error: expected unqualified-id before ‘.’ token
DS1307.setDate(datetime[0],datetime[1],datetime[2],0,datetime[4],datetime[5],datetime[6]); /* update the date and time */
^
smartbell:46:8: error: expected unqualified-id before ‘.’ token
DS1307.setDate(datetime[0],datetime[1],datetime[2],0,datetime[4],datetime[5],datetime[6]); /* update the date and time */
^
smartbell:54:9: error: expected unqualified-id before ‘.’ token
DS1307.setDate(datetime[0],datetime[1],datetime[2],0,datetime[4],datetime[5],datetime[6]); /* update the date and time */
^
smartbell:60:8: error: expected unqualified-id before ‘.’ token
DS1307.setDate(datetime[0],datetime[1],datetime[2],0,datetime[4],datetime[5],datetime[6]); /* update the date and time */
^
smartbell:66:7: error: expected unqualified-id before ‘.’ token
DS1307.setDate(datetime[0],datetime[1],datetime[2],0,datetime[4],datetime[5],datetime[6]); /* update the date and time */
^
Multiple libraries were found for “DS1307.h”
Used: C:\Users\ravali\Documents\Arduino\libraries\Arduino-DS1307-master
Multiple libraries were found for “LiquidCrystal.h”
Used: C:\Program
Multiple libraries were found for “Wire.h”
Used: C:\Program
exit status 1
expected unqualified-id before ‘.’ token
This report would have more information with
“Show verbose output during compilation”
option enabled in File -> Preferences.
I got this error how can i solve it.
I already downloaded DS1307 libraries and still i have same error..
Hi Vinay did you find where is the problem with these code, I have the same error.
we have already include all required libraries. although library error is present in this code
Give me the key information about the error.
are you sure you copied the right code, use visual code for better debugging, and inclide the libraries in the arduino default library folder, https://github.com/jarzebski/Arduino-DS1307
hello bhai program uploding mai error aaa raha hai
Arduino: 1.8.8 (Windows 8.1), Board: “Arduino/Genuino Uno”
Build options changed, rebuilding all
E:\Arduino Programs\bel\bel.ino: In function ‘void setup()’:
bel:13:9: error: expected unqualified-id before ‘.’ token
DS1307.begin(); /* the Real Time datetime Module */
^
bel:14:9: error: expected unqualified-id before ‘.’ token
DS1307.setDate(19,3,19,0,9,59,50);//d,m,y,sem,h,m,s – sets the time and date
^
E:\Arduino Programs\bel\bel.ino: In function ‘void loop()’:
bel:19:7: error: expected unqualified-id before ‘.’ token
DS1307.getDate(datetime); /* get date */
^
bel:39:8: error: expected unqualified-id before ‘.’ token
DS1307.setDate(datetime[0],datetime[1],datetime[2],0,datetime[4],datetime[5],datetime[6]); /* update the date and time */
^
bel:45:8: error: expected unqualified-id before ‘.’ token
DS1307.setDate(datetime[0],datetime[1],datetime[2],0,datetime[4],datetime[5],datetime[6]); /* update the date and time */
^
bel:53:8: error: expected unqualified-id before ‘.’ token
DS1307.setDate(datetime[0],datetime[1],datetime[2],0,datetime[4],datetime[5],datetime[6]); /* update the date and time */
^
bel:59:8: error: expected unqualified-id before ‘.’ token
DS1307.setDate(datetime[0],datetime[1],datetime[2],0,datetime[4],datetime[5],datetime[6]); /* update the date and time */
^
bel:65:8: error: expected unqualified-id before ‘.’ token
DS1307.setDate(datetime[0],datetime[1],datetime[2],0,datetime[4],datetime[5],datetime[6]); /* update the date and time */
^
exit status 1
expected unqualified-id before ‘.’ token
This report would have more information with
“Show verbose output during compilation”
option enabled in File -> Preferences.
how to slove it
same error here
Check whether you have installed DS1307 library. I suspect that’s the cause of this error.
download the DS1307 Library, and put it in your aduino library folder, your project should compile without any errors https://github.com/jarzebski/Arduino-DS1307
Hello there i want to make a school bell for my classroom, i want to make it to ring from Monday to Friday for example at 7:30 then after 45minute a brake and after the next hour. etc… But also if i want to ring it manual!!! And stop it and start it again if i want !!!! Could you please tell me the parts and the ring bell i think for 220v bell to out it on wall power supply. Also could you tell me the code to upload it in the Arduino. And the diagram
hi dear i can help you for this task
Anthimos, Have you succesfully built your school bell??