The complexity of the deal is much less than the fear of things
The STM32F407 Single Hip Mini PC is connected to Android Mobile Phone App via ESP8266 WiFi Module.
- Android mobile application
1. Equipment configuration of the lower machine
One of the microcomputer models used in this article is the STM32F407. If other models of single-hip microcomputer are used, you only need to change the software a little bit. Since the single-product device serial port is used as a boot program, the boot program. This article uses serial three three. All symbols used in STM32 can be downloaded from the link at the end of this article. In the program, you can see the third serial configuration, the Wi-Fi module in the program. Connecting one mini computer can enter the interface reserved by one development board, just like the above picture.
If there are no reserved interfaces, you need to use DuPont to connect. The Wi-Fi module power supply can be connected to 3.3V and 5V, then connect the RX PIN pins of the air conditioner to the WiFi module in the third serial port, and the TX pin of the Wi-Fi module. Serial port RX Pins three of the same chip machine, the Wi-Fi ground module is connected to the ground device.
2. Configure the WIFI module
The WiFi module used in this article is very familiar with the WiFi module mode, you may want to know it first.
This article defines a WiFi module as a TCP server mode in AP mode, which is equivalent to a router, and configures the IP address and port number of the WiFi module. You can control the equipment connected to a single-shell microcomputer to achieve the simple IoT function.
The configuration of the WiFi module is completed with the AT instruction. The following are commonly used in instructions:
-
in
When asked if the connected Wi-Fi module is working properly, if it is working fine, it returns fine. -
AT+RST
Restart the Wi-Fi module. -
AT + CWMODE = n
When n = 1: set the WiFi module working mode to STA mode;
When n = 2: Set the Wi-Fi module working mode to AP mode;
when n=3: set the WiFi module working mode to STA+AP mode; -
AT+CWMODE?
Inquire about the current working status of the Wi-Fi module. -
AT + CWSAP =
, , ,
Configure AP settings that are valid only in AP mode.: Wi-Fi access point name; : Wi-Fi password; : channel ; : encryption method, 0 – OPEN, 1 – WEP, 2 – WPA_PSK, 3 – WPA2_PSK, 4 – WPA_WPA2_PSK;
After the preparation of these instructions is completed. The network cannot be connected. Currently you need to send AT+RST to restart the instruction and wait a bit. -
AT + CIPMUX = N.
when n = 0: the Wi-Fi module is set to connection order mode;
when n = 1: the Wi-Fi module is set to multi-adaptation mode; -
AT+CIPMUX
Check if the Wi-Fi module is currently installed. -
AT + CIPMODE = n
when n = 0: the Wi-Fi module is set to non-transplane mode;
when n = 1: the Wi-Fi module is set to transparent mode; -
AT+CIPMODE
Query the current transmission mode of the Wi-Fi module. -
AT + CIPSTO = XXXX
Set the Wi-Fi module timeout. -
AT+CIPSTO?
Check Wi-Fi module timeout server. -
AT + CIPSERVER = <الوضع> , <المنفذ>
Create / close the server.
<الوضع>: 0 – Close the server, 1 – Create the server.: Set the server end number.
notice:
1) When the Wi-Fi module is in multi-circuit mode (at + cipmux = 1), in order to unlock the server, the server must be restarted.
2) Automatic creation of server monitoring after running the server. When the client is reached, it will automatically take the connection in order. -
AT + CIPSTATUS
View the current Wi-Fi module connection. -
AT + CIPSEND
The Wi-Fi module sends data to the connection.
1) During one connection (+cipmux=0) instruction – +cipsend=
2) During a multilevel connection (+ cipmux = 1) AT + CIPSEND = instructions, : Customer ID. : the length of the data being sent.
Answer: Get this command and return “>” and then start receiving serial data. Send data when the data length reaches showers
If the connection or connection is down, an error is returned;
If the submitted data is successful, resubmit OK; -
AT + CIPSTART
Create a connection.
1) During one connection (+cipmux=0) AT+cipStart= instruction, , 2) During multilevel communication (+cipmux=1) instructions AT+CIPSEND= , , , For example, if you want to establish a TCP connection, the instructions are: in + cipstart=”2″, “TCP”, “192.168.4.101”, 8080
If you return OK correctly and successfully, it will return false;
If the connection already exists, restart Alream Connect; -
AT + CWLAR
Check out the current list of wireless routers. -
AT + CWJAP =
,
Add the specified network. -
in +CWJAP?
Query the access point on the current Wi-Fi module connection. -
AT+CWLIF
Query the currently available IP address by the WiFi module. -
in + CIFSR
Dial the Wi-Fi module’s IP address.
After understanding the common in the instructions, we will use the AT instructions to configure the WiFi module. This article sets up the WiFi module in the program. You can also use the serial assistant to send AT instructions to the computer side for initialization. AP Mode TCP server mode configuration process is as follows:
1. AT
Ответ:
OK
2. ATE0
Ответ:
OK
3. AT+CWMODE=2
Ответ:
OK
4. AT+RST
Ответ:
ready
5. AT+CWSAP="ssid","pwd",1,4
Ответ:
OK
6. AT+CIPMUX=1
Ответ:
OK
7. AT+CIPSERVER=1,8088
Ответ:
OK
8. AT+RST
Ответ:
OK
9. AT+CIFSR
ответ:
+CIFSR:APIP,"192.168.4.1"
+CIFSR:APMAC,"ea,68,e6,86,c5,39"
OK
After configuring the Wi-Fi module according to the above steps, you can enter the IP address (“192.168.4.1”) and port number (8088) in the phone app to establish a TCP connection and then transfer data.
STM32 single microcomputer and Android application.
STM32 single-chip microcomputer
For Android app configuration steps, please see
STM32 single-chip microcomputer