Cite

Introduction

Light consumption in daily life causes an unprecedented waste of electricity resources. Countries carry out research on this issue. Now, many products in the domestic market mainly use different step-down technologies to achieve energy saving, such as self-disaster transformers and magnetic saturation reactors, but these products have more or less problems. After the improvement, the equipment aging fast, eliminated products to the environment and other problems such as greater pollution.

This paper compares the control principle and main function structure of some indoor lighting control system, describes in detail the hardware structure of the indoor lighting control system and the design and implementation of the control system, and carries on various debugging [1].

The overall design

The traditional lighting control in China usually adopts manual control or timing control [2]. This method is time-consuming, inefficient, and will lead to a large degree of resource waste. The combination of camera monitoring and remote control greatly increases the cost of construction and will inevitably cause extravagance and waste of power resources [3].

Common domestic lighting control usually adopts some manual or timing control methods, such as the following common methods:

1: The lighting system is controlled manually, and the lighting device in a certain area is turned on or off by manual patrol, which is time-consuming and labor-intensive;

2: Use sound to control the lighting system, and use a sound sensor to judge whether the lighting device should be turned on. This method is inefficient, and all disturbances may cause the lighting device to work and cause a greater degree of resources waste;

3: Use optics to control the lighting system, mainly to control the lighting device according to the brightness in a certain area, this method is similar to method 2.

Although the traditional lighting device control methods have their own characteristics, they also have some shortcomings. Even some scenes with more lighting devices will be controlled by a combination of camera monitoring and remote control, which can indeed achieve better results, but this method greatly increases the cost of construction, and because this method is still manual Control, so it will inevitably still cause a lot of extravagance and waste of power resources [4].

In this paper, STM32F103 is used as the main control chip of the indoor light control system [4], and the design and implementation of the indoor light control system is carried out by combining DS3231, OLED, infrared detection and BH1750 light intensity detection modules. The BH1750 light intensity detection module detects the brightness of the current environment. DS3231 clock module is to realize the real-time display of time and working time. TCRT5000 infrared reflection detection module realizes the function of human body induction [5]. By conducting infrared reflection induction in a specific area, it automatically controls the opening or closing of indoor light control system [6]. OLED reminds users of the current state of indoor lighting control systems. The system framework is shown in Figure.1 below.

Figure 1.

System block diagram

System control chip

In the indoor lighting control system, the position of the system control chip can be said to be very important [7], similar to the human brain, the instructions for the actions of each part of the body come from this. The control chip of the indoor lighting control system not only needs to control its own modules, but also needs to control some externally extended modules, so that the entire indoor lighting control system can operate [8].

Through the characteristics of 51 series, 32 series, 15 series and other types of single-chip microcomputers, combined with the requirements of the indoor lighting control system, the selected control chip has the characteristics of high speed, low power consumption and anti-interference. In the design of this article, the selected control chip It is a STM32F103 single-chip microcomputer chip. For this single-chip microcomputer, all the above-mentioned features are possessed, and it has more advantages. STM32F103 is widely used in many smart home control systems such as rice cookers, washing machines, refrigerators, and air conditioners, especially in the application of simple or single-function small micro-control systems is very common.

Environmental testing unit

The processing of sensors and brightness in the indoor lighting control system is also not negligible [910]. In the design of the system in this paper, TCRT5000 is used to detect the human body in the current environment; BH1750 detects the brightness in the current environment in real time.

For the TCRT5000 photoelectric sensor module, it is an infrared reflective photoelectric switch realized by the TCRT5000 infrared photoelectric sensor. For the sensor, it is composed of two parts, the first is an infrared photodiode, and the second is a high-sensitivity phototransistor [11]. The output control signal can be reshaped by Schmitt circuit, which is reliable, safe and reliable. The stability is very good. When in use, the built-in infrared emitting diode in the sensor will continuously emit infrared rays.

When the intensity of the emitted infrared rays is low or there is no emission at all, then the photosensitive transistor will always be in an off state. At this time, the output terminal corresponding to the module will be in a low level state, and at the same time, for the indicator diode, it will always be in a extinguished state; if the detected object is in the detection range, then the infrared will be Is emitted back and has a greater intensity at the same time, then the phototransistor will be in a saturated state [12]. At this time, the output terminal corresponding to the module is in a high-level state, and the indicator diode will be lit.

Figure 2.

Infrared reflection module

According to the light intensity sensor model BH1750FVI, it is a digital light intensity sensor integrated chip in principle. The inside of the sensor is composed of four parts: ADC acquisition, photodiode, crystal oscillator and operational amplifier. For PD diodes, a photovoltaic effect is used to convert the input optical signal into an electrical signal, which is then amplified by an operational amplifier circuit, and then the voltage is collected by ADC, and then logic is used The circuit converts it into a 16-bit binary data, and then stores it in the internal register (it should be noted here that if the intensity of the light entering the light window is greater, the corresponding photocurrent will be greater.

At the same time, the voltage will be higher, so the voltage value can be used to judge the size of the light, but it should be noted that even if the voltage and the light intensity are corresponding, this relationship is not a proportional relationship, so the chip performs internally The corresponding linear processing, which also explains why not choose photodiodes, but choose integrated IC). At the same time, the sensor carries out the data line and the clock line. The microcontroller can use the I2C protocol to communicate with the sensor, can use the BH1750 working mode, and can also extract the illuminance data stored in the BH1750 register.

Clock module and display module

For the clock module model DS3231, it is an IPC real-time clock (RTC) in principle, with higher accuracy and lower cost, and an integrated temperature-compensated crystal oscillator (TCXO) is set inside. And crystals. For this device, there is a battery input terminal, after disconnecting the main power supply, it can still ensure that the timing is accurate enough. At the same time, through the use of an integrated crystal oscillator, the long-term accuracy of the device can be improved, and the number of components required in the production line can be reduced.

For, it can realize the provision of industrial grade and commercial grade temperature range, the number of pins used is 16 in total, and a 300mil so package is also used. RTC can maintain a variety of time parameters. If the number of days in the month does not exceed 31 days, the end of the month will be automatically adjusted and the leap year compensation function can also be realized.

The clock has two working formats, the first is 24 hours, and the second is 12 hours with AM\PM indication. Able to realize one programmable square wave and two programmable calendar alarm clock output. Both data and address can use the PC two-way bus to achieve a serial transmission, a voltage reference and a comparator that have completed temperature compensation to monitor the Vcc status, detect power failures, and provide reset output at the same time, In some necessary cases [13], it can realize automatic switching to the standby power supply. In addition, for the RST monitoring pin, it can also be used as a manual button to generate an external reset signal.

In the design of this article, the OLED display screen is chosen to design the display module [14]. This display screen has many names, and sometimes it is also called an organic light-emitting semiconductor. This display screen was researched by a scholar in 1979. The characteristic of OLED display technology is that it can realize self-luminescence, has a wide viewing angle, fast reflection speed and low power consumption. The disadvantage is that the price is more expensive.

Hardware circuit design

The hardware circuit of the indoor lighting control system is mainly composed of STM32F103C8T6 MCU, DS3231 clock module, infrared detection module circuit, OLED display module and lamp tube circuit [15]. Combined with the requirements of indoor lighting control system control chip with high speed, low power consumption and anti-interference characteristics, this paper chooses the model of STM32F103 MCU chip.

The OLED display module and BH1750 light intensity sensor can be used together to obtain the brightness value of the current environment, so as to control the chip for the next processing judgment and issue corresponding instructions. In the clock module, users can adjust the indoor lighting control system with their own needs. Infrared detection module is set in the entrance and exit infrared reflection sensor, detection personnel in and out, so as to determine the number of people in the room. The lamp tube circuit is the main display part of the indoor lighting control system. The specific hardware circuit design is as follows.

Infrared Detection Module Circuit

Infrared detection module is composed of STM32 and CTRT5000 infrared detection module. After the indoor lighting control system is powered on, the CTRT5000 starts to work when it works normally. The infrared detection of the current environment is continuously carried out and the results are sent to the control chip. The control chip changes the state of the indoor lighting control system according to the returned results. The connection circuit between the infrared detection module and STM32 is shown in Figure 3.

Figure 3.

Connection circuit between IR sensor and STM32

Light Intensity Sensor Circuit

The light intensity sensor circuit of the indoor lighting control system is used to detect the light intensity. The BH1750 sensor is built with four components: an ADC acquisition, a photosensitive diode, a crystal oscillator, and an operational amplifier.

For PD diode, the use of light born v effect according to the input optical signals into electrical signals, then through operation amplifier circuit amplification processing, through the ADC to acquisition of voltage, after using logic circuit transformation, makes it a 16-bit binary data, and then stored in internal registers. This sensor carries on the data line and the clock line extraction, the micro-controller can use I2C protocol to realize the communication between the sensor, can use the BH1750 working mode, but also can extract the BH1750 register stored in the illuminance data. The BH1750 communicates in five steps: Step 1: Sends a power-on command. Step 2: Send the measurement command. Step 3: Wait for the measurement. Step 4: Read the data. Step 5: Calculate the result. Finally, the light intensity data stored in the module is extracted by the master chip and displayed by the OLED.

OLED Display Circuit

The corresponding power supply input terminal of this module is VCC_IN, which supplies U1 and U4 circuits after depressurization by U2. A voltage of 7~7.5V is required to drive the OLED screen, which is provided by boosting the voltage through SSD1306's built-in charge pump. For SSD1306, it can support parallel, SPI and I2C serial protocols. This module is grounded by using BS0->BS2 pins, which have been set as SPI protocol and shared with U4 Chinese character library chip for SPI interface. During operation, the chip's corresponding chip pins are used to distinguish. During read and write operations, the CS pins corresponding to the chip will be set to a low-level state, which will be used as the corresponding display part of this project. OLED is connected to STM32 and BH1750 and DS3231. In addition to displaying normal working hours, it also displays brightness, number of people, current time, etc.

Rectifier Voltage Regulator Circuit

In the circuit of the lighting control system, AMS1117 series regulator has two versions, one is adjustable version, one is a variety of fixed voltage version, the role is to carry out 1A current output, while ensuring that the working pressure difference will not exceed 1V. The minimum differential pressure of the AMS1117 device is guaranteed to be less than or equal to 1.3V at the maximum output current, and to decrease as the load current decreases. SS34 is a patch Schottky diode used for instantaneous circuit rectification. The function of the rectifier circuit is to convert a kind of AC voltage in positive and negative changing state through a one-way conductivity of the diode, so that it becomes a one-way pulse voltage. Through the action of the AC power supply, the rectifier diode can achieve a periodic on or off state, by which the load can receive a pulse of direct current. Rectifier voltage regulator circuit is shown in Figure 4.

Figure 4.

Rectifier voltage regulator circuit

Software program design
System Software Design

In the research and development of any electronic product system, not only the design and implementation of hardware need to be emphasized, but the design and implementation of software programs are also equally important. At present, the development tools of various electronic systems can be described as a dazzling array of functions, but many senior developers still prefer to use KEIL for development, mainly because the pages are friendly and easy for developers to use since KEIL came out. Therefore, the software design part of the indoor lighting control system is also selected to be developed through KEIL and C language. Moreover, for the increasingly mature application and development of stm32 single-chip microcomputers, many basic codes and routines are also increasing, which makes it more convenient and simpler to develop STM32 single-chip microcomputers based on KEIL in C language.

The research and development of the software part of the indoor lighting control system mainly adopts a process from a single sub-module to an overall realization, which facilitates the timely detection of errors and reduces the time for follow-up inspections:

The design of the environmental brightness detection module: The BH1750 is mainly used to detect the current environmental brightness in real time and transmit the data to the program of the main control chip.

OLED display module design: Mainly connected with the main control chip, it can realize the real-time display of the feedback data on the screen, so that the user can understand the current information program.

Clock module design: DS3231 performs accurate time calculation, and feeds back the program of real-time time and current working time.

Human body detection module design: It is mainly a program that detects the human body in the current environment and makes corresponding operation feedback.

Each subroutine relationship is shown as Figure 5.

Figure 5.

Relationship among subroutines

Ambient Brightness Detection

Intelligent lighting detection of the current environment brightness subroutine mainly uses BH1750 to detect the current environment brightness. The BH1750 light detection sensor needs to be initialized and the environment brightness is detected according to the instructions of the control chip. The environmental brightness detection subroutine flow is shown in Figure 6.

Figure 6.

Brightness detection subroutine

When detecting the brightness of the current environment, this paper adopts the method of twice detecting, that is, continuously detecting the brightness of the current environment twice. When the two detection results are consistent, the collected ambient brightness value will be sent to the control chip; otherwise, “0” will be sent.

OLED Display Programming

The display module program of this design needs to be set for the IO connected by the MCU and the OLED module, and the IO port is set as output. Initialize the OLED module. Use functions to display characters and numbers on the OLED module.

Clock Subroutine Design

The design of the clock module program through STM32 analog I2C signal channel, then configure IO pin, and initialization function, in the main function to call the time data of the module.

Body Detection Subroutine

Human body detection subroutine is a characteristic function of intelligent lamp, which can intelligently detect whether there is human body in the current environment. The control chip will intelligently control the opening or closing operation of the intelligent lamp according to the detection results. The feature is very convenient and friendly, especially at night. The human body detection subroutine flow is shown in Figure 7.

Figure 7.

Human body detection subroutine diagram

Once powered on, the smart lamp circulates through the current environment. The intelligent light will be turned on automatically when someone is detected, and will be turned off when no human body is detected.

Main Programming

The main program of indoor lighting control system is to initialize and circularly call subroutines such as clock module, display module, human body detection module and light intensity detection module. In this way, the system can be ensured to run smoothly. The main program flow is shown in Figure 8.

Figure 8.

Main program flow

After the indoor lighting control system is powered on the initialization settings, mainly including the initialization of some sub-modules and the declaration of common functions and so on. Make circular calls to sub-modules and between sub-modules.

This chapter mainly uses KEIL and C language to research and develop the software part of the indoor lighting control system. In the process of designing and implementing subroutines such as clock module, display module, human body detection module, light intensity detection module, etc., not only the theoretical knowledge learned is consolidated, but also his practical ability has been strengthened.

Function implementation and testing

The selection of main modules and components of the indoor lighting control system and the design of software and hardware have been implemented in the previous chapters. The following is mainly to integrate and debug the completed indoor lighting control system

The indoor lighting control system is composed of STM32F103, human body detection module circuit (infrared detection), clock circuit, display circuit, light intensity detection circuit and lamp circuit.

The first thing to do during and after the realization of the electronic system is debugging. Debugging during the implementation process can help to find and correct the shortcomings in the implementation process as early as possible; and the debugging after the implementation can help to find and correct the shortcomings of the system in time. There are many ways to realize the debugging of electronic systems, including software and hardware debugging and module debugging, system joint debugging and simulation debugging.

This system adopts the method of single module debugging and simulation debugging. The indoor lighting control system is debugged through hardware debugging and software debugging respectively. Hardware debugging mainly uses multimeter, oscilloscope and other tools to check the hardware circuit of each submodule; software debugging mainly uses KEIL development tools to detect human body detection module subroutines, button module subroutines, various working mode subroutines, etc., as well as the entire indoor lighting The program of the control system is debugged and a file that can be recognized by the control chip is generated.

The whole system is shown in Figure 9.

Figure 9.

The photo of the system

After the power supply is connected, the system enters the standby state. The screen shows the current working status and ambient brightness with the number of detected people.

If the infrared detection module works properly and detects human body entering the room, the BH1750 module starts to work. If the ambient light is detected below the set value (500 lumens), the system will automatically turn on the light for brightness enhancement. If the infrared detection module detects a human body, but the ambient light is greater than the set value (500 lumens), the system will not turn on the light. The two cases are shown in Figure 10. and Figure 11 respectively.

Figure 10.

The ambient light is below the set value

Figure 11.

The ambient light intensity is too high

eISSN:
2470-8038
Language:
English
Publication timeframe:
4 times per year
Journal Subjects:
Computer Sciences, other