Bài Report IOT102
Bài Report IOT102
1st Tran Le Nhat Vien, 2nd Nguyen Thanh Trung, 3rd Nguyen Dinh Khoi,
4th Tran Trong Tan, and Duc Ngoc Minh Dang
FPT University, Ho Chi Minh Campus, Vietnam
{vientnlse184359, trungntse183755, khoindse180300, tanttse184357}@fpt.edu.vn, and [email protected]
Abstract
The measurement and management of time have played a crucial role throughout human history, evolving significantly from
ancient practices to modern advancements in technology. Early methods relied on natural phenomena like the sun’s position and
seasonal changes, essential for activities such as agriculture and religious observances. Progress continued with the development
of devices such as sundials, water clocks, and later mechanical clocks during medieval times in Europe, marking important steps
toward more precise and standardized timekeeping.
The ongoing evolution of timekeeping underscores its enduring importance in shaping how societies structure daily routines,
work schedules, and scientific endeavors. From ancient methods to modern innovations, the quest for accuracy and efficiency in
time measurement remains a constant theme throughout human history.
I. I NTRODUCTION
The Digital Clock Project is an innovative project that combines the DS1307 Real-Time Clock (RTC), Arduino, and the
ESP8266 Wi-Fi module to produce a sophisticated and highly functional smart clock. By leveraging the strengths of these
components, this project provides a precise, reliable, and internet-based timekeeping system.
The central processing unit for controlling the clock’s various inputs and outputs is the Arduino microcontroller, which also
serves as the project’s main component. Due to its open-source nature and strong community support, Arduino is a popular
and versatile choice for both novice and experienced hobbyists in the electronics and embedded systems fields.
The clock’s functionality is enhanced by the ESP8266 module, which provides internet connectivity. This feature allows the
clock to synchronize with internet time servers to ensure accurate timekeeping.
II. M AIN P ROPOSAL
In the 20th century, the advent of electronic and atomic clocks brought revolutionary levels of precision, supporting global
positioning systems and international time standards. The digital age further transformed access to time through ubiquitous
devices like smartphones, computers, and smartwatches, integrating scheduling and time management tools seamlessly into
daily life. Contemporary innovations such as the Internet of Things (IoT) and wearable technology have continued to personalize
and enhance the integration of timekeeping in everyday activities.
A. System Models and Block Diagram
The developed system integrates both hardware and software components. It incorporates sensors: temperature. The Arduino
Uno and NodeMCU serve as IoT development platforms, utilizing the NodeMCU’s integrated Wi-Fi module to take data from
a local host server. A display unit is employed to present the system’s outputs. Figure 1 illustrates a block diagram of the
system configuration.
B. Components and Peripheral Devices
TABLE I
S YSTEM ’ S COMPONENTS AND PERIPHERAL DEVICES
Components/devices ID/remarks
Arduino Uno R3 ATmega328P based
NodeMCU ESP8266
Liquid-crystal Display LCD
Temperature Sensor LM35
Speaker Buzzer Piezo
Real Time Clock DS1307
The advanced control system integrates essential electronic components, including an ESP8266 module and a DS1307 Real-
Time Clock (RTC), to enhance its functionality. The ESP8266 serves as a powerful microcontroller with integrated Wi-Fi
capabilities, enabling seamless connectivity to local networks and the internet. This connectivity allows the system to receive
real-time data updates and commands, ensuring efficient and responsive operation based on current environmental conditions
and user inputs.
C. Software Programming
The code integrates various hardware components and functionalities using an Arduino and an ESP8266. The Arduino code
manages several sensors and devices such as a temperature sensor, an LCD for displaying data, a buzzer for alarms, and a
button for switching displays. It also interfaces with an RTC (Real-Time Clock) module to keep track of time and set alarms.
When the Arduino receives commands via I2C from the ESP8266, it processes these commands to either set an alarm or
adjust the current time. The main loop of the Arduino code checks the button state to cycle through different displays on the
LCD and periodically checks if the current time matches the alarm time to trigger the buzzer.
The ESP8266 code sets up a WiFi access point and a web server to serve different HTML pages for setting the alarm and the
time. When a user submits a form on these web pages, the ESP8266 processes the input and sends the appropriate command
to the Arduino via I2C. The ESP8266 also synchronizes the current time with an NTP server to ensure accurate timekeeping
and can handle weather data retrieval.
D. Real-Time Clock and Sensor Setup
1) RTC and Display: The DS1307 RTC module maintains accurate time and date, even during power loss. A LiquidCrystal
display shows time and temperature with connections to digital pins 2 through 12. I2C communication initializes the RTC,
displaying an error if not found.
1 RTC_DS1307 rtc;
2 char daysOfTheWeek[7][12] = {
3 "Sun",
4 "Mon",
5 "Tue",
6 "Wed",
7 "Thu",
8 "Fri",
9 "Sat"
10 };
11
7 // DS1307
8 if (! rtc.begin()) {
9 Serial.println("Couldn’t find RTC");
10 while (1);
11 }
12 // sets the RTC to the date & time on PC this sketch was compiled
13 rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
14
15 // other devices
16 pinMode(buzzerPin, OUTPUT);
17 pinMode(buttonPin, INPUT);
18 lcd.begin(16, 2);
19 }
Listing 2. RTC Setup
2) Temperature: The temperature sensor (LM35) connects to analog pin A0. The following example demonstrates initial-
ization:
1 const int sensorPin = A0;
2 float sensorValue;
3 float voltageOut;
4 float temperatureC;
Listing 3. Temperature Sensor Initialization
3) ESP8266 Access and Transfer Data Locally: To access and modify data between Arduino and ESP8266, we use a local
website connected to a WiFi:
1 // Create Access Point WiFi ESP8266
2 const char* ssid = "FPTU_Library";
3 const char* password = "12345678";
Listing 5. WiFi Setup
E. Programming Flowchart
B. Experimental Results
The experimental results demonstrate the successful implementation of the digital clock system integrated with the DS1307
Real-Time Clock (RTC) and LM35 temperature sensor. The system was tested under various conditions to evaluate its
functionality and accuracy.
Fig. 7. Fetch weather information.
Fig. 8. Fetch the room temperature.
Fig. 9. Adjust the current time.
TABLE II
AUTHOR ’ S CONTRIBUTION
R EFERENCES
[1] J. Tellez, F. Morilla, and J. Garcia, “Design of an IoT-based Temperature and Humidity Monitoring System,” Journal of Sensors, vol. 2016, pp. 1-10,
2016, doi: 10.1155/2016/7190495.
[2] H. Simon, Introduction to Arduino: A Hands-On Approach, Springer, 2020.
[3] K. Pahlavan and P. Krishnamurthy, “Wireless Information Networks,” Journal of Wireless Communications and Mobile Computing, vol. 2019, pp. 1-10,
2019, doi: 10.1155/2019/8579312.
[4] A. Kumar and R. Sharma, “IoT-based Smart Home Automation System,” in 2021 IEEE International Conference on Computer Science and Network
Technology (ICCSNT), 2021, pp. 90-94, doi: 10.1109/ICCSNT53734.2021.9671984.
[5] Y. Zhang and X. Li, “Real-Time Clock Synchronization for Wireless Sensor Networks,” IEEE Transactions on Wireless Communications, vol. 17, no.
10, pp. 6401-6411, 2018, doi: 10.1109/TWC.2018.2873548.