1 Project Introduction
An intelligent control node based on the Chuanzhi Education Hi3861 module. This module is a system package based on the HiSilicon Hi3861LV100 chip. It uses the Hongmeng embedded system and can achieve long-distance wireless control through WiFi.
Powered by two 18650 lithium batteries, all pin resources are utilized.
The main application scenarios in this project include: two-axis PTZ control, three-axis PTZ control, and dormitory wireless control switch.
2 Functional features
- 3-way PWM servo drive;
- 3-way vertical tact switch;
- 2-way controllable LED;
- 1 ADC acquisition pin;
- IIC’s 4pin 0096 OLED display;
3 circuit modules
(1) Main control circuit:
- Hi3861 master control, 3.3V power supply, can realize wifi communication, AP mode + STA mode, TCP, UDP and other communication protocols;
- Serial communication: CH340N serial port chip + spare 4P pin header interface.
(2) Pin configuration:
- 3-way PWM servo control: GPIO7 (PWM0), GPIO8 (PWM1), GPIO2 (PWM2);
- 3-way vertical key switch: GPIO11, GPIO12, GPIO13; [Capacitive hardware debounce]
- 2 controllable LEDs: GPIO6, GPIO14;
- 1-channel ADC acquisition: GPIO5 (ADC2); [Example: Sound sensor [MAX4466, realizing voice-activated switch function]
- 1-way OLED screen I2C interface: GPIO9 (SCL), GPIO10 (SDA).
(3) Power supply design:
Battery interface: 7.4~8.4 V-18650-lithium battery;
Type-C (800mA) interface: 5V power supply, serial port programming;
5.0V regulated LDO chip: LD1117-5.0 (1A);
3.3V regulated LDO chip: AMS1117-3.3 (500mA);
5.0V additional power supply input/output interface: 2pin header.
4 Schematic and PCB
(1) Schematic diagram:
(2) PCB:
5 Three-dimensional shell design
This shell is designed using SolidWorks2020 modeling software.
- Outer shell composition: bottom shell + top shell;
- Using FDM 3D printing, no support is required;
- Front bottom M3*2: MPU6050 module can be installed;
- Rear side back M3*4: fixing hole;
[Note! : When installing the bolts in the M3 hole on the back, be careful not to damage the wiring on the back]
6 Programming
Environment configuration teaching website: https://robot.czxy.com/ohos/
(This development environment is quite interesting. It links the virtual machine Ubuntu and the main system Win10. The editor is Clion and the burning tool is in the attachment)
Program framework:
- Main thread: OLED screen display and key interaction
- Timer: Collect the ADC2 pin voltage
- Thread Task1: Enable WIFI STA mode + receive UDP information
Function library:
- IIC communication library (ported from STM32)
- OLED display library: draw points, lines, circles, display characters... (ported from STM32)
- Steering gear control library: control angle, read angle
- ADC pin data reading library
- LED flash control library
Wireless control method: (UDP protocol)
Preconditions:
(1) The controller and the controlled one are connected to the same WIFI;
(2) How to obtain the IP address of the controlled terminal: serial port acquisition (115200 baud rate);
(3) On the PC side, enter ipconfig through cmd to obtain the ipv4 address; on the mobile side, search it on the WIFI setting interface.
Assumption: local IP: 192.168.31.138, controller IP: 192.168.31.80
Then, open the network debugger [in the attachment], and the machine sends control instructions to the controller through the UDP protocol.
- Select UDP protocol;
- Enter the local ipv4 address;
- Enter the port number;
- Click to connect;
- Enter the target ipv4 address;
- Enter the port number;
- Enter instructions;
- Click Send.
(The controller can be connected to the serial port to check whether it has received information)
[Source code in attachment]
7 APP design
The App program developed based on Android Studio serves as the host computer to send instructions. As mentioned in the previous chapter, the server and client communicate using the UDP protocol.
Function:
(1) Jump to the WIFI setting interface; (positioning and notification permissions are required)
(2) Obtain connected WIFI information;
(3) Instruction sending.
(The interface is very simple, this time I mainly use it for practice)
[.apk file is attached]
8 Physical display
(1) Main components:
(2) Power-on interface display:
[The demonstration video is in attachment V1...]
9 Application: Physical picture of main light switch in dormitory
Design Points:
- Servo model: MG996R;
- Apply the eccentric structure to solve the bean-shaped switch problem;
- The structures are all made of PLA material and manufactured by 3D printing;
- The main part is matched with M4 bolts to form a clamp, which is fixed on the light switch;
- The bevel angle of the main control board is 45°. The purpose is to: [1] stagger the positions of the MAX4466 sound sensor and the MG996R servo; [2] free up space for button interaction;
[This switch structure is designed for a special scene. For lighting switch structures in other scenes, you can refer to this example for modification and optimization]
[The video is in the attachments V2 and V3...]