The previous article conducted a simple test on the development board to confirm that the circuits were intact. This article mainly introduces how to build the hardware circuit.
In order to facilitate outdoor testing, I plan to make two system modules that can work independently, each powered by a power bank. The tag module needs to have a screen display to observe the measured distance. After searching through boxes and cabinets, I put together the following circuit board. As shown below.
Figure 1 Experimental board used for testing
The board with screen is a defective product that was eliminated from a product I made before. It is designed based on STM32 microcontroller and has display, serial port, buttons, etc. It is more suitable for tag end control. The other board with shielding cover is an evaluation board based on Arduino programming, with serial port, suitable for base station end.
The base station is relatively simple, so let's set up the hardware first. As shown in the figure below, the corresponding interfaces of the Arduino board are all connected, so just connect them accordingly.
Figure 2 Arduino board interface
First connect them with Dupont wires to test whether the circuit is connected. The following figure shows the connection.
Figure 3 Arduino board connection
Write a test program in Arduino IDE , set the working mode of NodeMCU-BU01 to base station, and then the program will read the output of NodeMCU-BU01 module and upload it to facilitate status observation, as shown below.
Figure 4 Program setting base station mode
Connect another module to the computer serial port, put the two modules together, and test whether the communication is normal. See the figure below.
Figure 5 Two-module joint test
Observe the communication results through the serial port debugging assistant. The figure below shows that the two modules can measure distance normally, indicating that there is no problem with the circuit connection.
Figure 6 Communication is successful
Then solder the NodeMCU-BU01 module and the Arduino board with wires. The Dupont wires are prone to poor contact and are not suitable for mobile testing. Power the two boards with a power bank, and you can move them freely, as shown in the figure below. The base station part is ready.
Figure 7 Base station construction completed
Next, I built the tag hardware. Since I didn't use a finished development board, the whole process was very complicated, requiring disassembly, jumpering, soldering debugging interfaces, etc. It took me a whole day to adjust the hardware. The final product is as shown below. Although it looks a bit ugly, the circuit is useful.
Figure 8: The tag end circuit is built
In addition to connecting the NodeMCU-BU01 module and the MCU board, I also connected the TX and RX lines used for communication to a USB- to-serial port receiving end, so that it is convenient to observe the actual data transmission and reception of the two boards. If you have the need to debug the serial port protocol, if you have not used this method, I strongly recommend you to try it, which really improves programming efficiency.
Write a simple test program on STM32, as shown below, and set the NodeMCU-BU01 module to tag mode in 4 steps .
Figure 9 Program setting label mode
Through the two monitoring serial ports, we can see that the two boards are communicating normally, and the NodeMCU-BU01 module continuously reports the test distance, as shown in the figure below.
Figure 10 MCU communication is successful
At this point, the hardware test environment has been set up. The next step is to design the microcontroller program to display real-time measurement data on the screen.