Based on STM32 self-developed multi-task + SpringBoot + Vue intelligent dimming system for agricultural greenhouses

It is often easy to feel exhausted after work, and do not get high-quality rest even on weekends. How do workers/students spend their weekends? Do you have any great ways to extend your weekends and time off from get off work? - The method is to accumulate more, post more blogs, and write out all the insights! ! , Next, I will show you a course design: the source code and hardware-side code will not be displayed. In the resource binding of this blog, if you are interested, you can refer to it. Front-end and back-end codes are saved in my resources

My main task:

1. The backend obtains the information developed by STM32 and can complete serial communication with it 

2. Write the front-end page and complete the interaction between the front-end and the front-end

3. (Hardware side) Write smart light supplement function according to custom parameters

Based on STM32 self-developed multi-task + SpringBoot + Vue 

Intelligent dimming system for agricultural greenhouses

Summary

        Prospering agriculture with science and technology is the only way for agricultural development, and the integration of communication technology into traditional agricultural greenhouse environmental monitoring is a typical representative of it. In order to ensure a reasonable lighting system for agricultural greenhouses, it is necessary to accurately monitor the light intensity in the greenhouses. Aiming at the disadvantages of current lighting intensity in the shed that cannot be adjusted, complex wiring, and high cost, an intelligent light intensity adjustment system based on stm32 technology is proposed.

        The intelligent lighting control system proposed by us can determine whether supplementary lighting is required according to the lighting threshold required by the currently set greenhouse, and can change the supplementary light intensity in real time according to the current lighting, and can observe the current greenhouse in real time on the client side natural light intensity and fill light intensity. If the threshold setting is unreasonable, the buzzer is also an alarm reminder.

Keywords: intelligent light supplement, stm32, SpringBoot, agricultural greenhouse

Based on STM32 Self developed multitasking + SpringBoot+Vue

Automatic lighting system for agricultural greenhouses

Abstract

        Promoting agriculture through technology is the necessary path for agricultural development, and the integration of communication technology into traditional agricultural greenhouse environmental monitoring is a typical representative. To ensure a reasonable lighting system for agricultural greenhouses, it is necessary to accurately monitor the light intensity inside the greenhouses. A smart light intensity adjustment system based on STm32 technology is proposed to address the current shortcomings of unadjustable lighting intensity, complex wiring, and high cost in the greenhouse.

        Our proposed intelligent lighting control system can determine whether greenhouse lighting is needed based on the current lighting threshold set for the greenhouse, and can change the lighting intensity in real time according to the current lighting. It can also observe the natural lighting intensity and lighting intensity of the current greenhouse in real time on the client.If the threshold setting is not reasonable, the buzzer will also provide an alarm reminder.

Keywords : Intelligent lighting, STM32, SpringBoot, Agricultural greenhouse.

1. Introduction

1.1 Background of topic selection

        Traditional agricultural production is not only limited by the influence of seasons, but also severely affected by weather changes. Especially in spring and winter, when there is a lot of rain and snow, most of the crops in the northern region are restricted. At present, some environmental factors in most agricultural greenhouses are controlled through manual intervention, and the current agricultural greenhouses cannot meet people's pursuit of high-quality requirements.

        Light is one of the important factors for plant growth. Low temperature and insufficient light in winter and early spring will have adverse effects on plant growth and development. Therefore, by adjusting the setting and use of greenhouse lighting facilities, the problem of insufficient light can be alleviated.

        The traditional way of artificially controlling light intensity and lighting time has certain disadvantages, such as wasting energy, uneven lighting, etc., and lacks real-time response to plant growth needs. In order to solve these problems, it is of great practical significance to develop an intelligent lighting control system.

        In view of the above problems, this topic aims to design an intelligent lighting adjustment system for agricultural greenhouses to realize real-time control of light intensity, so as to achieve the goals of energy saving, high efficiency, intelligence and automation. At the same time, factors such as system adaptability, stability, economy, and scalability need to be considered to meet the lighting requirements of different plant growth needs and climate conditions in different regions.

1.2 Research status at home and abroad

        Research status in foreign countries: Intelligent supplementary light technology for agricultural greenhouses originated in the Netherlands, the United States, Japan and other countries. As early as the 1990s, the Netherlands began to study plant growth lights, and in subsequent studies found that LED lights have a good effect of supplementing light for plants. The United States has also explored intelligent supplementary light in agricultural greenhouses. Researchers use computers to control LED plant growth lights to meet the light needs of plant growth. In Japan, research institutions use LED lamps and fluorescent lamps as light sources for plant growth, and have achieved certain research results.

        Domestic research status: There are relatively few researches on intelligent supplementary light in agricultural greenhouses in my country, and it has not been gradually paid attention to until recent years. Researchers are mainly concentrated in universities and scientific research institutions. The main research directions include the design and control strategy of plant growth lamps, the optimization and improvement of light source equipment, etc. At present, there are still many challenges in my country's intelligent supplementary light for agricultural greenhouses, such as energy efficiency of light source equipment, stability and diversity of light environment, and other issues.

        In general, intelligent light supplement technology for agricultural greenhouses has received extensive attention from scholars at home and abroad, but there are relatively few domestic studies. In future research, practical application and system optimization need to be further strengthened to improve the effect and benefit of intelligent light supplement technology for agricultural greenhouses.

1.3  Design and Research Direction

        Based on the above analysis, this topic is conceived based on the photodiodes and LED lights that come with the STM32F429IG development board, and automatically adjusts the brightness of the LED lights by setting the PWM duty cycle and pulse width ratio. By modifying the routine of the breathing light, write a breathing light in the form of an arithmetic sequence based on the proportion of the pulse width. At this time, we only need to adjust the brightness of the LED light without modifying the pulse width. The front-end is based on Vue+Echarts+Element-Plus for page rendering, and the back-end is based on SpringBoot to obtain the front-end response data in real time and send corresponding prompt information to the serial port, and at the same time collect the light intensity in real time and return it to the front-end. The real-time dynamic response of the terminal.

2. General scheme design

        The hardware is mainly divided into three areas, one is the photosensitive diode detection area, which collects the current light intensity in real time; the second is the LED light supplement area; the third is the buzzer reminder area, when the threshold setting is unreasonable (less than 10 is greater than 90), the buzzer will give an alarm.

        In terms of software, back-end design: Java’s RXTX.jar package can be used for serial communication, and then the back-end is built based on the SpringBoot framework. The main function should be to obtain the voltage value of the photodiode sent by the serial port in real time, and then customize Convert the light intensity according to the rules; send the current light intensity to the front end; receive the threshold set by the front end and the status of other LED lights, and then send the corresponding information to the serial port to control the LED lights. Front-end design: first initialize the real-time changing line chart, then obtain data from the backend, load the data into the line chart, and then return the data to the backend.

        The main control module chooses to use the STM32F429IGT6 chip for programming, control and measurement transmission data functions. The system architecture is as shown in Figure 1:

Figure 1 System architecture diagram

3. Principle design

3.1 Hardware Design

3.1.1 ADC Introduction

        STM32F429IGT6 has 3 ADCs, each ADC has 12-bit, 10-bit, 8-bit and 6-bit options, and each ADC has 16 external channels. In addition, two internal ADC sources and VBAT channels are hung on ADC1. ADC has independent mode, dual mode and triple mode, and almost all suitable modes are optional for different AD conversion requirements.

        Figure 2 below is the functional block diagram of the ADC:

Figure 2 ADC functional block diagram

3.1.2 Introduction of photosensitive sensor

        The GECSTM32F4 development board is equipped with a photodiode (photoresistor) as a light sensor, which is very sensitive to changes in light. Photosensitive diodes are also called photodiodes. Photosensitive diodes are similar in structure to semiconductor diodes, and their die is a PN junction with photosensitive characteristics, which has unidirectional conductivity, so a reverse voltage needs to be applied when working.

        When there is no light, there is a small saturated reverse leakage current, that is, dark current, and the photodiode is cut off at this time. When illuminated, the saturated reverse leakage current increases greatly, forming photocurrent, which changes with the intensity of incident light. When light irradiates the PN junction, electron-hole pairs can be generated in the PN junction, increasing the density of minority carriers. These carriers drift under the reverse voltage, increasing the reverse current. Therefore, the intensity of light can be used to change the current in the circuit.

        Using this current change, we can convert it into a voltage change by connecting a resistor in series, so as to read the voltage value through the ADC to judge the intensity of the external light.

        Figure 3 below is the schematic diagram of the photosensitive sensor:

Figure 3 Photosensitive sensor connection diagram

        In the figure, CS1 is a photosensitive diode, and R76 provides it with a reverse voltage. When the ambient light changes, the voltage at both ends of CS1 will also change accordingly, so that the ambient light can be obtained by reading the voltage on the photoresistor through the ADC1_IN5 channel. strength. The brighter the light, the lower the voltage, and the darker the light, the higher the voltage.

3.1.3 Buzzer Introduction

        The buzzer is an electronic sounder with an integrated structure. It is powered by DC voltage and is widely used as a sounding device in electronic products such as computers, printers, copiers, alarms, electronic toys, automotive electronic equipment, telephones, and timers. . Buzzers are mainly divided into two types: piezoelectric buzzers and electromagnetic buzzers.

        The buzzer on the GECSTM32F4 development board is an electromagnetic active buzzer, as shown in Figure 4 below, and Figure 5 is the schematic diagram of the buzzer.

Figure 4 active buzzer

Figure 5 Schematic diagram of the buzzer

3.1.4 Introduction of GPIOLED

        The following figure is the LED principle connection diagram of STM32F429IGT6:

Figure 6 LED principle connection diagram

        This experiment board is connected with 3 LED lights. The cathodes of these LED lights are all connected to the GPIO pins of STM32. As long as we control the level output state of the GPIO pins, we can control the LED lights to turn on and off.

3.2 Software Design

3.2.1 SpringBoot back-end engineering program design

        First, the program should obtain the voltage sent by the serial port, and then convert this into the light intensity of the custom rule ((300-voltage value*100)/300*100)-10). Why should the rule be set as above, because through practice, the voltage value is the closest to 3.0V in the darkest case, and then the voltage value is inversely proportional to the light intensity, and our assumed light intensity range is: 0-100, so There will be (300-voltage value*100)/300*100. As for the subsequent reduction of 10, it is practical, because according to the above formula, even in the darkest situation, there is still a light intensity of more than 10, so I Subtract 10 here.

        Then send the data to the front-end, after the front-end responds, send the data to the back-end, and the back-end receives the data and then redirects to the serial port, repeating this process, the program flow chart is as shown in Figure 7:

Figure 7 Back-end program flow chart 

3.2.2 Vue front-end engineering program design

        The front-end receives the data and refreshes the real-time line graph (here, in order to avoid the line graph being too confusing, the line graph is set to only display 20 points), and then returns to the front-end to return the threshold set at this time and the status of the rest of the LED lights to the back-end, the program flow The figure is shown in Figure 8 below:

Figure 8 Front-end program flow chart

4. Experiment and debugging

4.1 Experimental environment

        Dell Insprion 5509 Laptop, Keil5, IntelliJ IDEA 2021.1, Visual Studio Code, Google Chrome, STM32F429IGT6 Development Board

4.2 Experimental method

  1. Combining all the header files in the routine, write the Stm32 multitasking microsystem,
  2. Write relevant test code and burn it into the development test.
  3. Combining with the case of multi-task microsystem breathing light, write intelligent supplementary light code
  4. Burn and test the smart supplementary light
  5. Write the back-end code to obtain the data sent by the serial port in real time
  6. According to the back-end interface, write the front-end code
  7. Burn into the development board, run the front and rear ends, and integrate the test

4.3 Experimental results

        Run all the programs and visit localhost:5173 , you will see the effect shown in Figure 13 below: the client response is similar to the following, and the dynamic effect is saved in my resources:

Figure 9 running effect

        At present, we see that the development board needs to fill in the lights, and observe the status of the development board, as shown in Figure 10 below:

Figure 10 Development board status

Other test results:

Table 1 Test results

Test content

result

Click LED0 to turn on (off) the light whether LED0 is to turn on (off) the light

yes

Click LED0 to turn on (off) the light whether LED0 is to turn on (off) the light

yes

Adjust whether the threshold line graph changes accordingly

yes

Whether the status of the LED light on the development board corresponds to the line chart

yes

Test whether the brightness of the LED light is adjusted in real time when supplementing the light

yes

Whether the buzzer will alarm when the threshold is greater than 90 or less than 10

yes

4.4 Analysis of experimental results

        Through testing and analysis, our system can automatically fill in the light according to the threshold set by the client. If the threshold is unreasonable, it can also give an alarm reminder, and can also control the opening and closing of other LED lights. And has a very good dynamic effect.

Guess you like

Origin blog.csdn.net/qq_53317005/article/details/132066103