ARM-based intelligent low-power-consumption piezoelectric rainfall sensor and measurement method thereof
By using an ARM-based intelligent low-power piezoelectric rain sensor, which utilizes rain film detection and raindrop impact signal switching modes, combined with signal processing and microcontroller circuitry, the problems of high power consumption and insufficient accuracy of piezoelectric rain sensors in field monitoring are solved, achieving high-precision and low-power rain monitoring.
Patent Information
- Application Number
- CN202511568573.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-30
- Publication Date
- 2026-02-17
AI Technical Summary
Existing piezoelectric rain gauges consume a lot of power and have insufficient accuracy in long-term field monitoring, failing to meet the requirements for high accuracy and low power consumption.
Design an ARM-based intelligent low-power piezoelectric rain sensor. The rain film detection unit enters a low-power mode when there is no rain and enters a working mode when raindrops hit. It combines signal processing circuits and microcontroller circuits for real-time calculation and data transmission. A rain reading algorithm is adopted to improve accuracy, and it interacts with the host via RS485 Modbus RTU protocol.
It achieves a significant reduction in system power consumption while ensuring high-sensitivity rainfall detection, and improves the accuracy and stability of rainfall monitoring, making it suitable for long-term field monitoring.
Smart Images

Figure CN121541302A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of measurement and testing technology, specifically to an ARM-based intelligent low-power piezoelectric rain gauge and its measurement method. Background Technology
[0002] Rainfall monitoring is a fundamental data source for hydrological early warning, urban drainage, agricultural irrigation, and environmental monitoring. Currently, tipping bucket rain gauges are commonly used. While simple in structure, they lack the ability to measure the microscopic characteristics of precipitation and suffer from mechanical hysteresis, missed readings under heavy rainfall conditions, and clogging maintenance issues.
[0003] Piezoelectric rain sensors typically have a piezoelectric thin film attached to the sensing surface. They utilize the mechanical stress generated by raindrop impacts, converting it into a voltage signal via the piezoelectric effect. After voltage amplification, filtering, and analog-to-digital conversion, the raindrop event characteristics are extracted, and the rainfall value is obtained through pulse counting, energy integration, or model conversion. These sensors have no moving parts, fast response speed, and can cover a wide dynamic range from light rain to heavy rain, making them suitable for low-power remote deployment and multi-point networking.
[0004] However, for long-term field monitoring, the power consumption is high, and the measurement accuracy requirements are also high. Existing piezoelectric rain gauges cannot meet the requirements. Therefore, a rain gauge with high detection accuracy and low power consumption is needed. Summary of the Invention
[0005] This invention addresses the power consumption and accuracy issues of rain gauges by providing an ARM-based intelligent low-power piezoelectric rain gauge and its measurement method. The sensor includes a rain-sensing surface, a piezoelectric element, a housing, a signal processing circuit, and a microcontroller circuit. When there is no rain, the system operates in low-power mode. Upon detecting a rain film signal, it immediately exits low-power mode and enters working mode, calculating rainfall in real time for minutes, hours, 24 hours, and cumulative rainfall, and responding to host queries via the RS485 Modbus RTU protocol. The built-in rain reading algorithm significantly improves rainfall accuracy and reduces variance. Furthermore, the host can query real-time raindrop spectra, sensor internal temperature and humidity data, and newly set thresholds, among other rainfall-related parameters. Once the rain film disappears, the system automatically stops high-power peripherals and returns to low-power mode. This invention ensures highly sensitive capture and accurate accumulation of piezoelectric pulse events while greatly reducing system power consumption, guaranteeing long-term monitoring in the field.
[0006] This invention provides an ARM-based intelligent low-power piezoelectric rain sensor, including a rain-sensing surface connected to the upper part of the housing, a piezoelectric sensitive element connected to the bottom center of the rain-sensing surface, a rain film detection unit connected to the housing at one end and the rain-sensing surface at the other end, a signal processing circuit connected to the piezoelectric sensitive element, and a microcontroller circuit connected to both the rain film detection unit and the signal processing circuit. The microcontroller circuit performs AD acquisition, data processing, and communication transmission. The outer shell is a sealed structure, and the rain-sensing surface is an arc-shaped mirror structure with a length or diameter smaller than that of the outer shell and is sealed to the outer shell. The circuits of the rain film detection unit, the signal processing circuit, and the microcontroller circuit are all connected inside the outer shell. In rainy conditions, a rain film forms between the outer shell and the rain-sensing surface. The rain film causes a change in the resistance between the outer shell and the rain-sensing surface. The rain film detection unit determines whether a rain film has formed by detecting the resistance between the rain-sensing surface and the outer shell and outputs the judgment result to the microcontroller circuit. When the microcontroller circuit receives the rain film formation detection result, the piezoelectric rain sensor exits the low-power mode and enters the working mode to start rain monitoring. In working mode, after raindrops hit the rain-sensing surface, the rain-sensing surface transmits the vibration signal to the piezoelectric sensitive element. The piezoelectric sensitive element converts the vibration signal into a voltage signal and outputs it to the signal processing circuit. The signal processing circuit amplifies and filters the voltage signal and then outputs it to the microcontroller circuit for calculation. The microcontroller circuit transmits the calculated rainfall information to the host computer. After the rain film disappears, the microcontroller circuit can no longer receive the rain film formation detection results, and the piezoelectric rain sensor stops high-power peripherals and returns to low-power mode.
[0007] The present invention discloses an ARM-based intelligent low-power piezoelectric rain sensor. In a preferred embodiment, the microcontroller circuit is equipped with a rain reading algorithm. The rain reading algorithm does not accumulate all voltage values above a voltage threshold, but only accumulates the maximum voltage value of all pulses above the voltage threshold. At the same time, a specified time interval judgment is added. When the specified time interval judgment detects the first sample exceeding the threshold, the signal processing circuit is notified to enter the drip state. If a gap with a specified time interval below the threshold occurs, the drip is considered to have ended. High-power peripherals are ARM chips in microcontroller circuits; In low-power mode, the ARM chip of the piezoelectric rain sensor is in a stopped mode; the rain film formation detection result is a high level output to the ARM chip pin, and the ARM chip is activated after receiving the high level. Rainfall information includes cumulative rainfall and real-time raindrop spectra.
[0008] The present invention discloses an ARM-based intelligent low-power piezoelectric rain sensor, in which the outer shell is preferably made of metal. The sensing unit of a piezoelectric rain sensor consists of a rain-sensing surface and a piezoelectric sensitive element. The rain-sensing surface is made of stainless steel and is sealed and bonded to the upper surface of the outer shell, with the outer edges of the rain-sensing surface all located on the upper surface of the outer shell. The rain-sensing surface is connected to the rain film detection unit via wires; The piezoelectric sensing element is a piezoelectric ceramic sheet. The piezoelectric sensing element is attached to the center below the rain-sensing surface with adhesive. The piezoelectric sensing element is connected to the signal processing circuit through wires. The signal processing circuit includes a bias circuit, an amplifier circuit, and a filter circuit, and provides rain and rain film signals to the microcontroller circuit. The microcontroller circuit provides power to the signal processing circuit and contains an ARM chip.
[0009] The present invention discloses an ARM-based intelligent low-power piezoelectric rain sensor. In a preferred embodiment, the rain film detection unit includes an operational amplifier U3A electrically connected to the rain-sensing surface, an operational amplifier U3B electrically connected to the housing, an operational amplifier U3C whose positive input terminal is connected to the output terminal of operational amplifier U3A and whose negative input terminal is connected to the output terminal of operational amplifier U3B, a comparator chip U4 whose negative input terminal is connected to the output terminal of operational amplifier U3C, and resistors R27, R28, and R29 connected in parallel with the positive input terminal of comparator chip U4. The output terminal of comparator chip U4 is connected to the ARM chip. One end of resistor R27 is connected in parallel with resistors R28 and R29, and the other end is connected to the output of comparator chip U4. Resistor R28 is connected to 3.3V voltage, and resistor R29 is grounded. Op-amps U3A and U3B are both buffer comparators with raised input impedance. Op-amp U3C is a differential subtractor that converts the potential difference into a single-ended quantity. Op-amp U3C outputs voltage Vdiff, and comparator chip U4 inputs voltage Vth at its positive input terminal. Resistors R27, R28, and R29 set the low and high voltage thresholds for voltage Vth. When Vdiff < the low voltage threshold, comparator chip U4 outputs a high level; when the low voltage threshold ≤ Vdiff ≤ the high voltage threshold, comparator chip U4 maintains its previous state; when Vdiff > the high voltage threshold, comparator chip U4 outputs a low level. When there is no rain, the outer casing and the rain-sensing surface are in an open circuit state, the rain film resistance Rwater between the outer casing and the rain-sensing surface is greater than 7.5MΩ, Vdiff is greater than the high voltage threshold, and the comparator chip U4 outputs a low level. When there is a rain film, the outer shell and the rain-sensing surface are connected, Rwater < 4.535MΩ, Vdiff < low voltage threshold, and the comparator chip U4 outputs a high level; if the low voltage threshold ≤ Vdiff ≤ high voltage threshold, the output of the comparator chip U4 remains in the previous state.
[0010] The present invention discloses an ARM-based intelligent low-power piezoelectric rain sensor. In a preferred embodiment, the host sends instructions to the microcontroller circuit via the RS485 Modbus RTU protocol to observe the rainfall in minutes, hours, 24 hours and cumulative rainfall in real time, and can query the real-time raindrop pattern, sensor internal temperature and humidity data, set new thresholds, determine new gap lengths and zero the rainfall.
[0011] The ARM-based intelligent low-power piezoelectric rain sensor of the present invention, in a preferred embodiment, further includes a temperature and humidity sensor connected in the housing, a pole adapter connected to the bottom of the housing, and a power supply structure disposed inside the housing and connected to the microcontroller circuit, wherein the power supply structure is a battery. At least two copper pillars are connected to the bottom of the housing. The microcontroller circuit is connected to the top of the copper pillars. The signal processing circuit is set above the microcontroller circuit through the copper pillars. The rain film detection unit is connected to the circuit board of the signal processing circuit. The housing is connected to the rain film detection unit through the copper pillars and solder. The temperature and humidity sensor is soldered and fixed onto the microcontroller circuit. The pole adapter is made of insulating material and has a flat upper surface. The pole adapter isolates the metal outer shell from the metal pole or any metal surface that may cause interference.
[0012] This invention provides a measurement method for an ARM-based intelligent low-power piezoelectric rain gauge, comprising the following steps: S1. The piezoelectric rain sensor is in low power mode by default. At this time, the ARM chip in the microcontroller circuit is in a stopped state and does not react to external vibration factors. In rainy conditions, when the rain film detection unit outputs a high level to the microcontroller circuit, the piezoelectric rain sensor exits the low-power mode and enters the working mode. The working mode includes rain mode and spectrum transfer mode. In rain mode, the process proceeds to step S2, and in spectrum transfer mode, the process proceeds to step S3. S2, Timer Interrupt: The microcontroller circuit's processor obtains the ADC output voltage value and assigns it to the `adc_val` variable. If `adc_val` is greater than the ADC variable threshold, it continues to check the `in_pulse` value. If `in_pulse` is 0, it means it's not currently in a raindrop, so `in_pulse=1` is set to enter a raindrop, and the `adc_val` value is assigned to the maximum value `current_pulse_max` within that raindrop. However, if `adc_val` > `current_pulse_max`, the new `adc_val` value is assigned to `current_pulse_max` to ensure that `current_pulse_max` is always updated to its maximum value, and then the gap count is reset. If adc_val is less than or equal to the ADC variable threshold and is inside a raindrop, the gap count is incremented by 1; when the gap count is greater than the set maximum gap, the drop ends, current_pulse_max is added to the original voltage accumulation value, in_pulse is reset to 0, and the gap count is reset to 0. The algorithm iterates N times to obtain the cumulative data of the maximum voltage value after processing N samples. The measurement continues according to the host requirements, and then the voltage value is converted into cumulative rainfall. When the N+1th sample is reached, it is determined whether the sample is within a raindrop. If it is, the current_pulse_max is added to the original voltage accumulation value, in_pulse is reset to 0, and the gap count is reset to 0. S3. Record each voltage value and assign it to an array variable to obtain the raindrop voltage spectrum.
[0013] The measurement method of the ARM-based intelligent low-power piezoelectric rain gauge described in this invention, as a preferred embodiment, in step S2, N is 2000, each interrupt is 0.5ms, and the period of 2000 samples is 1s; the rain pattern data and the data of the tipping bucket rain gauge are fitted by least squares method to convert the voltage value into the actual rainfall. The microcontroller circuit first calculates the rainfall value for the current second in mm using a sliding window update function, then updates the cumulative rainfall every second, the minute rainfall every second, the hourly rainfall every minute, and the 24-hour rainfall every hour; then it begins to recount the samples.
[0014] The measurement method of the ARM-based intelligent low-power piezoelectric rain gauge described in this invention, as a preferred embodiment, proceeds to step S4 when the microcontroller circuit receives the signal transmitted by the host through the UART interface; S4. The microcontroller circuit first determines whether the signal is received by the UART function module in the ARM chip. If so, it sets the flag to 0 and receives the host transmission signal. The host transmission signal includes the address code and function code. rxRemLen is set according to different function codes, and then the flag is set to 1. The remaining bytes are received according to the value of rxRemLen. After the reception is completed, the flag is set to 0, and CRC check is performed through frameLen. If the check fails, it returns and restarts signal reception. If the check succeeds, different functions are implemented according to different function codes. The functions implemented by the function codes include querying the slave address, updating the slave address, parsing the register address and value, judging whether the register address is valid, switching the data reading mode to spectrum mode, and the program entering the main loop.
[0015] The measurement method of the ARM-based intelligent low-power piezoelectric rain gauge described in this invention, as a preferred embodiment, has both the address code and the function code being 1 byte, with frameLen=2+rxRemLen; When it is necessary to implement the function of querying the slave address, construct a response frame and send it, and write the device address to the slave through the master; When it is necessary to implement the function of updating the slave address, construct a response frame and send it, and the slave responds to the master with the device address; When it is necessary to implement the function of parsing register address and value, the third and fourth bytes are parsed. Depending on the difference between the third and fourth bytes, it is decided to write a new threshold or rainfall accumulation value to the slave through the master, or clear the buffer, or write a new gap length. When it is necessary to implement the function of judging whether the register address is valid, if it is valid, the calculation mode is switched to the rainfall mode, and the slave responds to the master with the cumulative rainfall value. The cumulative rainfall value includes the cumulative rainfall in 1 minute, the cumulative rainfall in 1 hour, the cumulative rainfall in 24 hours, and the total cumulative rainfall. When it is necessary to switch the data reading mode to the spectrum transfer mode, copy the data to the large packet, and the slave device responds to the host with all ADC samples within a sample threshold period; When the program needs to enter the main loop, the flag is first set to 1, and then the program enters the main loop. In the main loop, the program interacts with the temperature and humidity sensor chip through the I2C peripheral to obtain real-time temperature and humidity data and send it to the host.
[0016] This invention proposes a piezoelectric rain sensor, which, compared with traditional rain sensors, features small size, low power consumption, accurate rainfall monitoring, and the ability to monitor raindrop pattern, internal temperature and humidity data, and rainfall-related parameters such as new threshold values. It is very suitable for rainfall monitoring and has great application prospects.
[0017] The present invention has the following advantages: This invention provides an ARM-based intelligent low-power piezoelectric rain sensor, comprising a rain-sensing surface, a piezoelectric element, a housing, a signal processing circuit, and a microcontroller circuit. When there is no rain, the system is in low-power mode. Once a rain film signal is detected, it immediately exits low-power mode and enters working mode, calculating rainfall in real time for minutes, hours, 24 hours, and cumulative rainfall, and responding to host queries via the RS485 Modbus RTU protocol. The built-in rain reading algorithm significantly improves rainfall accuracy and reduces variance. Furthermore, the host can query real-time raindrop spectra, sensor internal temperature and humidity data, and newly set thresholds and other rainfall-related parameters at any time. After the rain film disappears, the system automatically stops high-power peripherals and returns to low-power mode. This invention ensures highly sensitive capture and accurate accumulation of piezoelectric pulse events while greatly reducing system power consumption, guaranteeing long-term monitoring in the field. Attached Figure Description
[0018] Figure 1 This is a schematic diagram of an ARM-based intelligent low-power piezoelectric rain sensor. Figure 2 This is a flowchart illustrating the workflow of an ARM-based intelligent low-power piezoelectric rain gauge and its measurement method. Figure 3 This is a circuit diagram of a rain film detection unit for an ARM-based intelligent low-power piezoelectric rain sensor and its measurement method. Figure 4 This is a flowchart of a rainfall reading algorithm for an ARM-based intelligent low-power piezoelectric rain gauge and its measurement method. Figure 5 This is a schematic diagram of a rainfall reading algorithm for an ARM-based intelligent low-power piezoelectric rain gauge and its measurement method. Figure 6 This is a flowchart of the UART receive interrupt callback program for an ARM-based intelligent low-power piezoelectric rain gauge and its measurement method. Figure 7 A flowchart of UART function code distribution for an ARM-based intelligent low-power piezoelectric rain gauge and its measurement method; Figure 8 This image shows a smart, low-power piezoelectric rain gauge based on ARM and its measurement method. The piezoelectric rain gauge (black) and tipping bucket rain gauge (blue) are used to measure rainfall over 38 hours. Figure 9 This image shows an ARM-based intelligent low-power piezoelectric rain gauge and its measurement method. The piezoelectric rain gauge displays the number of raindrops per second (black) and the rainfall measured by a tipping bucket rain gauge (blue) over 38 hours. Figure 10 This paper presents a low-power piezoelectric rain gauge based on ARM and its measurement method. The plot shows a line graph of the least squares fitting between the rainfall value of the piezoelectric rain gauge (horizontal axis) and the rainfall value of the tipping bucket rain gauge (vertical axis). Figure 11 A single raindrop test image of a rainfall pattern for an ARM-based intelligent low-power piezoelectric rain sensor and its measurement method. Figure 12 A dual-droplet test pattern of rainfall pattern for an ARM-based intelligent low-power piezoelectric rain sensor and its measurement method; Figure 13 This is a real-world rain test image showing a rainfall pattern of an ARM-based intelligent low-power piezoelectric rain sensor and its measurement method. Figure 14 A single raindrop test image of the transmission spectrum mode of an ARM-based intelligent low-power piezoelectric rain sensor and its measurement method; Figure 15 This is a magnified view of a single raindrop test in the transmission mode of an ARM-based intelligent low-power piezoelectric rain sensor and its measurement method. Figure 16 A dual-droplet test pattern of the transmission spectrum mode for an ARM-based intelligent low-power piezoelectric rain sensor and its measurement method; Figure 17 This is a real-world rain test image showing the transmission spectrum mode of an ARM-based intelligent low-power piezoelectric rain sensor and its measurement method.
[0019] Figure label: 1. Housing; 2. Rain-sensing surface; 3. Piezoelectric sensing element; 4. Rain film detection unit; 5. Signal processing circuit; 6. Microcontroller circuit; 7. Temperature and humidity sensor; 8. Pole adapter. Detailed Implementation
[0020] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Example 1
[0021] An ARM-based intelligent low-power piezoelectric rain gauge and its measurement method, such as Figure 1 As shown, the sensor consists of a housing 1, a rain-sensing surface 2, a piezoelectric sensitive element 3, a rain film detection unit 4, a signal processing circuit 5, a microcontroller circuit 6, a temperature and humidity sensor 7, and a pole adapter 8.
[0022] The piezoelectric sensing element 3 and the rain-sensing surface 2 constitute the sensing unit of the piezoelectric rain sensor. The piezoelectric sensing element 3 can be a piezoelectric ceramic sheet, and the rain-sensing surface 2 can be made of stainless steel. The rain-sensing surface 2 has a curved mirror structure, and the piezoelectric sensing element 3 is attached to the bottom of the rain-sensing surface 2 with adhesive.
[0023] The piezoelectric sensing element 3 is connected to the signal processing circuit 5 via a wire, and the rain-sensing surface 2 is directly connected to the signal processing circuit 5 via a wire to form a rain film detection unit 4.
[0024] The signal processing circuit 5 and the microcontroller circuit 6 are structurally fixedly connected by four copper pillars and functionally connected by multiple wires. The signal processing circuit 5 provides the microcontroller circuit 6 with rainfall and rain film signals, and the microcontroller circuit 6 provides power to the signal processing circuit 5.
[0025] The temperature and humidity sensor 7 is welded and fixed onto the microcontroller circuit 6.
[0026] The outer casing 1 is used to protect and secure the various components. The outer casing 1 is preferably made of a metal with a low coefficient of thermal expansion; in this embodiment, it is aluminum. The outer casing 1 secures the circuit board of the microcontroller circuit 6 to four hexagonal copper pillars.
[0027] The pole adapter 8 can be made of insulating materials such as plastic. The pole adapter 8 can isolate the metal outer shell 1 from the metal pole or other metal surfaces that may cause interference.
[0028] In this embodiment, the specific dimensions of the piezoelectric rain sensor are as follows: the outer shell 1 has a diameter of 70mm and a height of 30mm, and a hollow base with a diameter of 30mm and a height of 10mm is sealed at the bottom. The diameter of the bottom edge of the rain-sensing surface 2 is 69.8mm, and the local curvature of the top is R30mm. The pole adapter 8 includes a second cylindrical structure with a diameter of 40mm and a first cylindrical structure connected to the second cylindrical structure and extending into the hollow base.
[0029] In rainless environments, the sensor operates in low-power mode and is unresponsive to external vibrations. In rainy conditions, a rain film forms between the rain-sensing surface 2 and the outer casing 1. This rain film causes a change in resistance between the two surfaces. The rain film detection unit 4 transmits this information to the processor, and the sensor immediately exits low-power mode and enters operating mode to begin monitoring rainfall. After the rain film disappears, the sensor exits operating mode and returns to low-power mode.
[0030] like Figure 2 As shown, in the working mode, after a raindrop strikes the rain-sensing surface 2, the surface 2 transmits a vibration signal to the piezoelectric sensitive element 3. The piezoelectric sensitive element 3 receives the vibration signal, converts it into a voltage signal, and transmits it to the signal processing circuit 5. The signal processing circuit 5 amplifies and filters the voltage signal before transmitting the processed signal to the microcontroller circuit 6. The microcontroller circuit 6 calculates the processed voltage signal and transmits the rainfall information to the host computer. Because the pulse signal caused by raindrop impact is highly chaotic and greatly affected by external factors, the read voltage value varies significantly under the same rain conditions, making it difficult to accurately reflect the rainfall amount. Therefore, a rainfall reading algorithm is designed.
[0031] This rainfall reading algorithm does not accumulate all voltage values above the threshold; it only accumulates the maximum voltage value of all pulses above the threshold, while adding a specified time interval judgment. This judgment will detect the first sample exceeding the threshold, instructing the processor to enter the drip state. If a gap occurs with the specified time below the threshold, the drip is considered to have ended.
[0032] The rain film detection unit 4 is connected to the circuit board of the signal processing circuit 5. The rain-sensing surface 2 is connected to NodeA_PAD (a solder joint) of the rain film detection unit 4 through wires. The outer casing 1 is connected to NodeB_PAD (another solder joint) of the rain film detection unit 4 through hexagonal copper pillars and solder.
[0033] A threaded hole is provided inside the outer casing 1, and the threads of the hexagonal copper pillar are fixed in the hole for electrical connection. The top of the hexagonal copper pillar protrudes slightly from the circuit board of the signal processing circuit 5. The NodeB_PAD solder joint is very close to the top of the hexagonal copper pillar, and a piece of solder is used to connect the NodeB_PAD solder joint and the hexagonal copper pillar. Alternatively, a wire can be connected between the NodeB_PAD and the hexagonal copper pillar.
[0034] The entire connection logic is: outer shell - hexagonal copper pillar - solder - NodeB_PAD like Figure 3 The circuit diagram of the rain film detection unit 4 is shown. The MCP6074 is a quad op-amp chip, and three of them (U3A, U3B, U3C) are used here. U3A and U3B are used as buffers (to increase the input impedance), and U3C is used as a differential subtractor (to make the potential difference a single-ended quantity). The LMV331M5 is a comparator chip (to compare the input Vdiff with the threshold voltage Vth to output a high or low level). Here, R27, R28, and R29 are used to make Vth a low threshold of 0.61V and a high threshold of 0.90V. The effect is that when Vdiff < 0.61V, the comparator outputs a high level; when 0.61V ≤ Vdiff ≤ 0.90V, the comparator output remains in the previous state; when Vdiff > 0.90V, the comparator outputs a low level).
[0035] According to this example, when the rain-sensing surface and the metal casing are in an open-circuit state (i.e., no rain), Rwater (rain film resistance) > 7.5MΩ, Vdiff (comparator input) > 0.90V, and the comparator output is low. When the rain-sensing surface and the metal casing are in a connected state (i.e., with a rain film), when Rwater < 4.535MΩ, Vdiff < 0.61V, the comparator output is high. If 0.61V ≤ Vdiff ≤ 0.90V, the comparator output remains in the previous state.
[0036] The threshold can be modified based on the actual situation or the user's actual needs for the sensitivity of the rain film sensor.
[0037] Specifically: the rain sensor 2 outputs the RAIN_FILM_IN signal, the negative input terminal and output terminal of op-amp U3A are connected, the output terminal of op-amp U3A is connected to the positive input terminal of op-amp U3C, the negative input terminal and output terminal of op-amp U3B are connected, the output terminal of op-amp U3B is connected to the negative input terminal of op-amp U3C, the negative input terminal and output terminal of op-amp U3C are connected, and the output terminal of op-amp U3C is connected to the negative input terminal of comparator U4. The output signal of comparator U4 is RAIN_FILM_PROC, and RAIN_FILM_PROC is output to the external interrupt input pin of the ARM chip.
[0038] Diodes D3 and D4 are both ESD5Z3.3T1G, capacitors C14 and C15 are both 1nF, resistors R19 and R20 are both 20Ω, resistors R21 and R22 are both 10MΩ, resistors R23, R24, R25, and R26 are 100kΩ, operational amplifiers U3A, U3B, and U3C are MCP6074, resistor R27 is 470kΩ, resistor R28 is 220kΩ, resistor R29 is 56kΩ, resistor R30 is 47kΩ, capacitor C17 is 0.1μF, and comparator U4 is an LMV331M5.
[0039] like Figure 4 , 5 As shown, the host computer sends commands via the RS485 Modbus RTU protocol, enabling real-time monitoring of minute, hourly, 24-hour, and cumulative rainfall. Furthermore, the host computer can also use this protocol to query real-time raindrop patterns, sensor internal temperature and humidity data, and rainfall-related parameters such as new threshold settings, new gap determination lengths, and rainfall zeroing.
[0040] like Figure 6 , 7 As shown, the UART is set to serial port receive mode. UART is a general term for Universal Asynchronous Receiver / Transmitter, and UART2 is a specific UART function module instance in the chip. It serves as the channel for host-slave interaction.
[0041] By default, UART is set to be in serial port receive mode.
[0042] The UART is ready to receive two bytes of address code (1 byte) + one byte of function code. First, it needs to be confirmed that it is UART2 to avoid other modules. `rxStage` is a flag: when `rxStage == 0`, it indicates that the UART is about to receive two bytes from the host. After receiving these two bytes (address code + function code), `rxRemLen` will be set differently depending on the function code. For example, if the function code is 0x20, `rxRemLen` equals 2, meaning the UART needs to receive another two bytes. If the function code is 0x03, `rxRemLen` equals 6, meaning the UART needs to receive six bytes. If the function code is 0x99, it is outside the valid function code range, resulting in frame loss and a restart. When `rxStage == 1`, it tells the UART to start receiving the remaining bytes (`rxRemLen` bytes).
[0043] Then, rxStage is reset to 0, and the UART is also reset to receive 2 bytes at any time. frameLen is the number of complete bytes, which is 2 + rxRemLen, that is, the 2 bytes of the function code plus rxRemLen remaining bytes. This is used when calculating the CRC code.
[0044] Then, the CRC check is performed. If the check fails, the process returns; if the check succeeds, the process continues, implementing different functions based on different function codes.
[0045] After the UART receives different function codes After the UART receives different function codes, the ARM chip will reflect the different functions accordingly.
[0046] If the function code is 0x20, it means that the host writes the device address to the slave.
[0047] If the function code is 0x30, it means that the slave device is responding to the master device with the device address.
[0048] If the function code is 0x03, the calculation mode is switched to rainfall mode. The slave device responds to the master device with the accumulated rainfall value, which includes the rainfall in 1 minute, the rainfall in 1 hour, the rainfall in 24 hours, and the total accumulated rainfall.
[0049] If the function code is 0x41, the calculation mode switches to spectrum transfer mode. The slave device responds to the master device with a total ADC sample containing 2000 samples. If the function code is 0x42, the program enters the main loop. Within the main loop, it interacts with the AHT20 chip via an I2C peripheral to obtain real-time temperature and humidity data.
[0050] If the function code is 0x06, then continue parsing the third and fourth bytes. Depending on the difference between the third and fourth bytes, it is determined whether to write a new threshold or rainfall accumulation value to the slave device, clear the cache, or write a new gap length.
[0051] TIM2 is a timer TIM2 is a timer, set to trigger every 0.5ms.
[0052] If the mode is rainfall mode, the ADC value is assigned to the `adc_val` variable via the `HAL_ADC_GetValue` function. If `adc_val` is greater than the threshold, the `in_pulse` value is checked. If `in_pulse` is 0 (meaning it's not currently in a raindrop), `in_pulse` is set to 1 (meaning it's already in a raindrop), and the `adc_val` value is assigned to `current_pulse_max` (the maximum value in a raindrop). However, if `adc_val` > `current_pulse_max`, the new `adc_val` value is assigned to `current_pulse_max` to ensure that `current_pulse_max` is always updated to its maximum value. Then, `gap_count` is set to 0 to reset the gap count.
[0053] If the sample being read is below the threshold and is inside a raindrop, then gap_count is incremented (gap count + 1). Once gap_count exceeds the set maximum gap (e.g., 5 samples, i.e., 2.5ms), current_pulse_max is added to the original voltage accumulation value, in_pulse is reset to 0, and gap_count is reset to 0.
[0054] The above process loops 2000 times, with 1 sample per loop, and each loop takes 0.5ms, resulting in 2000 samples and a total of 1 second.
[0055] Once the 2001st sample is reached, it is determined whether the sample is within a raindrop. If so, `current_pulse_max` is added to the original accumulated voltage value, `in_pulse` is reset to 0, and `gap_count` is also reset to 0. Then, the accumulated voltage value is converted to mm. A sliding window update function is designed here: first, the rainfall value (mm) for the current second is calculated; then, the accumulated rainfall is updated in real time every second, the minute rainfall every second, the hourly rainfall every minute, and the 24-hour rainfall every hour. Then, the sample count is restarted, counting another 2000 samples.
[0056] If the mode is spectral transmission mode, then you can directly assign the 2000 sample values to an array variable.
[0057] It rained in Beijing from June 13 to 15, 2025. A comparative test was conducted on the calibration of the piezoelectric rain gauge and the tipping bucket rain gauge of this embodiment. Figure 8 The data represents rainfall data for 38 hours, from 19:00 on June 13th to 9:00 on June 15th. The black curve represents the rainfall measured by the piezoelectric rain gauge in this embodiment, with units of voltage; the blue curve represents the rainfall measured by the tipping bucket rain gauge, with units of mm. As can be seen from the figure, the two curves are basically consistent over the 38-hour rainfall period, proving the reliability of the rainfall data measured by the piezoelectric rain gauge.
[0058] Furthermore, the piezoelectric rain sensor of this invention can record the number of raindrops per second. By comparing the number of raindrops per second recorded by the piezoelectric rain sensor with the rainfall curve measured by a tipping bucket rain gauge, we found that in the significantly elevated portions of the tipping bucket rain gauge curve (around 8:00 AM, 12:00 PM, and 9:00 PM on the 14th), the raindrop count was significantly denser. The measured raindrop density was positively correlated with the steepness of the rainfall curve measured by the tipping bucket rain gauge. Figure 9 As shown. During the periods when the blue curve was stable (19:00 on the 13th to 7:00 on the 14th, 14:00 to 19:00 on the 14th, and 22:00 on the 14th to 7:00 on the 15th), the number of raindrops per second was also very sparse.
[0059] like Figure 10 As shown, the data measured by the piezoelectric rain gauge every second is mapped one-to-one with the data measured by the tipping bucket rain gauge, with the former as the horizontal axis and the latter as the vertical axis. Least squares fitting is used to calculate the relationship between the two, thus converting the voltage value (V) of the former into the actual rainfall (mm). The formula for calculating the relationship between the two is: y=0.00023305 x +0.04508386; x y is the voltage value (V) of the piezoelectric rain gauge, y is the rainfall value (mm) of the tipping bucket rain gauge, and R is the rainfall value (mm) of the tipping bucket rain gauge. 2 ≈0.97.
[0060] Figures 11-13 This is a rainfall pattern image, and the output is the cumulative rainfall value. The vertical axis is the cumulative rainfall (unit V), and the horizontal axis is time (unit s). This graph shows the process of rainfall continuously accumulating and increasing as the duration of rainfall changes.
[0061] Figures 14-17 For spectral mode images, Figure 15 for Figure 14 The enlarged view within the red box Figures 14-17 All outputs real-time raindrop spectrum, with the vertical axis representing the real-time voltage of the processed raindrops received by the ARM chip (in V) and the horizontal axis representing time (in 0.5 ms).
[0062] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.
Claims
1. An ARM-based intelligent low-power piezoelectric rain sensor, characterized in that: The rain-sensitive surface (2) is connected to the upper part of the shell (1), the piezoelectric sensitive element (3) is connected to the bottom center of the rain-sensitive surface (2), the rain film detection unit (4) is connected to one end of the shell (1) and the other end of the rain-sensitive surface (2), the signal processing circuit (5) is connected to the piezoelectric sensitive element (3), and the microcontroller circuit (6) is connected to the rain film detection unit (4) and the signal processing circuit (5); the microcontroller circuit (6) performs AD acquisition, data processing and communication transmission; The shell (1) is a sealed structure, the rain-sensitive surface (2) is an arc mirror surface structure with a length or diameter smaller than that of the shell (1) and is sealingly connected to the shell (1), and the circuits of the rain film detection unit (4), the signal processing circuit (5) and the microcontroller circuit (6) are all connected inside the shell (1); In a rainy environment, a rain film is formed between the shell (1) and the rain-sensitive surface (2), the rain film causes the resistance between the shell (1) and the rain-sensitive surface (2) to change, the rain film detection unit (4) detects the resistance between the rain-sensitive surface (2) and the shell (1) to determine whether a rain film is formed and outputs the determination result to the microcontroller circuit (6), and when the microcontroller circuit (6) receives the rain film formation detection result, the piezoelectric rain sensor exits the low-power mode and enters the working mode to start rain listening; In the working mode, after raindrops hit the rain-sensitive surface (2), the rain-sensitive surface (2) transmits the vibration signal to the piezoelectric sensitive element (3), the piezoelectric sensitive element (3) converts the vibration signal into a voltage signal and outputs it to the signal processing circuit (5), the signal processing circuit (5) amplifies and filters the voltage signal and outputs it to the microcontroller circuit (6) for calculation, and the microcontroller circuit (6) transmits the calculated rain information to the host; After the rain film disappears, the microcontroller circuit (6) cannot receive the rain film formation detection result, the piezoelectric rain sensor stops the high-power peripheral device and returns to the low-power mode.
2. The ARM-based intelligent low-power piezoelectric rain sensor according to claim 1, characterized in that: The rain amount reading algorithm is set in the microcontroller circuit (6), the rain amount reading algorithm does not accumulate all voltage values above the voltage threshold, but only accumulates the maximum voltage of all pulses above the voltage threshold, and a specified time gap is added; when the specified time gap detection detects the first threshold value sample, the signal processing circuit (5) is notified to enter the drop state, and if a specified time gap below the threshold value appears, it is considered that the drop is over; The high-power peripheral device is an ARM chip in the microcontroller circuit (6); In the low-power mode, the ARM chip is in the stop mode; the rain film formation detection result is a high level output to the pin of the ARM chip, and the ARM chip is activated after receiving the high level; The rain information includes the cumulative rainfall and the real-time spectrum of raindrops. 3.The ARM-based intelligent low-power piezoelectric rain sensor according to claim 1, characterized in that: The shell (1) is made of metal; The rain-sensitive surface (2) and the piezoelectric sensitive element (3) form a sensing unit of the piezoelectric rain sensor. The material of the rain sensing surface (2) is stainless steel, the rain sensing surface (2) is sealed and bonded on the upper surface of the shell (1), and the outer edges of the rain sensing surface (2) are located on the upper surface of the shell (1); The rain sensing surface (2) is connected with the rain film detection unit (4) through a wire; The piezoelectric sensitive element (3) is a piezoelectric ceramic sheet, the piezoelectric sensitive element (3) is pasted below the center of the rain sensing surface (2) by glue, and the piezoelectric sensitive element (3) is connected with the signal processing circuit (5) through a wire; The signal processing circuit (5) includes a bias circuit, an amplification circuit and a filter circuit and provides rain amount and rain film signals for the microcontroller circuit (6), the microcontroller circuit (6) provides power supply for the signal processing circuit (5), and an ARM chip is arranged in the microcontroller circuit (6).
4. The ARM-based intelligent low-power piezoelectric rain sensor according to claim 1, characterized in that: The rain film detection unit (4) includes an operational amplifier U3A electrically connected with the rain sensing surface (2), an operational amplifier U3B electrically connected with the shell (1), an operational amplifier U3C with a positive input end connected with the output end of the operational amplifier U3A and a negative input end connected with the output end of the operational amplifier U3B, a comparator chip U4 with a negative input end connected with the output end of the operational amplifier U3C, and resistors R27, R28 and R29 connected in parallel with the positive input end of the comparator chip U4, and the output end of the comparator chip U4 is connected with the ARM chip; One end of the resistor R27 is connected in parallel with the resistors R28 and R29, the other end is connected with the output end of the comparator chip U4, the resistor R28 is connected with a 3.3V voltage, and the resistor R29 is grounded; The operational amplifier U3A and the operational amplifier U3B are both buffer comparators with high input impedance, the operational amplifier U3C is a differential subtractor for converting a potential difference into a single-ended quantity, the output voltage of the operational amplifier U3C is Vdiff, the input voltage of the positive input end of the comparator chip U4 is Vth, the resistors R27, R28 and R29 convert the voltage Vth into a low voltage threshold and a high voltage threshold, when Vdiff is less than the low voltage threshold, the comparator chip U4 outputs a high level, when the low voltage threshold is less than or equal to Vdiff and Vdiff is less than or equal to the high voltage threshold, the comparator chip U4 outputs a previous state, and the state is unchanged, and when Vdiff is greater than the high voltage threshold, the comparator chip U4 outputs a low level; In the no-rain state, the shell (1) and the rain sensing surface (2) are in an open circuit state, the rain film resistance Rwater between the shell (1) and the rain sensing surface (2) is greater than 7.5MΩ, Vdiff is greater than the high voltage threshold, and the comparator chip U4 outputs a low level; In the rain film state, the shell (1) and the rain sensing surface (2) are in a connected state, Rwater is less than 4.535MΩ, Vdiff is less than the low voltage threshold, and the comparator chip U4 outputs a high level; if the low voltage threshold is less than or equal to Vdiff and Vdiff is less than or equal to the high voltage threshold, the output of the comparator chip U4 remains the previous state.
5. The ARM-based intelligent low-power piezoelectric rain sensor according to claim 1, characterized in that: The host sends instructions to the microcontroller circuit (6) through RS485 Modbus RTU protocol, observes the minutes, hours, 24 hours and cumulative rainfall in real time, inquires the real-time spectrum of raindrops, the internal temperature and humidity data of the sensor, binds new threshold values, performs new gap judgment length and rainfall zero clearing at any time.
6. The ARM-based intelligent low-power piezoelectric rain sensor according to claim 1, characterized in that: It also comprises a temperature and humidity sensor (7) connected in the shell (1), a vertical rod adapter (8) connected to the bottom of the shell (1) and a power supply structure provided inside the shell (1) and connected with the microcontroller circuit (6), wherein the power supply structure is a battery; At least two copper columns are connected to the bottom of the shell (1), the microcontroller circuit (6) is connected to the top of the copper columns, the signal processing circuit (5) is provided on the upper part of the microcontroller circuit (6) through the copper columns, the rain film detection unit (4) is connected to the circuit board of the signal processing circuit (5), and the shell (1) is connected with the rain film detection unit (4) through the copper columns and soldering tin; The temperature and humidity sensor (7) is welded and fixed on the microcontroller circuit (6); The vertical rod adapter (8) is made of insulating material and has a flat upper surface, which isolates the shell (1) made of metal from metal vertical rods or metal surfaces that may cause interference.
7. The measuring method of the intelligent low-power piezoelectric rain sensor based on ARM according to any one of claims 1-6, characterized in that: The following steps are included: S1, the piezoelectric rain sensor is in a low-power consumption mode by default, at which time the ARM chip in the microcontroller circuit (6) is in a stopped state and does not react to external vibration factors; When the rain film detection unit (4) outputs a high level to the microcontroller circuit (6) in a rainy environment, the piezoelectric rain sensor exits the low-power consumption mode and enters a working mode, which includes a rainfall mode and a transmission spectrum mode, the rainfall mode enters step S2, and the transmission spectrum mode enters step S3; S2, the timer is interrupted, the processor of the microcontroller circuit (6) obtains the ADC output voltage value and gives it to the adc_val variable, if the adc_val is greater than the ADC variable threshold, the in_pulse value is continuously judged, if the in_pulse is 0, it is not currently in a raindrop, in_pulse=1 is set, a raindrop is entered, and the adc_val value is given to the maximum value current_pulse_max in the raindrop, but if the adc_val>current_pulse_max, the new adc_val value is assigned to current_pulse_max, to ensure that current_pulse_max is updated to the maximum value at all times, and then the gap count is reset; If the adc_val is less than or equal to the ADC variable threshold and is in a raindrop, the gap count is incremented by 1, when the gap count is greater than the set maximum gap, the drop is ended, the current_pulse_max is added to the original voltage cumulative value, the in_pulse is reset to 0, and the gap count is reset to 0. Circulating N times, get N samples of the algorithm processing after the maximum voltage value of the cumulative data, according to the host computer to continue to measure, then the voltage value is converted to cumulative rainfall; When N+1 samples, determine whether the sample is in a raindrop, if so, add current_pulse_max to the original voltage cumulative value, in_pulse is 0, the gap count is 0; S3, record each voltage value and assign to array variable to get raindrop voltage spectrum shape. 8.The measuring method of the ARM-based intelligent low-power piezoelectric rain sensor according to claim 7, characterized in that: In step S2, N is 2000, each interruption is 0.5ms, 2000 sample period is 1s; the rainfall mode data is fitted with the data of the tipping bucket rain gauge by least square method to convert the voltage value into real rainfall; The microcontroller circuit (6) calculates the rainfall value per second by the sliding window update function, unit: mm, then updates the cumulative rainfall every second, updates the minute rainfall every second, updates the hour rainfall every minute, and updates the 24-hour rainfall every hour; then start to re-count the samples. 9.The measuring method of the ARM-based intelligent low-power piezoelectric rain sensor according to claim 7, characterized in that: When the microcontroller circuit (6) receives the signal transmitted by the host through the UART interface, step S4 is entered; S4, the microcontroller circuit (6) first judges whether it is the UART function module in the ARM chip to receive the signal, if so, the flag bit is set to 0, the host transmission signal is received, the host transmission signal includes address code and function code, according to different function code setting rxRemLen, then the flag bit is set to 1, according to the size of rxRemLen value, the remaining bytes are received, after receiving, the flag bit is set to 0, CRC check is carried out through frameLen, if the check fails, return, restart signal receiving; if the check is successful, different functions are realized according to different function codes, the functions realized by the function codes include querying slave address, updating slave address, analyzing register address and value, judging whether the register address is legal, switching data reading mode to spectrum transmission mode and program entering main loop. 10.The measuring method of the ARM-based intelligent low-power piezoelectric rain sensor according to claim 9, characterized in that: The address code and the function code are both 1 byte, frameLen=2+rxRemLen; When the function of querying slave address needs to be realized, the response frame is constructed and sent, and the device address is written to the slave by the host; When the function of updating slave address needs to be realized, the response frame is constructed and sent, and the device address is responded by the slave to the host; When the function of analyzing register address and value needs to be realized, the third and fourth bytes are continued to be analyzed, according to the different third and fourth bytes, it is decided to write new threshold or rainfall cumulative value to the slave by the host, or to clear the buffer, or to write new gap length; When the function of judging whether the register address is legal needs to be realized, if it is legal, the mode is switched to rainfall mode, and the cumulative rainfall value is responded by the slave to the host, the cumulative rainfall value includes 1 minute cumulative rainfall, 1 hour cumulative rainfall, 24 hour cumulative rainfall and total cumulative rainfall; When the function of switching data reading mode to spectrum transmission mode needs to be realized, the data is copied to the large package, and all ADC samples in a sample threshold period are responded by the slave to the host. When the program needs to enter the main loop function, first set the flag position to 1, then the program enters the main loop, in the main loop, the real-time temperature and humidity data are obtained by interacting with the chip of the temperature and humidity sensor (7) through the I2C peripheral, and are sent to the host computer.