STM32-Based Intelligent Desk Lamp Design and Implementation
←
→
Page content transcription
If your browser does not render page correctly, please read the page content below
Open Access Library Journal 2021, Volume 8, e7754 ISSN Online: 2333-9721 ISSN Print: 2333-9705 STM32-Based Intelligent Desk Lamp Design and Implementation Yuyang Lian, Dong Wu*, Zelin Ji Department of Mechanical and Control Engineering, Guilin University of Technology, Guilin, China How to cite this paper: Lian, Y.Y., Wu, D. Abstract and Ji, Z.L. (2021) STM32-Based Intelligent Desk Lamp Design and Implementation. Table lamps have long been one of the necessities of people’s life and work, as Open Access Library Journal, 8: e7754. they appear and are used very frequently in household lighting equipment. https://doi.org/10.4236/oalib.1107754 Table lamps provide the right amount of light for people to work and study in Received: July 13, 2021 their daily lives. Compared with the general traditional desk lamp, intelligent Accepted: August 6, 2021 desk lamps provide a more comfortable lighting environment for people to Published: August 9, 2021 read, work and study. The paper firstly analyzes the system scheme of the intel- ligent desk lamp and completes the hardware selection, using STM32F103C8T6 Copyright © 2021 by author(s) and Open Access Library Inc. as the main control, HR-SR501 module as the pyroelectric module of the in- This work is licensed under the Creative telligent desk lamp. HC-SR04 ultrasonic distance measures sensor for dis- Commons Attribution International tance measurement. Bluetooth module HC-05 is the wireless control module License (CC BY 4.0). of the lamp. Then the interface circuit design of each functional module is http://creativecommons.org/licenses/by/4.0/ Open Access completed by drawing schematic diagram through Altium Designer. The program design of each function by drawing program flowchart is completed. The program is written through keil5. Finally, the automatic adjustment of lighting intensity, posture reminder, human infrared sensing and wireless control of the intelligent lamp are realized through a combination of hard- ware and software. Desk lamp has the advantages of simple operation, energy saving, sitting posture reminder, automatic dimming and wireless control, etc. Compared with the general traditional desk lamp, it solves the problems of traditional desk lamp control not simple enough, high energy consumption and being easy to cause visual fatigue or myopia; therefore, it has high appli- cation value and market value. Subject Areas Automata Keywords STM32, Intelligent Control, Table Lamp, Sensor, Wireless Control DOI: 10.4236/oalib.1107754 Aug. 9, 2021 1 Open Access Library Journal
Y. Y. Lian et al. 1. Introduction Along with the continuous development of technology and people’s rising stan- dard of living and quality of life, people have begun to put forward more and more demands for home appliances, and the demand has gradually changed from the initial single function to the intelligent and simple operation design of home appliances. Compared with traditional home appliances, smart appliances can not only be set and controlled according to the user’s needs, but can also perform personalized operations according to the user’s home environment and habits [1]. Lighting affects the efficiency of work and study, and when people are in poor lighting conditions, they will be less efficient in work and study due to visual fa- tigue and other problems [2]. While desk lamps are created for similar activities such as reading and writing, it is a movable lamp that provides localized lighting [3]. In modern society, myopia caused by poor sitting posture such as hun- chback is very common among adolescents, which causes a lot of inconvenience in daily life. As a household lighting device, the desk lamp is used very frequently and is essential in people’s daily study and work. Traditional desk lamps only have simple lighting functions and require manual control of the lamp, which is a single function [4] [5]. Those intelligent desk lamps with sitting sensing func- tion can provide more scientific and intelligent lighting conditions [6]. Smart desk lamps with pyroelectric detection can detect biological activity around them, and when there is no activity around, the lamp will turn off the lighting after a time delay [7]. As a smart desk lamp, although most of them have inte- grated multiple functions that allow the lamp to be used in different situations, the core function of the lamp is still the ability to provide a comfortable lighting environment for the user [8]. As the first electric lamp, the incandescent lamp is heated by energizing the filament, and when it becomes incandescent, the visible light is emitted by the thermal radiation generated by the filament. Because the light emitted is very close to the spectrum of the sun, it can faithfully restore the original color of the displayed object [9]. Fluorescent lamps, also known as fluorescent lamps, rely on phosphors on the inside of the lamp to adjust the color of light, and changing the type of phosphor can change the color of light emitted [10]. And in the process of bonding, light will be generated, the light-emitting phenomenon is caused by the release of photons [11]. Nowadays, the mainstream light sources are using LED lights for lighting. The task of this project is to use the STM32 microcontroller as the control core, combined with the sensor module, design a lamp to achieve automatic lighting, intelligent dimming, remind to change the sitting posture, night light and other functions, through the wireless sensor transmission data and cell phone APP for real-time control of the lamp, with the collection of environ- mental parameters around the function of intelligent desk lamp, to achieve energy saving and convenience purposes. DOI: 10.4236/oalib.1107754 2 Open Access Library Journal
Y. Y. Lian et al. 2. Overall Design of Smart Desk Lamp 2.1. The Working Principle and System Structure Diagram of Intelligent Desk Lamp The intelligent desk lamp designed in this project is based on STM32F103C8T6 microprocessor as the core control unit, with several sensor modules to achieve various functions. The main modules of the control system of this design are: light intensity detection module, distance measurement module, pyroelectric module, alarm module, power supply module, button module, wireless commu- nication module and lighting module. The photoresistor sensor detects the light intensity of the environment and converts the detected light intensity into a spe- cific numerical value, the HC-SR501 pyroelectric sensor detects the activity of people, the HC-SR04 ultrasonic distance sensor detects the distance between the user and the lamp, the buzzer reminds the user, the keypad adjusts the lighting intensity of the lamp, and the HC05 Bluetooth serial module to establish a con- nection between the lamp and the cell phone for wireless communication. After the wireless connection is established through the Bluetooth module, the lighting intensity of the lamp can be adjusted and the current mode of the lamp can be changed wirelessly through the cell phone APP. The lighting part uses a triode to drive 12 LEDs to achieve lighting, and adjusts the lighting intensity through PWM. For the power supply, 5.0 USB power supply is used, and the 5.0 volt vol- tage is stepped down to 3.30 volts through the step-down module, of which 3.30 volts is provided to the microcontroller, Bluetooth module and light detection module, and 5 volts is supplied to the HC-SR501 pyroelectric module and HC-SR04 ultrasonic module, as shown in Figure 1. 2.2. Functional Design of Smart Desk Lamp This design of smart table lamp receives and processes various information by microcontroller, and adjusts the lighting brightness of the lighting LED lamp according to the information. The smart desk lamp has three working modes, Figure 1. System structure diagram. DOI: 10.4236/oalib.1107754 3 Open Access Library Journal
Y. Y. Lian et al. namely manual operation mode, intelligent adjustment lighting mode and night light mode. After the lamp is powered on, the lamp is in manual operation mode by default or reset, and the user can switch the operation mode of the lamp through the mode switch button. In manual operation mode, users can press the lighting switch button to adjust the lighting intensity of the lamp, or use Blu- etooth to connect the phone to the lamp and adjust the lighting intensity of the lamp and switch the lamp mode through the mobile app. In the intelligent ad- justment of lighting mode, the lamp will detect whether there is human activity around, and if there is activity, it will detect the brightness of the surrounding environment and automatically adjust the lamp lighting according to the envi- ronmental brightness. After switching to night light mode, when the external light is low, the desk lamp will turn on the pyroelectric sensor and ultrasonic distance measurement mode, and when the human body is detected to be close to the desk lamp, the desk lamp will turn on a light with lower brightness to faci- litate users’ activities at night. In addition to the three modes, the lamp also has a distance measurement function, which can be controlled by a button to turn it on or off. When the distance measurement function is turned on, the lamp can detect the distance between the user and the lamp in real time to determine whether the user’s sitting posture is reasonable, and if it is not, the lamp will trigger a buzzer alarm to remind the user to adjust the sitting posture. 3. Hardware Design of Smart Desk Lamp 3.1. Hardware Selection and Justification 3.1.1. Selection and Demonstration of the Main Control Chip As the 8051 microcontroller has less timer function and no ADC function, an external analog-to-digital converter chip is needed to convert the analog value measured by the photoresistor sensor to a specific digital. 8051 microcontroller has a low clock frequency of less than 12 MHz and poor performance. The mi- crocontroller selected for this design is the STM32F103C8T6, which has a higher clock frequency (up to 72 MHz) and strong performance. 3.1.2. Selection and Justification of Pyroelectric Sensors The principle of HR-SR501 module is the same as that of HR-SR602 module, but the sensing range of HR-SR501 module is larger (up to 7 meters). Compared with the HR-SR602 module, the HR-SR501 module is more convenient to adjust the delay time by simply turning the corresponding knob, as shown in Figure 2. The pins of the HC-SR501 pyroelectric human sensor module are shown in Figure 3. As seen in Figure 3, the sensor’s pins include a power supply pin, a time delay pin, a sensitivity adjustment pin, and a trigger method pin. 3.1.3. Selection and Justification of the Distance Measurement Module Infrared distance measurement module GP2Y0A21YK0F, which uses triangula- tion, and its output voltage value can be converted to get the distance. The sen- sor can be used for distance measurement, obstacle avoidance, etc. The mea- DOI: 10.4236/oalib.1107754 4 Open Access Library Journal
Y. Y. Lian et al. surement range is between 10.0 cm and 80.0 cm. Compared with the HC-SR04 module, its distance measurement range is small, but its accuracy is high. Therefore, the HC-SR04 ultrasonic distance measurement sensor of Option 1 is selected, as shown in Figure 4. 3.1.4. Selection and Justification of Light Detection Module The photoresistors are very sensitive to light, the stronger its light the lower the resistance. Due to the characteristic of its resistance value changing with the light intensity, the photoresistor has gained wide application. The change in the resistance value of the photoresistor changes the voltage of the photoresistor, and the change in its voltage and can respond to the light intensity of the envi- ronment. However, since its voltage change is an analog quantity, it needs to be converted to a digital quantity by AD before it can be used, as shown in Figure 5. Figure 2. HC-SR501 pyroelectric human sensor module. Figure 3. The pins of the HC-SR501 pyroelectric human sensor module. Figure 4. HC-SR04 ultrasonic distance measuring sensor. DOI: 10.4236/oalib.1107754 5 Open Access Library Journal
Y. Y. Lian et al. Figure 5. Photoresistor sensor. Figure 6. HC-05 bluetooth module. 3.1.5. Selection and Justification of Wireless Communication Modules HC-05 Bluetooth module compared with ESP8266wifi module, the price of both is basically the same, but the development and programming of HC-05 Blu- etooth module is much easier than ESP8266wifi module, because ESP8266wifi module itself is a microcontroller, you need to develop and program it separately. Therefore, this design selects the Bluetooth module HC-05 as the wireless con- trol module of the desk lamp, as shown in Figure 6. 3.2. Hardware Circuit Schematic The pins of STM32F103C8T6 that need to be used in this design of smart desk lamp are: the output port of pyroelectric module is connected to PA8 port of microcontroller, the control input of ultrasonic distance measurement module is connected to PA4 port of microcontroller, and the output of ultrasonic module is connected to PB6 pin. The analog output of the photoresistor sensor is con- nected to the PA0 port of the microcontroller. The transmit and receive pins of the Bluetooth module accumulate to pins PB10 and PB11 of the microcontroller, respectively, and use the USART3 function of STM32 to communicate with the microcontroller. The keypad module uses the microcontroller’s PB12 port to re- ceive external voltage. The LED lighting module uses the microcontroller’s PA6 port to output PWM square wave, thus regulating the lighting. The Intelligent desk lamp microcontroller I/O port and resource allocation table is shown in Table 1. DOI: 10.4236/oalib.1107754 6 Open Access Library Journal
Y. Y. Lian et al. This design uses STM32F103C8T6 minimum system board as the main con- trol core, with manual control, intelligent control and wireless control functions. In manual control, the lighting control of the lamp can be completed by using only one button; in smart control mode, the lamp can adjust the lighting bright- ness according to the brightness of the surrounding environment and the state of the user; in wireless control, the lighting of the lamp can be controlled by Blu- etooth using a cell phone. The overall design block diagram is shown in Figure 7. Table 1. Intelligent desk lamp microcontroller I/O port and resource allocation table. Modules I/O Ports Microcontroller Resources Pyroelectric Infrared Sensor Module PA8 I/OPorts HC-SR04 Ultrasonic Module PA4, PB6 Timer TIM4, I/O ports Photoresistor Sensor PA0 ADC HC05 Bluetooth Module PB10, PB11 USART3 LED Lighting PA6 TimerTIM3 PWM Push button module PB12 I/O Figure 7. Overall design block diagram. DOI: 10.4236/oalib.1107754 7 Open Access Library Journal
Y. Y. Lian et al. 4. Software Design of Smart Desk Lamp There are three control modes available in this design: one is to use the buttons on the lamp, which is also the default mode; one is the intelligent dimming mode, in which the lamp will automatically adjust the lighting in combination with the surrounding light intensity and the activities of people around the lamp without human intervention; and one is the night light mode, which can provide lighting for users when they are active at night. After choosing the manual mode, the lighting can only be adjusted by the buttons on the lamp, or wirelessly adjust the lamp lighting through the cell phone APP, and the cell phone wireless control and button control can be used at the same time, without conflict. After selecting the control mode of intelligent lighting adjustment, the lamp will automatically adjust the lamp lighting ac- cording to the current specific environmental brightness when people are de- tected and the current light is low; if the posture reminder function is turned on at the same time, the lamp will issue a reminder when it detects the user's poor posture to remind the user to correct the posture; after switching to night light mode, the lamp can be used as a bedside lamp and other night lighting tools, and when the user is up and moving in the dark, the lamp will turn on. When users get up and move around in the dark, the lamp will turn on the lower lighting to provide light to users and not to affect other users’ sleep because of too bright light. The flow chart of the main program is shown in Figure 8. Figure 8. Main program flow chart. DOI: 10.4236/oalib.1107754 8 Open Access Library Journal
Y. Y. Lian et al. 5. Product Commissioning 5.1. Commissioning of Pyroelectric Sensors When the pyroelectric module is powered on, an LED is connected to its output pin, and the LED will light up when the pyroelectric module is working normally. As shown in Figure 9, the LED lights up after triggering the pyroelectric mod- ule. 5.2. Commissioning of Ultrasonic Sensors For the detection of ultrasonic module, according to its working principle, it is difficult to judge whether it can work normally by hardware circuit only, so it is necessary to burn the test program to the microcontroller and connect the pins of ultrasonic module to the corresponding pins of the microcontroller correctly. Then by constantly adjusting the distance between the object under test and the ultrasonic module, use the serial port to send the data to the computer side to see whether the output distance corresponds to the actual distance, so as to de- termine whether the ultrasonic module works properly. The ultrasonic module ranging data sheet is shown in Table 2. A total of six sets of experiments were conducted, and the test distances selected for the experiments were 10, 20, 40, 45, 60 and 100 cm. The measured values are shown in Table 2. The ultrasonic module can measure the distance within 80 cm, and the error is within 3 cm; when the measurement range exceeds 80 cm, the error is larger than 3 cm. Figure 9. Table lamp lights up after triggering pyroelectricity. Table 2. Ultrasonic module ranging data sheet. Time Distance (cm) Measured value (cm) 1 10 10.2 2 20 20.1 3 40 40.8 4 45 43.7 5 60 61 6 100 97.7 DOI: 10.4236/oalib.1107754 9 Open Access Library Journal
Y. Y. Lian et al. 6. Conclusions The main functions of the STM32-based intelligent desk lamp design required by this topic are as follows. 1) Manual control (keypad): In manual control mode, the lighting intensity of the desk lamp can be adjusted by the number of keystrokes, so as to select the appropriate lighting intensity. 2) Manual control (cell phone wireless control): In the manual control mode, the lighting of the lamp can be controlled wirelessly by cell phone. And in the manual control mode, the cell phone control and button control do not conflict, and can be seamlessly switched. 3) Intelligent dimming mode: In this mode, the intelligent desk lamp can au- tomatically adjust the lighting intensity of the lamp according to the ambient light intensity and whether there are people around. After detecting someone around, it will adjust the lamp lighting appropriately according to the current ambient light intensity. 4) Posture reminder mode: In this mode, the smart desk lamp can detect the distance from the user to the lamp through the ultrasonic distance measurement module. When the distance between the user and the lamp is detected to be too small and lasts for more than 3 seconds, the alarm system will issue a reminder to urge the user to stay away from the lamp, and the buzzer will end the alarm after the user stays away from the lamp. 5) Night light mode: In this mode, the smart desk lamp can be used as a night light. When the ambient brightness is low, when the desk lamp detects some- one’s activity nearby, it will turn on the lower brightness lighting to facilitate the user’s action in the dark, but the desk lamp lighting turns off after the user im- mediately. Acknowledgements This research was supported by the Doctoral Research Initiation Fund of Guilin University of Technology (GUTQDJJ2018068) and 2020 Guangxi University Middle-aged and Young Teachers’ Basic Research Ability Improvement Project (2020KY06024). Conflicts of Interest The authors declare no conflicts of interest. References [1] Wang, L. and Zheng, L. (2019) Design and Implementation of Wireless Control System for Home Table Lamp. Practical rural Technology, No. 6, 126. [2] Liu, J.Y., Xu, L.K. and Wang, J.H. (2020) Comprehensive Evaluation of Desk Lamp Lighting Based on Light Environment. Industrial Design, No. 4, 91-92. [3] Hu, S. and Lu, D. (2020) Design of a Rapid Testing System for Table Lamp Photo- metric Performance. Electromechanical Information, No. 11, 124-125. DOI: 10.4236/oalib.1107754 10 Open Access Library Journal
Y. Y. Lian et al. [4] Feng, M. (2017) Design of Intelligent Table Lamp System Based on 51 Microcon- troller. Electrical and Mechanical Engineering Technology, No. S2. [5] Xiong, Z. and Wang, R. (2016) Intelligent Learning Desk Lamp Design Based on STM32. Electronic World, No. 8, 160-161. [6] Luo, Y. (2020) An Intelligent Desk Lamp Design with Sitting Sensing Function. In- formation Recording Materials, 21, 131-132. [7] Qin, Z. (2020) Analysis of the Application of Microcontroller in the Field of Intelli- gent Home Appliances. China Equipment Engineering, No. 3, 31-33. [8] Song, J., Li, J. and He, X. (2019) New Thinking on the Development of Intelligent Reading and Writing Desk Lamp. Light Sources and Lighting, No. 3, 44-48. [9] Li, Z. (2016) Colin Fernandez. Incandescent Light Bulbs Are Expected to Be “Put Back in Service” with New Technology. China Lighting Appliance, No. 4, 42-43. [10] Zheng, X. (2019) How to Buy Table Lamps. Rural Pepsi, No. 16, 54-55. [11] Xia, W. (2018) The Characteristics, Applications and Prospects of LED Lights. Science and Technology Wind, No. 2, 115. DOI: 10.4236/oalib.1107754 11 Open Access Library Journal
You can also read