Electric parameter integrated teaching sensor based on ESP32
By using relay switching circuits in portable measurement sensors, the complex and easy-to-break sensor switching problems are solved, and a simple and safe sensor switching function is realized.
Patent Information
- Application Number
- CN202411759000.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-03
- Publication Date
- 2025-02-28
AI Technical Summary
Existing portable measurement sensors have complex processes and high risks in sensor switching, making it difficult for users to switch different sensors at will, which can easily lead to incorrect operation and damage to the ADC circuit.
A electrical parameter integrated teaching sensor based on ESP32 is designed, using a relay as a switch, and the relay switching circuit is controlled through the external input button of the motherboard to realize the switching of current or voltage measurement mode.
It enables switching of different electrical sensors without additional operations, improves user experience, prevents sensor damage caused by wrong operations, and enhances the safety and reliability of the sensor.
Smart Images

Figure CN119534983A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of sensors, in particular to an ESP32-based electrical parameter integrated teaching sensor. Background Art
[0002] Portable measurement sensors are devices used to collect and analyze data in various environments. They come in a variety of types depending on the measurement requirements, but they are essentially devices that use a central board that constantly replaces external receiving boards to collect data, manually convert the data into code, and then process the data on the main board. However, existing portable measurement sensors have the following shortcomings:
[0003] There are obvious defects in the sensor switching. Users cannot switch between different sensors at will. Each time the switching operation is performed, it is extremely inconvenient and often requires manual execution of a complex switching process, which seriously affects the user experience. In terms of measuring current and voltage, if the sensor needs to switch between current and voltage measurement modes, the existing technology either equips two independent sets of sensors, which undoubtedly increases product cost and resource usage, or requires the user to re-power on and burn in the program, which is too complicated. In addition, during the sensor switching operation, since the sensor needs to turn the dip switch 2 to the ON state, it is easy for users who are not familiar with the operation to make mistakes if they accidentally adjust the setting to the current sensor but forget to turn the dip switch, which will cause the sampling ADC circuit to burn out. As a key component, the ADC circuit will lose its basic function once it burns out, making the entire motherboard unable to work properly. This requires users to be proficient in the operating steps, otherwise the entire sensor will be scrapped if they are not careful, causing great inconvenience and economic losses to users, and greatly increasing the consumption of manpower and material resources. Especially in the teaching process, the above problems are more likely to occur due to students' lack of proficiency in operation. The root cause of these problems is that the switching solutions used by related products are too complicated. Summary of the Invention
[0004] To solve the above technical problems, the present invention provides an ESP32-based integrated electrical parameter teaching sensor. The sensor can be switched to current or voltage measurement mode by using a relay as a switch to prevent users from operating the sensor incorrectly or forgetting the steps, which may cause the sensor to be scrapped.
[0005] In order to achieve the above object, the technical solution adopted by the present invention is:
[0006] The present invention discloses an ESP32-based electrical parameter integrated teaching sensor, comprising a mainboard, an ADC analog-to-digital converter, a switching module, and a power module. The output end of the mainboard is connected to the input end of the switching module, the output end of the switching module is connected to the input end of the ADC analog-to-digital converter, the output end of the ADC analog-to-digital converter is connected to the input end of the mainboard, and the power module is respectively connected to the mainboard and the switching module, and the power module is used to provide operating power.
[0007] As a preferred embodiment of the present invention, the switching module includes a switching circuit, which includes a relay K1, a relay K2 and a relay K3; the pin 1 of the relay K1 is connected to the anode of the switching diode D3 and the positive electrode of the 3.3V power supply, the pin 4 of the relay K1 is respectively connected to the cathode of the switching diode D3 and the collector of the triode Q3, the base of the triode Q3 is respectively connected to one end of the resistor R8 and one end of the resistor R9, the other end of the resistor R8 is connected to the emitter of the triode Q3 and the negative electrode of the 3.3V power supply, the other end of the resistor R9 is connected to the IO port of the motherboard 2, and the relay K1 is connected to the 10 port of the motherboard 2. Pin 5 is connected to one end of the resistor R4 and one end of the resistor R5 respectively, the other end of the resistor R4 is connected to the positive electrode of the 3V power supply, the other end of the resistor R5 is used as the GND test terminal and connected to the negative electrode of the 3V power supply, the pin 3 of the relay K1 is normally closed, the pin 2 of the relay K1 is used as the A1 test terminal and is connected to the pin 5 of the relay K2 and the pin 5 of the relay K3 respectively; the pin 1 of the relay K2 is connected to the anode of the switching diode D1 and the positive electrode of the 3.3V power supply, the pin 4 of the relay K2 is connected to the cathode of the switching diode D1 and the collector of the triode Q1 respectively, and the base of the triode Q1 is connected to the cathode of the switching diode D1 and the collector of the triode Q1 respectively. One end of the resistor R2 is connected to one end of the resistor R1, the other end of the resistor R1 is connected to the IO port of the mainboard 2, the other end of the resistor R2 is connected to the emitter of the triode Q1 and the negative electrode of the 3.3V power supply, the pin 3 of the relay K2 is normally closed, and the pin 2 of the relay K2 is connected to one end of the current measuring resistor U2; the pin 1 of the relay K3 is connected to the anode of the switching diode D2 and the positive electrode of the 3.3V power supply, the pin 4 of the relay K3 is respectively connected to the cathode of the switching diode D2 and the collector of the triode Q2, the base of the triode Q2 is respectively connected to one end of the resistor R3 and one end of the resistor R7, the triode The other end of the resistor R3 is connected to the IO port of the mainboard 2, the other end of the resistor R7 is connected to the emitter of the transistor Q2 and the negative electrode of the 3.3V power supply, the pin 3 of the relay K3 is normally closed, and the pin 2 of the relay K3 is connected to one end of the resistor R6; the other end of the current measuring resistor U2 is connected to the other end of the resistor R6 and serves as the A0 test terminal; it also includes a bank group U6, the GND test terminal, the A0 test terminal and the A1 test terminal are respectively connected to pin 1, pin 2 and pin 3 of the bank group U6, the pin 4 of the bank group U6 is connected to the positive electrode of the 3V power supply, and the pin 1, pin 5 and pin 6 of the bank group U6 are all connected to the negative electrode of the 3V power supply.
[0008] As a preferred embodiment of the present invention, the switching circuit also includes a preset bank group, which includes bank group U1 and bank group U4. The other end of the resistor R9 is also connected to pin 2 of bank group U4 and connected to the IO port of the motherboard 2. Pin 3 of the bank group U4 is connected to the positive electrode of the 3.3V power supply, and pin 1, pin 5 and pin 6 of the bank group U4 are all connected to the negative electrode of the 3.3V power supply; the other end of the resistor R1 and the other end of the resistor R3 are also respectively connected to pin 2 and pin 3 of bank group U1 and connected to the IO port of the motherboard 2. Pin 4 of the bank group U1 is connected to the positive electrode of the 3.3V power supply, and pin 1, pin 5 and pin 6 of the bank group U1 are all connected to the negative electrode of the 3.3V power supply.
[0009] Due to the adoption of the above technical solution, the present invention has the following beneficial effects:
[0010] 1. The present invention adopts a relay as a switch switching circuit, and an external input button can be connected through the mainboard. When the input button is input, the mainboard will send a control signal to the relay to turn on the corresponding relay. Different conduction modes of the relay constitute different measurement modes, so that the switching circuit can measure the current or voltage of the external circuit, so as to achieve the purpose of switching different electrical sensors by long pressing the button, and realize the simultaneous switching of software and hardware without additional operation, which not only improves the user experience, but also prevents the sensor from being burned and scrapped due to incorrect operation or forgetting steps, thereby enhancing the safety and reliability of the sensor.
[0011] 2. The present invention adds a preset array group so that the switching circuit can be expanded to connect to other sensors to achieve the purpose of measuring other physical quantities. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] Figure 1 It is a functional flow chart of the present invention.
[0013] Figure 2 is a circuit diagram of a switching circuit of the present invention.
[0014] Figure 3 It is the internal diagram, schematic diagram and PCB diagram of the invented relay structure.
[0015] Figure 4 It is the circuit diagram of the invented ADC analog-to-digital converter. DETAILED DESCRIPTION
[0016] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making any creative efforts shall fall within the scope of protection of the present invention.
[0017] An ESP32-based integrated electrical parameter teaching sensor of this embodiment includes a mainboard 1, an ADC analog-to-digital converter 2, a switching module 3 and a power module 4. The output end of the mainboard 1 is connected to the input end of the switching module 3, the output end of the switching module 3 is connected to the input end of the ADC analog-to-digital converter 2, the output end of the ADC analog-to-digital converter 2 is connected to the input end of the mainboard 1, and the power module 4 is connected to the mainboard 1 and the switching module 3 respectively. The power module 4 is used to provide operating power. The power module 4 specifically outputs 3.3V control power and 3V startup power to the mainboard 2 and the switching module 4 respectively.
[0018] Switching module 4 includes a switching circuit, which includes relays K1, K2, K3, and bank U6. Specifically, relays K1, K2, and K3 all utilize 5-pin relays, a conventional technology. A brief description of 5-pin relays follows: The relay's starting voltage is 3V, relay pins 1 and 4 connect to the positive and negative control input voltages, relay pin 3 is normally closed, relay pin 2 is normally open, and relay pin 5 serves as a common terminal. When the voltage between relay pins 1 and 4 is 0V, relay pins 3 and 5 connect. When the control voltage is applied between relay pins 1 and 4, relay pins 2 and 5 connect.
[0019] Pin 1 of relay K1 is connected to the anode of switching diode D3 and the positive electrode of 3.3V power supply. Pin 4 of relay K1 is connected to the cathode of switching diode D3 and the collector of transistor Q3 respectively. The base of transistor Q3 is connected to one end of resistor R8 and one end of resistor R9 respectively. The other end of resistor R8 is connected to the emitter of transistor Q3 and the negative electrode of 3.3V power supply. The other end of resistor R9 is connected to the IO port of motherboard 2. Pin 5 of relay K1 is connected to one end of resistor R4 and one end of resistor R5 respectively. One end is connected to the positive electrode of the 3V power supply, and the other end of the resistor R5 is connected to pin 1 of the bank U6 as the GND test terminal. Pin 3 of the relay K1 is normally closed. Pin 2 of the relay K1 is used as the A1 test terminal and is connected to pin 5 of the relay K2 and pin 5 of the relay K3 respectively, and is also connected to pin 3 of the bank U6; Pin 1 of the relay K2 is connected to the anode of the switching diode D1 and the positive electrode of the 3.3V power supply, and Pin 4 of the relay K2 is connected to the cathode of the switching diode D1 and the collector of the transistor Q1 respectively. The base of the transistor Q1 is connected to the positive electrode of the 3.3V power supply. The relay K2 is connected to one end of the resistor R2 and one end of the resistor R1 respectively. The other end of the resistor R1 is connected to the IO port of the mainboard 2. The other end of the resistor R2 is connected to the emitter of the transistor Q1 and the negative electrode of the 3.3V power supply. The pin 3 of the relay K2 is normally closed. The pin 2 of the relay K2 is connected to one end of the current measuring resistor U2. The pin 1 of the relay K3 is connected to the anode of the switching diode D2 and the positive electrode of the 3.3V power supply. The pin 4 of the relay K3 is connected to the cathode of the switching diode D2 and the collector of the transistor Q2 respectively. The base of the transistor Q2 is connected to One end of resistor R3 is connected to one end of resistor R7, the other end of resistor R3 is connected to the IO port of mainboard 2, the other end of resistor R7 is connected to the emitter of transistor Q2 and connected to the negative pole of 3.3V power supply, pin 3 of relay K3 is normally closed, and pin 2 of relay K3 is connected to one end of resistor R6; the other end of current measuring resistor U2 is connected to the other end of resistor R6 and connected to pin 2 of bank group U6 as A0 test end; pin 4 of bank group U6 is connected to the positive pole of 3V power supply, and pin 1, pin 5 and pin 6 of bank group U6 are all connected to the negative pole of 3V power supply. The switching circuit described above connects the base of the transistor to the IO port of the motherboard 2, and can control the conduction and cutoff of the transistor through the signal output by the motherboard 2, thereby controlling the flow of a larger current and driving the corresponding relay as a switch. When the pin corresponding to the base of the transistor outputs a high level, the transistor is turned on, the relay coil is energized, and the relay contacts are closed. When the output is a low level, the transistor is turned off, the relay coil is de-energized, and the relay contacts are opened. A resistor is connected in series between the base and emitter of the transistor to protect the base and prevent the transistor from being affected by noise signals and causing malfunctions.
[0020] Preferably, the above-mentioned transistors Q1, Q2 and Q3 all use NPN transistors with the commercial model S8050-J3Y as switch drive relays; the switching diodes D1, D2 and D3 all use diodes with the commercial model 1N4007W as freewheeling diodes to protect the transistors from breakdown, the resistance of the resistors R1, R3 and R9 is 1KΩ, and the resistors R1, R3 and R9 serve as current limiting resistors to prevent high voltage from impacting the mainboard 2. The resistance of the resistors R2, R4, R5, R7 and R8 is 10KΩ, among which the resistors R2, R7 and R8 serve as pull-down resistors for anti-interference to prevent the relay from malfunctioning. The resistance of the resistor R6 is 100KΩ, and the resistance of the current measuring resistor U2 is 0.14Ω.
[0021] Relay conduction status and input mode: When relay K1 is turned on, a 1.5V potential difference is added between the A0 test terminal and the A1 test terminal for measuring positive and negative voltages; when relay K2 is turned on, a 0.14Ω current measuring resistor U2 is connected in parallel between the A0 test terminal and the A1 test terminal, so that the A0 test terminal and the A1 test terminal can be used to measure current; when relay 3 is turned on, a 100kΩ resistor R6 is connected in parallel between the A0 test terminal and the A1 test terminal for balancing the voltage difference. When the relay combination is turned on, it is divided into the following three modes: ① When relay K1, relay K2 and relay K3 are all off, it is single-ended input mode, the A0 test terminal is used as the positive pole, and the test terminal GND is used as the negative pole. The sensor can only measure forward voltage or forward current; ② When relay K1 and relay K3 are turned on, and relay K2 is not turned on, it is double-ended input mode, the A0 test terminal is used as the positive pole, and the A1 test terminal is used as the negative pole. The sensor measures positive and negative voltages; ③ When relay K1 and relay K2 are turned on, and relay K3 is not turned on, it is current measurement mode, the A0 test terminal is used as the positive pole, and the A1 test terminal is used as the negative pole. The sensor measures positive and negative currents.
[0022] The sensor operates as follows: An external input key is connected to the mainboard 2. When the key switch is closed, the mainboard 2 detects the key press and generates a control signal, which is output to the switching circuit. The control signal switches the relay in the switching circuit on and off, switching between different current and voltage sensor modes. The A0, A1, and GND test terminals can be connected to an external probe via the U6 array to measure the external circuit under test. The resulting voltage or current analog signal is output to the ADC 3 for processing, conversion to a digital signal, and then output to the mainboard 2 for further processing.
[0023] It should be noted that ADC 3 utilizes existing technology, specifically the commercially available ADS1120-Q1. A brief description is provided below: The ADS1120-Q1 is a 16-bit ADC with two differential inputs or four single-ended inputs implemented using a flexible input multiplexer (MUX), a low-noise programmable gain amplifier (PGA), two programmable excitation current sources, a voltage reference, an oscillator, a low-side switch, and a precision temperature sensor. By selecting the ADS1120 chip as the ADC sampling chip, its integrated features can reduce the cost of the sensor system and the number of components used in sensor signal measurement applications, enabling high-precision voltage sampling and improving measurement accuracy and reliability.
[0024] Based on the above scheme, as a preferred embodiment, the switching circuit also includes a preset array, which includes array U1 and array U6. The other end of resistor R9 is also connected to pin 2 of array U4 to the positive electrode of the 3.3V power supply, pin 3 of array U4 is connected to the positive electrode of the 3.3V power supply, and pins 1, 5, and 6 of array U4 are all connected to the negative electrode of the 3.3V power supply. The other end of resistor R1 and the other end of resistor R3 are also connected to pin 2 and pin 3 of array U1, respectively, pin 4 of array U1 is connected to the positive electrode of the 3.3V power supply, and pins 1, 5, and 6 of array U1 are all connected to the negative electrode of the 3.3V power supply. The transistors are connected to the IO of the motherboard through the preset resistor array, which can simplify the physical layout and design of the circuit. In addition, the preset resistor array can also serve as an extended function interface, which can be used to connect different sensors to measure other physical quantities, such as piezoelectric sensors and ultrasonic sensors, to expand the measurement function and improve the flexibility of circuit design based on the switching circuit.
[0025] As mentioned above, the present invention uses a relay as a switch switching circuit. Through the external input button of the mainboard, the mainboard can send a control signal to the relay while switching the function menu, so that the relay of the switching module conducts the corresponding circuit, so that different electrical sensors can be switched by just long pressing the button, and the software and hardware are switched at the same time without additional operation. This not only improves the user experience, but also prevents incorrect operation and forgetting steps from causing the sensor to burn out and become scrapped, thereby enhancing the safety and reliability of the sensor. At the same time, the addition of a preset group allows the switching circuit to be expanded to connect to other components to achieve the purpose of measuring other physical quantities. The multi-purpose use of one machine can reduce the purchase cost, and the components used are all affordable, so the production cost is relatively reduced.
[0026] Obviously, the above embodiments of the present invention are merely examples for the purpose of clearly illustrating the present invention and are not intended to limit the embodiments of the present invention. A person skilled in the art would be able to make various obvious changes, readjustments, and substitutions without departing from the scope of protection of the present invention. It is not necessary and impossible to enumerate all embodiments here. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention shall be included within the scope of protection of the claims of the present invention.
Claims
1. An electrical parameter integrated teaching sensor based on ESP32, characterized in that: The invention comprises a mainboard (1), an ADC analog-to-digital converter (2), a switching module (3) and a power module (4), wherein the output end of the mainboard (1) is connected to the input end of the switching module (3), the output end of the switching module (3) is connected to the input end of the ADC analog-to-digital converter (2), the output end of the ADC analog-to-digital converter (2) is connected to the input end of the mainboard (1), and the power module (4) is connected to the mainboard (1) and the switching module (3) respectively, and the power module (4) is used to provide operating power.
2. The electrical parameter integrated teaching sensor based on ESP32 according to claim 1, characterized in that: The switching module (3) comprises a switching circuit, which comprises a relay K1, a relay K2 and a relay K3; a pin 1 of the relay K1 is connected to the anode of the switching diode D3 and to the positive electrode of a 3.3V power supply, a pin 4 of the relay K1 is respectively connected to the cathode of the switching diode D3 and the collector of the triode Q3, a base of the triode Q3 is respectively connected to one end of a resistor R8 and one end of a resistor R9, the other end of the resistor R8 is connected to the emitter of the triode Q3 and to the negative electrode of the 3.3V power supply, the other end of the resistor R9 is connected to the IO port of the mainboard 2, and the pins 5 of the relay K1 are respectively connected to the cathode of the switching diode D3 and the collector of the triode Q3. One end of the resistor R4 is connected to one end of the resistor R5, the other end of the resistor R4 is connected to the positive electrode of the 3V power supply, the other end of the resistor R5 is used as a GND test end and is connected to the negative electrode of the 3V power supply, the pin 3 of the relay K1 is normally closed, the pin 2 of the relay K1 is used as an A1 test end and is respectively connected to the pin 5 of the relay K2 and the pin 5 of the relay K3; the pin 1 of the relay K2 is connected to the anode of the switching diode D1 and the positive electrode of the 3.3V power supply, the pin 4 of the relay K2 is respectively connected to the cathode of the switching diode D1 and the collector of the triode Q1, and the base of the triode Q1 is respectively connected to the One end of the relay K3 is connected to one end of the resistor R1, the other end of the resistor R1 is connected to the IO port of the mainboard 2, the other end of the resistor R2 is connected to the emitter of the triode Q1 and connected to the negative electrode of the 3.3V power supply, the pin 3 of the relay K2 is normally closed, and the pin 2 of the relay K2 is connected to one end of the current measuring resistor U2; the pin 1 of the relay K3 is connected to the anode of the switching diode D2 and connected to the positive electrode of the 3.3V power supply, the pin 4 of the relay K3 is respectively connected to the cathode of the switching diode D2 and the collector of the triode Q2, the base of the triode Q2 is respectively connected to one end of the resistor R3 and one end of the resistor R7, and the resistor R The other end of the resistor R7 is connected to the emitter of the transistor Q2 and the negative electrode of the 3.3V power supply, the pin 3 of the relay K3 is normally closed, and the pin 2 of the relay K3 is connected to one end of the resistor R6; the other end of the current measuring resistor U2 is connected to the other end of the resistor R6 and serves as the A0 test terminal; and also includes a row group U6, the GND test terminal, the A0 test terminal and the A1 test terminal are respectively connected to the pin 1, pin 2 and pin 3 of the row group U6, the pin 4 of the row group U6 is connected to the positive electrode of the 3V power supply, and the pin 1, pin 5 and pin 6 of the row group U6 are all connected to the negative electrode of the 3V power supply.
3. An electrical parameter integrated teaching sensor based on ESP32 according to claim 2, characterized in that: The switching circuit also includes a preset group, which includes a group U1 and a group U4. The other end of the resistor R9 is also connected to pin 2 of the group U4 and connected to the IO port of the mainboard 2. Pin 3 of the group U4 is connected to the positive electrode of the 3.3V power supply, and pin 1, pin 5 and pin 6 of the group U4 are all connected to the negative electrode of the 3.3V power supply; the other end of the resistor R1 and the other end of the resistor R3 are also respectively connected to pin 2 and pin 3 of the group U1 and connected to the IO port of the mainboard 2. Pin 4 of the group U1 is connected to the positive electrode of the 3.3V power supply, and pin 1, pin 5 and pin 6 of the group U1 are all connected to the negative electrode of the 3.3V power supply.