你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

利用stm32+app inventor与esp8266通信

[复制链接]
STMCU小助手 发布时间:2022-10-16 20:19
关于stm32与esp8266之间的通信,在前面的文章中已经介绍得差不多了,本文章主要介绍的是app inventor的制作,然后生成app二维码,最后在手机端下载app,进而实现通过WIFI局域网控制stm32开发板,当然关于stm32与esp8266之间的一些东西也会粗略讲一下。; C! C- E3 ?4 U, I! d$ s1 U9 f
本章所用到的器件如下:. S" U/ m' {7 h' ~' \
STM32F103ZET6最小系统板
: M6 `. `3 `0 |ESP8266-01S模块- O$ e7 X1 y4 |6 x& D- o
USB转microUSB数据线5 _' }7 Y3 i! s) W* c0 z
四根杜邦线# l2 E0 e8 x. K, o  J

/ X- H- t- l' X, \7 a, @. }4 M
连接如下:
3 j: V2 U) c. f( Z! T9 N$ L( ]3 A32板3.3v----------->ESP8266的3.3v6 ^7 h1 d$ |: T0 y+ G
32板GND---------->ESP8266的GND
* r& u6 ^5 }, V; V+ p* s32板的PA2-------->ESP8266的RX( `: T  d4 M" w3 W1 G7 Z6 z
32板的PA3-------->ESP8266的TX3 G; ]! N, S& H% F' b  `. u8 |* i
) [. o: C; p% y- M. I
stm32与esp8266通信, I0 _7 _+ s4 A+ o
  先附上32程序的主代码:
: O' B2 q. O* m( G2 s
  1. <font face="Tahoma"><font size="3"><font color="#000000">#include "stdio.h"</font></font></font>
    ) m, I# s. b3 Q3 G8 n7 e, [* a9 {
  2. <font face="Tahoma"><font size="3"><font color="#000000">#include "delay.h"</font></font></font>
    : q2 P5 m( a$ a, r( @
  3. <font face="Tahoma"><font size="3"><font color="#000000">#include "led.h"</font></font></font>
    3 V) f3 H9 D9 a) V! M# w4 t
  4. <font face="Tahoma"><font size="3"><font color="#000000">#include "usart.h"</font></font></font>
    * O0 g+ i: i5 K$ y" t
  5. <font face="Tahoma"><font size="3"><font color="#000000">#include "serial.h"</font></font></font>
    " w/ Q4 ^% K+ t0 T$ r+ s% f' v
  6. <font face="Tahoma"><font size="3"><font color="#000000">#include "esp8266.h"</font></font></font>3 Y1 }6 _; m! K2 h7 X$ c$ u8 K
  7. <font face="Tahoma"><font size="3"><font color="#000000">
    & y( u; N3 e, X/ ^2 n2 ?
  8. </font></font></font>2 w7 p' `* ^& X8 d8 d* w
  9. <font face="Tahoma"><font size="3"><font color="#000000">/*        AT指令返回值的结尾没有\r\n这样的回车换行符,</font></font></font>* H4 a1 F' ~, P
  10. <font face="Tahoma"><font size="3"><font color="#000000"> *        而在串口调试助手中,需要MCU输出\r\n给串口调试助手才能刷新缓冲区把字符显示出来,</font></font></font>$ q9 @' S4 O1 x: D3 p
  11. <font face="Tahoma"><font size="3"><font color="#000000"> *        同时这个\r\n还起到回车换行的目的*/</font></font></font>* g  }/ r  c% K7 N$ g
  12. <font face="Tahoma"><font size="3"><font color="#000000"> </font></font></font>
    & i1 W8 Q' b" @
  13. <font face="Tahoma"><font size="3"><font color="#000000">/*        AT指令的结尾处必须是\r\n*/</font></font></font>
    % C5 P/ Y5 T1 M
  14. <font face="Tahoma"><font size="3"><font color="#000000">
    ) L. O; n$ y1 j( q# v
  15. </font></font></font>, J- |' ?$ \: G- y6 \
  16. <font face="Tahoma"><font size="3"><font color="#000000">/*        serial.h中的usart1_send_usart2函数用于没有USB转TLL模块的人使用,</font></font></font>/ |7 ~6 V6 G2 F4 g' a
  17. <font face="Tahoma"><font size="3"><font color="#000000"> *        此函数作用是利用串口1发送AT指令给串口2,串口2将AT指令发送给ESP8266,实现对ESP8266的AT指令配置,</font></font></font>" c) o7 l$ W& |! Y8 L1 K3 s+ @
  18. <font face="Tahoma"><font size="3"><font color="#000000"> *        当然,如果你有USB转TTL模块的话,可以直接将ESP8266与USB转TTL模块直连,然后在串口调试助手里面直接配置AT指令*/</font></font></font>
    & I' W/ E. S6 N( e! j+ P
  19. <font face="Tahoma"><font size="3"><font color="#000000">, K$ c) B9 [/ B6 Z* f
  20. </font></font></font>
    6 F, B; i% r# u& L6 G* h
  21. <font face="Tahoma"><font size="3"><font color="#000000">extern u8         esp_sipsend1[];</font></font></font>
    * I: v, l" a- }6 k6 v2 Z& M
  22. <font face="Tahoma"><font size="3"><font color="#000000">extern u8         esp_sipsend2[];</font></font></font>
    ; x6 @) o, {  O0 T
  23. <font face="Tahoma"><font size="3"><font color="#000000"># Z; u* r/ D& k" s- x
  24. </font></font></font>
    5 b( i" m# R5 P) A. g$ x) Z) I
  25. <font face="Tahoma"><font size="3"><font color="#000000">int main(void)</font></font></font>
    ; V5 l( b" T, T2 l5 `& H
  26. <font face="Tahoma"><font size="3"><font color="#000000">{        </font></font></font>
    . R# S( n# `- P' |7 m
  27. <font face="Tahoma"><font size="3"><font color="#000000">        delay_init();                                                                                     //延时函数初始化</font></font></font>5 Q# h/ S9 j* r+ Q6 L+ s. W7 i2 k
  28. <font face="Tahoma"><font size="3"><font color="#000000">        NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);                        //设置NVIC中断分组2:2位抢占优先级,2位响应优先级</font></font></font>. U8 t/ ~3 r7 A3 T2 s
  29. <font face="Tahoma"><font size="3"><font color="#000000">        uart_init(115200);                                                                                 //串口1初始化为115200</font></font></font>$ ?5 w+ a" e+ n
  30. <font face="Tahoma"><font size="3"><font color="#000000">        Uart2_Init(115200);                                                                                //串口2初始化为115200</font></font></font>3 `7 d2 b2 l+ C) A$ U( l0 _
  31. <font face="Tahoma"><font size="3"><font color="#000000">        LED_Init();                                                                                                  //初始化与LED连接的硬件接口</font></font></font>
    - y" }5 Y3 x/ X, u
  32. <font face="Tahoma"><font size="3"><font color="#000000">        Esp8266_Init();</font></font></font>
    2 i' s7 W) @2 u
  33. <font face="Tahoma"><font size="3"><font color="#000000">        </font></font></font>
    * D* t3 d- N5 }$ W2 J0 ]7 A( w
  34. <font face="Tahoma"><font size="3"><font color="#000000">  while(1)</font></font></font>
    3 P3 F' O3 h# E2 C
  35. <font face="Tahoma"><font size="3"><font color="#000000">        {        </font></font></font>
    ( a2 S% j8 U9 r* \
  36. <font face="Tahoma"><font size="3"><font color="#000000">                usart1_send_usart2();                                                                //利用串口1发送AT指令给串口2,从而达到配置ESP8266的目的,并且让模块的返回值在串口1打印出来</font></font></font>1 |% t( q& p9 h1 r
  37. <font face="Tahoma"><font size="3"><font color="#000000">                if(Data_Compare((u8 *)"LEDK"))                               //点亮板上的led</font></font></font>( m, B, ?' ]7 `; J8 p
  38. <font face="Tahoma"><font size="3"><font color="#000000">                {                </font></font></font>) \: U0 n0 D$ o1 A; i) \$ O: M2 \7 [6 F
  39. <font face="Tahoma"><font size="3"><font color="#000000">            led(1);        </font></font></font>
    + k( e6 P/ k: r. V$ o3 m$ D) I
  40. <font face="Tahoma"><font size="3"><font color="#000000">                        Clear_Buf();</font></font></font>
    * |* c: E) k9 |* r2 U  _+ W# @
  41. <font face="Tahoma"><font size="3"><font color="#000000">                        Uart_SendStr(USART1, (u8 *)"led is open\r\n");        </font></font></font>
    ) a4 I8 Q7 h4 q) H: X
  42. <font face="Tahoma"><font size="3"><font color="#000000">                        Uart_SendStr(USART2, esp_sipsend1);                                //利用串口2给esp8266发送AT+CIPSEND指令,告诉它下一次将发送具体数据</font></font></font>
    5 G9 C( A# F5 q
  43. <font face="Tahoma"><font size="3"><font color="#000000">                        Usart2_Receive_Data(USART1);                                        //将串口2接收到的AT+CIPSEND指令返回的数据显示在串口1上</font></font></font>; n" u  H2 x; H5 z: t7 Q- N
  44. <font face="Tahoma"><font size="3"><font color="#000000">                        Uart_SendStr(USART2, (u8 *)"led is open\r\n");        //发送具体数据给esp8266,让他转发到app上</font></font></font>5 t5 j8 f( ?0 Z. ?
  45. <font face="Tahoma"><font size="3"><font color="#000000">                }</font></font></font>9 C- C. W" M3 q9 k# ^3 a
  46. <font face="Tahoma"><font size="3"><font color="#000000">                else if(Data_Compare((u8 *)"LEDG"))                                    //关闭板上的led</font></font></font>! q: d) U/ Z* N7 M
  47. <font face="Tahoma"><font size="3"><font color="#000000">                {</font></font></font>- m1 @& m# ^+ F) Q  I: A( k4 C& c
  48. <font face="Tahoma"><font size="3"><font color="#000000">            led(0);</font></font></font>/ \. h( b/ R- w4 Z" Z; Z: D
  49. <font face="Tahoma"><font size="3"><font color="#000000">                        Clear_Buf();</font></font></font>
    , u  W/ K& \$ y1 s$ f) Y) W
  50. <font face="Tahoma"><font size="3"><font color="#000000">                        Uart_SendStr(USART1, (u8 *)"led is close\r\n");        </font></font></font>
    3 n6 {8 e4 J: a
  51. <font face="Tahoma"><font size="3"><font color="#000000">                        Uart_SendStr(USART2, esp_sipsend2);                                //利用串口2给esp8266发送AT+CIPSEND指令,告诉它下一次将发送具体数据</font></font></font>
    + a/ R  B* n3 B* w7 m6 ?+ R& p
  52. <font face="Tahoma"><font size="3"><font color="#000000">                        Usart2_Receive_Data(USART1);                                        //将串口2接收到的AT+CIPSEND指令返回的数据显示在串口1上</font></font></font>
    3 Z6 ]+ Y" s; P% m. Z
  53. <font face="Tahoma"><font size="3"><font color="#000000">                        Uart_SendStr(USART2, (u8 *)"led is close\r\n");        //发送具体数据给esp8266,让他转发到app上                </font></font></font>
    ' p% @# H, @. F4 Q, e
  54. <font face="Tahoma"><font size="3"><font color="#000000">                }</font></font></font>. ?7 k& O# n, J9 W" A
  55. <font face="Tahoma"><font size="3"><font color="#000000">        }</font></font></font>
    # q* V9 y9 h4 n% g; a" `8 y% W
  56. <font face="Tahoma"><font size="3"><font color="#000000">}</font></font></font>
复制代码

3 J" u; e4 q9 d5 r, i" Q+ O. F  此代码中的serial.h包含几个自定义函数,其函数的作用见其右边的注释,代码如下所示:8 v, g3 f% w/ P4 E9 ]
  1. <font face="Tahoma"><font size="3"><font color="#000000">#ifndef        __SERIAL_H</font></font></font>! i7 v9 V" h) _- e! `
  2. <font face="Tahoma"><font size="3"><font color="#000000">#define __SERIAL_H</font></font></font>( s, g; K) I3 \& N; G- I2 v# ~
  3. <font face="Tahoma"><font size="3"><font color="#000000">#include "stdio.h"        </font></font></font>
    : y5 ~- {6 p. x0 |- s) d# x6 c
  4. <font face="Tahoma"><font size="3"><font color="#000000">#include "sys.h" </font></font></font>
    : L- ?0 ~0 @+ R1 V. g( }
  5. <font face="Tahoma"><font size="3"><font color="#000000">#include "delay.h"</font></font></font>
    4 }4 V) Y% s( N( Q7 _
  6. <font face="Tahoma"><font size="3"><font color="#000000">#include  "string.h"</font></font></font>
    ' `% d" S1 @; u! k  c! c2 [/ J
  7. <font face="Tahoma"><font size="3"><font color="#000000">#include "usart.h"</font></font></font>
    1 I* I. X5 m* D1 }  X2 C: [
  8. <font face="Tahoma"><font size="3"><font color="#000000">% N4 J; }, ~5 E6 y7 K! k
  9. </font></font></font>
    # W4 c( ^4 m7 D( E( _, a
  10. <font face="Tahoma"><font size="3"><font color="#000000">#define tbuf 100</font></font></font>
    / V3 s% j4 K9 n3 E8 q9 _, ~5 e4 Z
  11. <font face="Tahoma"><font size="3"><font color="#000000">$ w5 \1 J: ]( P/ x$ L; d/ N
  12. </font></font></font>' o7 o5 V* U1 ]0 u. a( ~
  13. <font face="Tahoma"><font size="3"><font color="#000000">void Uart2_Init(u32 bound);                                                        //初始化串口2</font></font></font>( C; E, F2 E; W, x# o+ K1 R
  14. <font face="Tahoma"><font size="3"><font color="#000000">void Clear_Buf(void);                                                                //清除缓冲区数据</font></font></font>
    ( q  _. |0 H' L$ X# N& s
  15. <font face="Tahoma"><font size="3"><font color="#000000">void Uart_SendStr(USART_TypeDef* USARTx, u8 *s);        //往某一个串口发送指定字符串</font></font></font>
    ; g2 T. _$ e; k
  16. <font face="Tahoma"><font size="3"><font color="#000000">void Usart2_Receive_Data(USART_TypeDef* USARTx);        //将串口2返回的数据发送给串口1进行显示</font></font></font># B% R/ W2 p2 [  Y0 ]
  17. <font face="Tahoma"><font size="3"><font color="#000000">u8 Data_Compare(u8 *p);                                                                //指定字符串与缓存数组数据进行数据比较</font></font></font>; K, y: q5 c/ {% X. m5 f
  18. <font face="Tahoma"><font size="3"><font color="#000000">void usart1_send_usart2(void);                                                //利用串口1发送AT指令给串口2,从而达到配置ESP8266的目的,并且让模块的返回值在串口1打印出来</font></font></font>
    + p, c+ \7 v; h; c" C+ Y4 V
  19. <font face="Tahoma"><font size="3"><font color="#000000"># c; n( p+ Y2 f. U" r& X; u# `2 j
  20. </font></font></font>
      G# J) u" c& U- Y# v
  21. <font face="Tahoma"><font size="3"><font color="#000000">#endif</font></font></font>
复制代码

1 L) q. m/ c, E$ @  其中Usart2_Receive_Data函数是用于接收esp8266返回的数据并在串口1进行显示,因为串口2是与esp8266进行连接的,只要串口2正确发送AT指令给esp8266,esp8266都会返回响应值,由于手头上没有USB转TTL模块,只能用这种方法来观察esp8266模块的返回值。
+ ]' o2 t) x, n* \/ M  而usart1_send_usart2函数的作用是利用串口调试助手发送AT指令给串口1,串口1接收到数据之后,将数据通过串口2发送给esp8266模块,达到通过串口调试助手发送AT指令配置esp8266模块的目的,之所以用这种方式,其原因是手头上没有USB转TTL模块,才出此下策。
' d" o5 o$ p7 H) Y% H+ E) \+ G  假如手头上有USB转TTL模块,上面的两个函数大可不必要,直接将USB转TTL直连上esp8266模块,然后USB端插在电脑上,利用串口调试助手即可直接发送AT指令去配置esp8266模块以及显示模块的返回值。
* L4 H# i1 r  \  主函数中的Esp8266_Init函数是对esp8266进行一系列的配置,使得能够被app客户端所连接上,其详细代码如下所示:) d7 w- b9 f  ]. o" r

8 G9 y9 z' s( B% U# w3 f, d, d" x
  1. <font face="Tahoma"><font size="3"><font color="#000000">#include "esp8266.h"</font></font></font>: R7 o! A8 a. }: J) _; Y; I
  2. <font face="Tahoma"><font size="3"><font color="#000000">
    ( [% G. o+ @2 [5 v9 Q% M8 J4 c1 Z
  3. </font></font></font>
    8 o+ b: @) D" }. {7 h
  4. <font face="Tahoma"><font size="3"><font color="#000000">u8  esp_at[] = "AT\r\n";                                          //握手连接指令,返回"OK"</font></font></font>1 w) I  V" c. P( N) ?: a
  5. <font face="Tahoma"><font size="3"><font color="#000000">u8  esp_cifsr[] = "AT+CIFSR\r\n";                                 //本机IP地址查询指令</font></font></font>7 b% x0 q5 |: W& S5 s( a8 J9 C
  6. <font face="Tahoma"><font size="3"><font color="#000000">u8  esp_cipsend[] = "AT+CIPSEND=6\r\n";                           //设置发送数据长度</font></font></font>
    5 w% K9 o" h# @1 J
  7. <font face="Tahoma"><font size="3"><font color="#000000">u8  esp_test[] = "sunny\r\n";                                           //数据内容</font></font></font>6 O! d/ ]% H) j6 `' L1 @  d
  8. <font face="Tahoma"><font size="3"><font color="#000000">u8  esp_rst[] = "AT+RST\r\n";                                                 //软件复位</font></font></font>
    4 Q7 l, t" |& I4 m8 Q3 _* J
  9. <font face="Tahoma"><font size="3"><font color="#000000">u8  esp_cwmode[] = "AT+CWMODE=2\r\n";                             //设置ESP8266的工作模式2(AP模式,WIFI模块作为热点),返回"OK"或者"no change"</font></font></font>, z% h: i! o: |6 _
  10. <font face="Tahoma"><font size="3"><font color="#000000">u8  esp_cwsap[] = "AT+CWSAP="ESP8266_TEST","1234567890",1,4\r\n";//设置WIFI的名称、密码、通道号、加密方式(4-WPA_WPA2_PSK)</font></font></font>
    . E0 N- T+ e* v( O2 g/ X8 t5 e$ [
  11. <font face="Tahoma"><font size="3"><font color="#000000">u8  esp_cipmux[] = "AT+CIPMUX=1\r\n";                           //打开多连接        </font></font></font>8 z& q) R8 i+ }+ A" K: D; T0 {5 I
  12. <font face="Tahoma"><font size="3"><font color="#000000">u8  esp_cipserver[] = "AT+CIPSERVER=1,8080\r\n";          //建立TCP服务器,开放端口8080,端口号可以改成其他的例如8086等等</font></font></font>) i* V) ^+ v2 L- m3 H+ A5 v( a
  13. <font face="Tahoma"><font size="3"><font color="#000000">u8         esp_cipsto[] = "AT+CIPSTO=2880\r\n";                        //设置服务器超时时间为2880s,也就是连接服务器过程中可以等待的时间</font></font></font>
    0 Z: L, a/ B3 u# R# J
  14. <font face="Tahoma"><font size="3"><font color="#000000">4 o/ e$ U2 m6 Z$ m2 [% n! Y
  15. </font></font></font>
    & m9 N  k; P1 u$ R* R( X
  16. <font face="Tahoma"><font size="3"><font color="#000000">extern u8        RX_num;                                                                   //接收计数变量</font></font></font>' h* H: U% ^. `' k
  17. <font face="Tahoma"><font size="3"><font color="#000000">extern u8  RX_buffer[tbuf];</font></font></font>
    ( r0 Q1 e& E: m) y
  18. <font face="Tahoma"><font size="3"><font color="#000000">/ e1 d9 L. b3 v: k' Z/ U8 B6 e
  19. </font></font></font>$ b8 w- `6 D5 Y3 q
  20. <font face="Tahoma"><font size="3"><font color="#000000">void Esp8266_Init(void)</font></font></font>
    ) O# N+ _" v% l' F% x6 d0 M* Z: `
  21. <font face="Tahoma"><font size="3"><font color="#000000">{</font></font></font>
    / s$ r( {$ `: ?$ y7 C: o0 g6 f
  22. <font face="Tahoma"><font size="3"><font color="#000000">        Uart_SendStr(USART2, esp_cwmode);                   //设置ESP8266的工作模式2 AP,返回"OK"或者"no change"</font></font></font>
    * ~* A% s: [, M/ Y; U! @5 h
  23. <font face="Tahoma"><font size="3"><font color="#000000">        Usart2_Receive_Data(USART1);                        //将串口2收到的数据发送给串口1进行显示</font></font></font>! U' s2 }- a( u5 b1 c
  24. <font face="Tahoma"><font size="3"><font color="#000000">        Uart_SendStr(USART1, (u8 *)"\r\nOK,set mode as AP with ESP8266!\r\n----------\r\n");</font></font></font>
    # O. x. a1 X- r' z- H$ R0 M
  25. <font face="Tahoma"><font size="3"><font color="#000000">        </font></font></font>
    - K' s' _3 Z  W! N' t9 |' p
  26. <font face="Tahoma"><font size="3"><font color="#000000">        Uart_SendStr(USART2, esp_rst);                           //设置ESP8266的工作模式后需要复位以生效该模式</font></font></font>/ D2 n: _5 i1 z6 V" E! }& |
  27. <font face="Tahoma"><font size="3"><font color="#000000">        Usart2_Receive_Data(USART1);                        //复位后可能会返回一堆乱码</font></font></font>' j+ P2 u8 m5 O
  28. <font face="Tahoma"><font size="3"><font color="#000000">        Uart_SendStr(USART1, (u8 *)"\r\nOK,set RST success!\r\n----------\r\n");</font></font></font>: t5 w( I$ S! g* s; `5 S: ~7 g3 U
  29. <font face="Tahoma"><font size="3"><font color="#000000">        </font></font></font>
    % t$ B: ?* B  R7 T/ @6 ]
  30. <font face="Tahoma"><font size="3"><font color="#000000">        Uart_SendStr(USART2, esp_cwsap);                   //设置WIFI的名称及密码</font></font></font>: H# m) c. H4 |+ y  d. m
  31. <font face="Tahoma"><font size="3"><font color="#000000">        Usart2_Receive_Data(USART1);                        //将串口2收到的数据发送给串口1进行显示</font></font></font>
    . S7 D0 ^8 I% m* S
  32. <font face="Tahoma"><font size="3"><font color="#000000">        Uart_SendStr(USART1, (u8 *)"\r\nOK,set cwsap success!\r\n----------\r\n");</font></font></font>3 `. h, Q+ [! L1 \3 h, M% ?; ~
  33. <font face="Tahoma"><font size="3"><font color="#000000">        </font></font></font>
    " [) D, b; f+ Z
  34. <font face="Tahoma"><font size="3"><font color="#000000">        Uart_SendStr(USART2, esp_cipmux);                   //设置多连接(多路连接模式)</font></font></font>- v" x% E0 ^& F  n
  35. <font face="Tahoma"><font size="3"><font color="#000000">        Usart2_Receive_Data(USART1);                        //将串口2收到的数据发送给串口1进行显示</font></font></font>3 n! Q; g  F" i! ]
  36. <font face="Tahoma"><font size="3"><font color="#000000">        Uart_SendStr(USART1, (u8 *)"\r\nOK,set cipmux success!\r\n----------\r\n");</font></font></font>, X: r2 @* Z6 `2 ~# `" S* X- D! G# h
  37. <font face="Tahoma"><font size="3"><font color="#000000">        </font></font></font>. G& L3 T0 L* I) y; m, Y* o
  38. <font face="Tahoma"><font size="3"><font color="#000000">        Uart_SendStr(USART2, esp_cipserver);        //设置wifi模块为TCP服务器模式,并配置端口为8080</font></font></font>
    & Y+ E- _% S; g: _, L; X
  39. <font face="Tahoma"><font size="3"><font color="#000000">        Usart2_Receive_Data(USART1);                        //将串口2收到的数据发送给串口1进行显示</font></font></font>
    ; {2 ^3 r* L' `8 Q
  40. <font face="Tahoma"><font size="3"><font color="#000000">        Uart_SendStr(USART1, (u8 *)"\r\nOK,set server success!\r\n----------\r\n");</font></font></font>) B* t4 k0 _+ X+ Q* q+ w
  41. <font face="Tahoma"><font size="3"><font color="#000000">        </font></font></font>
    . X  E/ \5 k2 L2 z5 K- O
  42. <font face="Tahoma"><font size="3"><font color="#000000">        Uart_SendStr(USART2, esp_cipsto);                //设置服务器超时时间为2880s</font></font></font>
    / R: W$ b0 o6 Z0 n7 x- J' _& u6 l  I
  43. <font face="Tahoma"><font size="3"><font color="#000000">        Usart2_Receive_Data(USART1);                        //将串口2收到的数据发送给串口1进行显示</font></font></font>; s1 J/ b- |) {! i! j
  44. <font face="Tahoma"><font size="3"><font color="#000000">        Uart_SendStr(USART1, (u8 *)"\r\nOK,set cipsto success!\r\n----------\r\n");</font></font></font>7 t) G" C/ f+ n5 W. k. _
  45. <font face="Tahoma"><font size="3"><font color="#000000">        </font></font></font>
    " Y, H% K/ G! v/ f
  46. <font face="Tahoma"><font size="3"><font color="#000000">        Uart_SendStr(USART2, esp_cifsr);                //获取本机IP地址</font></font></font>5 V6 i5 w7 @$ L/ o4 _, [
  47. <font face="Tahoma"><font size="3"><font color="#000000">        Usart2_Receive_Data(USART1);                        //将串口2收到的数据发送给串口1进行显示</font></font></font>
    ) ?$ j9 |% t  s. T
  48. <font face="Tahoma"><font size="3"><font color="#000000">        Uart_SendStr(USART1, (u8 *)"\r\nOK,get ip address success!\r\n----------\r\n");</font></font></font>
    ( ^7 `8 |; T* u, }1 l1 u* A3 p
  49. <font face="Tahoma"><font size="3"><font color="#000000">}</font></font></font>
复制代码
, x% ^& }# }' f+ z/ t0 h
  至于其中的AT指令,网上随便找一下都有一大堆关于AT指令的详细解释,这里就不再过多解释,而其他的函数,也没有什么好讲的,至此,stm32代码部分就到这里了。& f. r  T% Y2 X! K2 l1 T! K$ i% C
1 A9 t$ Y0 p! g7 F6 @6 c0 z' x
移动端app制作、生成、控制
& @) d) d, X8 B$ X  接着进行app的设计,本章app的设计采用的是app inventor。
, C& r" c8 w8 ~1 N- a  APP INVENTOR由谷歌实验室开发,后移交麻省理工学院,是一款可视化编程环境,采用搭积木的方式快速建立应用程序,并且可以结合AI伴侣,极其便利的在手机上进行测试和应用。& w" O% |( O+ c: y4 }' i
  APP INVENTOR是完全基于网页的在线编程工具,国内外都有一些可用的服务器。' a$ y! w$ }# g& b' B! y

/ u! D" d" a9 p6 c0 B1 R0 P
6e76da6c9a4849978af1bad2f967ed1d.png
2 {) I8 U% e% L( r. p

$ Z, I% `9 I* F) G  可以用QQ登录,登录后创建项目就可以进入编程界面。: Y5 g% j: j# Z6 a  M- _* {
7 }* v2 D0 v1 R
59ae0fd06bdd4b6e937c9b1895b5e8e0.png

; e; o7 U% J8 L( E
: ?: i5 W8 r0 {8 ?! j# S: y) g# |, ~
  中间显示的就是手机屏幕,通过拖拽工具到手机屏幕,就可以开始编程了,目前只支持Android手机。
$ G2 L% v, g' b+ [9 o  为了便于编程调试可以在手机上安装AI伴侣,下载地址可以通过点击菜单栏 帮助->AI伴侣信息 打开下载帮助页。
: ]$ T, B% e# @8 T) ~5 \  k————————————————! L+ b' x& u, K/ S% o6 t
版权声明:i土豆8 J* l, d0 F- Y6 _. W" D: t
. \, [9 c* z/ F% Z" b6 D/ }

" s5 t/ V- N9 ?. _
收藏 评论0 发布时间:2022-10-16 20:19

举报

0个回答

所属标签

相似分享

官网相关资源

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
st-img 微信公众号
st-img 手机版