Arduino Based Automatic School/College Bell System

 Automatic School/College Bell System By using Arduino



In this Article, We are going to learn how to construct an automatic school bell or college bell system with the help of Arduino, a 16x2 display, and a real-time clock module. With this project, you can easily program the bell to ring up to sixteen times per day at your preferred hour and minute. Plus, you can customize the duration of the bell ring in seconds. Follow the step-by-step instructions to build your own automated bell system today.


 Abstract:

An automatic school bell system using Arduino is a sophisticated time-management solution that automates the ringing of school bells at predetermined intervals throughout the day. The system utilizes an Arduino microcontroller to program and control the bell schedule, ensuring accurate and consistent bell timings. Its advantage lies in streamlining school operations, eliminating the need for manual bell ringing, and reducing the chances of human errors or delays. Additionally, the system allows for easy customization of bell schedules to accommodate special events or variations in daily routines. By providing a reliable and efficient timekeeping mechanism, the automatic school bell system ensures a more organized and punctual environment for students, teachers, and staff, enhancing overall productivity and fostering a conducive learning environment.


Table of Contents:


  • Needed Material 
  • Circuit diagram 
  • Circuit connections 
  • Setting RTC and switch
  • Source Code
  • How to use it
  • Working prototype 
  • Conclusion

Materials Needed:


  • Arduino Board: Any Arduino board can be used (e.g., Arduino Uno, Arduino Mega, etc.).
  • Real-Time Clock (RTC) Module: A module that provides accurate timekeeping even when the Arduino is powered off. The DS3231 RTC module is a popular choice.
  • 16 x 2 LCD Display: A 16-character by 2-line alphanumeric display, typically based on the Hitachi HD44780 driver. It allows you to show the current time and other relevant information.
  • Buzzer or Relay: An audio output device to generate the bell sound when the scheduled time is reached.
  • Breadboard and Jumper Wires: For prototyping and connecting components on the breadboard.
  • Resistors and Potentiometer: Resistors may be needed for limiting current in the circuit, and a potentiometer can be used to adjust the contrast of the LCD display.
  • Push Buttons: To add manual control or adjust the bell schedule
  • Power Supply or Battery Pack: A stable power source to power the Arduino and other components.
  • Computer with Arduino IDE: To write and upload the Arduino code to the Arduino board

Optional:


  • Enclosure: A suitable box or enclosure to house the components neatly and protect them from dust or damage.

  • RTC Module with Integrated Temperature Sensor (Optional): Some RTC modules come with an integrated temperature sensor, which can be helpful for additional functionalities or monitoring the temperature.

Note: Depending on the specific Arduino board and RTC module, the required jumper wires and connections may vary. Make sure to check the datasheets and guides for the components you are using to ensure proper connections.


Remember, safety should always be the first priority when working with electronic components. Double-check the compatibility of the features and connections, and avoid overloading the Arduino's pins or using inappropriate voltage levels.


Circuit diagram:


  • Arduino to LCD Display

fig: LCD to Arduino

The display to Arduino connections is slightly different from what we wire them usually, the pins 9, 8, 7, 6, 5, and 4 are used here. The pin numbers 2 and 3 are used as hardware interrupts via push buttons.

Use the 10K potentiometer for adjusting the contrast for the display.

Here, a 220-ohm resistor is used for setting up the brightness of the backlight for the 16*2 LCD Display which is optional.


  • Arduino to Relay, RTC, and switch Connection:


Fig: Arduino to Relay ,RTC & Switch Connection

 

In order to fully assemble the School Bell project, it's important to connect the first and second diagrams together. This will ensure that all of the components are properly linked and working together.


Circuit Connections:


  1. Connection of the RTC Module to Arduino:


    • RTC SDA pin to Arduino A4 (or SDA) pin
    • RTC SCL pin to Arduino A5 (or SCL) pin
    • RTC VCC pin to Arduino A3 pin
    • RTC GND pin to Arduino A2 pin

    • Connect the 16 x 2 LCD Display to Arduino:

    • LCD D4 pin to Arduino D7 pin
    • LCD D5 pin to Arduino D6 pin
    • LCD D6 pinto Arduino D5 pin
    • LCD D7 pin to Arduino D4 pin
    • LCD E pin to Arduino D8 pin
    • LCD RS pin to Arduino D9 pin

    • LCD VCC pin to Arduino 5V pin
    • LCD GND pin to Arduino GND pin

    • LCD RW pin (if applicable) to GND (for write-only operation)

    • LCD Contrast Adjustment: Connect one end of a potentiometer to the LCD VO pin and the other end to the GND. The wiper of the potentiometer goes to the Arduino 5V pin.

    • Connect Relay to Arduino:

    • Relay Signal Pin to Arduino digital 10 pin
    • Relay VCC to Arduino 5V
    • Relay Gnd to Arduino GND


Setting Real Time Clock Module:



The Real time clock module keeps track of the time even after a long power cut After that  A 5V relay is provided for switching the bell on and off.

 To Power the circuit use a 5v / 500mA wall adapter.

Three push buttons are provided one for manually operating the bell during some situations. Pressing the “exit” button will stop the bell after ringing the bell manually.

The “bell disable button” will disable the bell forever. To re-enable the bell press the “Exit” button.


How to set time to RTC module:


Download the RTC library:
Link: github.com/PaulStoffregen/DS1307RTC

-----------------------------------------------------------------
Download timeLib.h:
github.com/PaulStoffregen/Time
------------------------------------------------------------------

Upload the Program:


//----------------------------------------------------//
#include <Wire.h>
#include <TimeLib.h>
#include <DS1307RTC.h>
int P=A3; //Assign power pins for RTC
int N=A2;
const char *monthName[12] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
tmElements_t tm;
void setup() {
pinMode(P,OUTPUT);
pinMode(N,OUTPUT);
digitalWrite(P,HIGH);
digitalWrite(N,LOW);
bool parse=false;
bool config=false;
//Get the date and time the compiler was run
if (getDate(__DATE__) && getTime(__TIME__)) {
parse = true;
// and configure the RTC with this info
if (RTC.write(tm)) {
config = true;
}
}
Serial.begin(9600);
while (!Serial) ; // wait for Arduino Serial Monitor
delay(200);
if (parse && config) {
Serial.print("DS1307 configured Time=");
Serial.print(__TIME__);
Serial.print(", Date=");
Serial.println(__DATE__);
} else if (parse) {
Serial.println("DS1307 Communication Error :-{");
Serial.println("Please check your circuitry");
} else {
Serial.print("Could not parse info from the compiler, Time=\"");
Serial.print(__TIME__);
Serial.print("\", Date=\"");
Serial.print(__DATE__);
Serial.println("\"");
}
}
void loop() {
}
bool getTime(const char *str)
{
int Hour, Min, Sec;
if (sscanf(str, "%d:%d:%d", &Hour, &Min, &Sec) != 3) return false;
tm.Hour = Hour;
tm.Minute = Min;
tm.Second = Sec;
return true;
}
bool getDate(const char *str)
{
char Month[12];
int Day, Year;
uint8_t monthIndex;
if (sscanf(str, "%s %d %d", Month, &Day, &Year) != 3) return false;
for (monthIndex = 0; monthIndex < 12; monthIndex++) {
if (strcmp(Month, monthName[monthIndex]) == 0) break;
}
if (monthIndex >= 12) return false;
tm.Day = Day;
tm.Month = monthIndex + 1;
tm.Year = CalendarYrToTm(Year);
return true;
}
//---------------------------------------------------//


After uploading the code, open the serial monitor, it will say that the time is set.
Once the above step is accomplished successfully move on to next.
Now upload the below code to Arduino.

Main program Code:



//------------Program developed by sakshyam_Bastakot------//

#include<EEPROM.h>
#include <Wire.h>
#include <TimeLib.h>
#include <DS1307RTC.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(9, 8, 7, 6, 5, 4);

//------ Set Bell Timings from hours 1 to 23 hrs---------//

//---- 1st bell ------//
const int h1 = 0; //hours
const int m1 = 0; //Minutes
//---- 2nd bell ------//
const int h2 = 0;
const int m2 =  0;
//---- 3rd bell ------//
const int h3 = 0;
const int m3 = 0;
//---- 4th bell ------//
const int h4 = 0;
const int m4 = 0;
//---- 5th bell ------//
const int h5 = 0;
const int m5 = 0;
//---- 6th bell ------//
const int h6 = 0;
const int m6 = 0;
//---- 7th bell ------//
const int h7 = 0;
const int m7 = 0;
//---- 8th bell ------//
const int h8 = 0;
const int m8 = 0;
//---- 9th bell ------//
const int h9 = 0;
const int m9 = 0;
//---- 10th bell ------//
const int h10 = 0;
const int m10 =0;
//---- 11th bell ------//
const int h11 = 0;
const int m11 = 0;
//---- 12th bell ------//
const int h12 = 0;
const int m12 = 0;
//---- 13th bell ------//
const int h13 = 0;
const int m13 = 0;
//---- 14th bell ------//
const int h14 = 0;
const int m14 = 0;
//---- 15th bell ------//
const int h15 = 0;
const int m15 = 0;
//---- 16th bell ------//
const int h16 = 0;
const int m16 = 0;
//--------------- bell ring lenght in seconds -------//
const int Lenght = 3; //in seconds
//-------------------------- -------------------------//


#include<EEPROM.h>
#include <Wire.h>
#include <TimeLib.h>
#include <DS1307RTC.h>

int i = 0;
int H = 0;
int M = 0;
int S = 0;
int setting_value;
const int bell = 10;
const int P = A3;
const int N = A2;
const int setting_address = 0;
const int over_ride_off = 11;
boolean bell_status = true;
boolean Over_ride = true;

void setup()
{
lcd.begin(16, 2);
Serial.begin(9600);
Serial.println("//********//Automatic_School_Bell_System_Developed_BY_Sakshyam_Bastakoti//********//");
delay(100);
Serial.println("");
pinMode(P, OUTPUT);
pinMode(N, OUTPUT);
pinMode(bell, OUTPUT);
pinMode(over_ride_off, INPUT);
digitalWrite(P, HIGH);
digitalWrite(N, LOW);
digitalWrite(over_ride_off, HIGH);
attachInterrupt(0, over_ride, RISING);
attachInterrupt(1, bell_setting, RISING);
if (EEPROM.read(setting_address) != 1)
{
bell_setting();
}
}
void loop()
{
tmElements_t tm;
lcd.clear();
if (RTC.read(tm))
{
H = tm.Hour;
M = tm.Minute;
S = tm.Second;

lcd.setCursor(0, 0);
lcd.print("TIME:");
lcd.print(tm.Hour);
lcd.print(":");
lcd.print(tm.Minute);
lcd.print(":");
lcd.print(tm.Second);
lcd.setCursor(0, 1);
lcd.print("DATE:");
lcd.print(tm.Day);
lcd.print("/");
lcd.print(tm.Month);
lcd.print("/");
lcd.print(tmYearToCalendar(tm.Year));

 
Serial.print("TIME:");
Serial.print(tm.Hour);
Serial.print(":");
Serial.print(tm.Minute);
Serial.print(":");
Serial.print(tm.Second);
Serial.print("---------");
Serial.print("DATE:");
Serial.print(tm.Day);
Serial.print("/");
Serial.print(tm.Month);
Serial.print("/");
Serial.println(tmYearToCalendar(tm.Year));
} else {
if (RTC.chipPresent())
{
  
lcd.setCursor(0, 0);
lcd.print("RTC stopped!!!");
lcd.setCursor(0, 1);
lcd.print("Run SetTime code");
Serial.println("RTC stopped!!! -- Run SetTime code");


} else {

lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Read error!");
lcd.setCursor(0, 1);
lcd.print("Check circuitry!");

Serial.println("Read error!");
Serial.println("Check circuitry!");


}
}
if (EEPROM.read(setting_address) == 1)
{
if (H == 0 && M == 0 && S == 0)
{
digitalWrite(bell, LOW);
}
if (H == h1 && M == m1 && S == 0)
{
for (i = 0; i < Lenght; i++)
{
digitalWrite(bell, HIGH);
delay(1000);
}
digitalWrite(bell, LOW);
i = 0;
}
if (H == h2 && M == m2 && S == 0)
{
for (i = 0; i < Lenght; i++)
{
digitalWrite(bell, HIGH);
delay(1000);
}
digitalWrite(bell, LOW);
i = 0;
}
if (H == h3 && M == m3 && S == 0)
{
for (i = 0; i < Lenght; i++)
{
digitalWrite(bell, HIGH);
delay(1000);
}
digitalWrite(bell, LOW);
i = 0;
}
if (H == h4 && M == m4 && S == 0)
{
for (i = 0; i < Lenght; i++)
{
digitalWrite(bell, HIGH);
delay(1000);
}
digitalWrite(bell, LOW);
i = 0;
}
if (H == h5 && M == m5 && S == 0)
{
for (i = 0; i < Lenght; i++)
{
digitalWrite(bell, HIGH);
delay(1000);
}
digitalWrite(bell, LOW);
i = 0;
}
if (H == h6 && M == m6 && S == 0)
{
for (i = 0; i < Lenght; i++)
{
digitalWrite(bell, HIGH);
delay(1000);
}
digitalWrite(bell, LOW);
i = 0;
}
if (H == h7 && M == m7 && S == 0)
{
for (i = 0; i < Lenght; i++)
{
digitalWrite(bell, HIGH);
delay(1000);
}
digitalWrite(bell, LOW);
i = 0;
}
if (H == h8 && M == m8 && S == 0)
{
for (i = 0; i < Lenght; i++)
{
digitalWrite(bell, HIGH);
delay(1000);
}
digitalWrite(bell, LOW);
i = 0;
}
if (H == h9 && M == m9 && S == 0)
{
for (i = 0; i < Lenght; i++)
{
digitalWrite(bell, HIGH);
delay(1000);
}
digitalWrite(bell, LOW);
i = 0;
}
if (H == h10 && M == m10 && S == 0)
{
for (i = 0; i < Lenght; i++)
{
digitalWrite(bell, HIGH);
delay(1000);
}
digitalWrite(bell, LOW);
i = 0;
}
if (H == h11 && M == m11 && S == 0)
{
for (i = 0; i < Lenght; i++)
{
digitalWrite(bell, HIGH);
delay(1000);
}
digitalWrite(bell, LOW);
i = 0;
}
if (H == h12 && M == m12 && S == 0)
{
for (i = 0; i < Lenght; i++)
{
digitalWrite(bell, HIGH);
delay(1000);
}
digitalWrite(bell, LOW);
i = 0;
}
if (H == h13 && M == m13 && S == 0)
{
for (i = 0; i < Lenght; i++)
{
digitalWrite(bell, HIGH);
delay(1000);
}
digitalWrite(bell, LOW);
i = 0;
}
if (H == h14 && M == m14 && S == 0)
{
for (i = 0; i < Lenght; i++)
{
digitalWrite(bell, HIGH);
delay(1000);
}
digitalWrite(bell, LOW);
i = 0;
}
if (H == h15 && M == m15 && S == 0)
{
for (i = 0; i < Lenght; i++)
{
digitalWrite(bell, HIGH);
delay(1000);
}
digitalWrite(bell, LOW);
i = 0;
}
if (H == h16 && M == m16 && S == 0)
{
for (i = 0; i < Lenght; i++)
{
digitalWrite(bell, HIGH);
delay(1000);
}
digitalWrite(bell, LOW);
i = 0;
}
}
delay(1000);
}
void over_ride()
{
lcd.clear();
while (Over_ride)
{
digitalWrite(bell, HIGH);
lcd.setCursor(0, 0);
lcd.print("Press Exit to");
lcd.setCursor(0, 1);
lcd.print("Stop the bell!!!");
Serial.println("Press Exit to Stop --- Stop the bell!!!");

if (digitalRead(over_ride_off) == LOW)
{
Over_ride = false;
digitalWrite(bell, LOW);
}
}
Over_ride = true;
}
void bell_setting()
{
setting_value = 0;
EEPROM.write(setting_address, setting_value);
lcd.clear();
while (bell_status)
{
lcd.setCursor(0, 0);
lcd.print("Bell is Disabled");
lcd.setCursor(0, 1);
lcd.print("Press Exit.");
Serial.println("Bell is Disabled Press Exit");

if (digitalRead(over_ride_off) == LOW)
{
bell_status = false;
}
}
bell_status = true;
setting_value = 1;
EEPROM.write(setting_address, setting_value);
}
//------------Program developed by Sakshyam_Bastakoti------------//


Once you have uploaded the code above, the time in hours will be displayed. This marks the end of the program code.

Download All Files: Link

How to use this Automatic bell system:


1. To proceed, ensure that you have a fully functioning hardware setup.

2. Begin by uploading the "time setting" code and launching the serial monitor. Then, in the main program, specify the exact time at which the relay should be triggered. 

//---- 1st bell ------//

const int h1 = 0; //hours

const int m1 = 0; //Minutes
//---- 2nd bell ------//
const int h2 = 0;
const int m2 = 0;
//---- 3rd bell ------//
const int h3 = 0;
const int m3 = 0;
//---- 4th bell ------//
const int h4 = 0;
const int m4 = 0;

//---------------------//


• Same for h1 to h16 and m1 to m16.
• If you want to disable some bell leave value h = 0 and m = 0 for example: h5 = 0 and m5 = 0, zero will disable that particular bell.

• Set h1 in hours from 1 to 23 hours and m1 in minutes from 0 to 59.

3. Choose the time duration for the bell to ring on and off by modifying this code line:

//--------------- bell ring length in seconds -------//

const int Length = 3; //in seconds

The default time is set to 3 seconds. Once the set time is reached, the relay will turn on for 3 seconds before turning off. Adjust this value as needed.

4. Upload the updated code to your Arduino.

5. Use the "bell disable button" to turn off the bell and the "Exit" button to turn it back on.

6. To ring the bell manually, use the "manual bell switch" and to stop the bell, press "exit".

Working prototype images and video:

 Initial stage of Assembling



Assembly of Electronics




All Round View




finial product





conclusion:

In conclusion, the automatic school bell system using Arduino brings significant benefits to the education system. This innovative solution optimizes the daily operations of educational institutions by providing a streamlined and efficient way to manage bell-ringing schedules. The integration of an Arduino board, a real-time clock module, and a 16 x 2 display allow for easy programming and customization of up to 16 bell rings per day. With precise timekeeping and reliable automation, this system ensures punctuality in transitioning between classes and activities, creating a more organized learning environment. By reducing the manual effort required to manage the bell system, teachers and administrators can focus more on their core responsibilities, ultimately enhancing the overall educational experience for students. Additionally, the project's accessibility and adaptability make it a cost-effective solution that can be easily implemented in various educational settings, reaffirming its value in modernizing and optimizing the education system.


The project is now complete. If you have any questions or concerns, please don't hesitate to ask in the comments section.

Previous Post Next Post