Upgrade STM32 preheat: SCM regular intervals using http get weather

 

First, the realization of functions:

  1.1 STM32 AT command control Wi-Fi connect to TCP server (weather Web server), and then send commands to obtain weather according to API.

  It http://www.weather.com.cn/data/sk/ front API interface provided by the National Weather Service of these are fixed back to the city code 101 010 100, to be described later how to obtain city codes

  http://www.weather.com.cn/data/sk/101010100.html       get Beijing's weather provided a way

  

  http://www.weather.com.cn/data/cityinfo/101010100.html    Obtaining Beijing's weather provided 2

  

 

  1.2 is so direct input on page  http://www.weather.com.cn/data/sk/101010100.html

    The default port number is 80, so no need to write the port number can also  http://www.weather.com.cn:80/data/sk/101010100.html

  1.3 implemented with TCP http, so

    1.3.1 TCP connection IP address: www.weather.com.cn   Port Number: 80

    Then 1.3.2 transmission protocol: "GET /data/sk/101010100.html HTTP / 1.1 \ r \ nHost: www.weather.com.cn \ r \ n \ r \ n" to obtain

         However, due to the problem of encoding format will be Chinese garbled ..... only extract temp and SD

        

 

 

 

 

    1.3.3  单片机程序

    

 

 

 

    

 

 

 

 

    1.3.4  如果不明白我说的!

    

 

 

二,效果图:

 

 

 

三,操作流程

  3.1 硬件设置: 短接STM32   PB2 和 WIFI  RST   (以后均采用硬件复位)

  

  3.2 下载单片机程序

  

 

 

  

 

 

  3.3  如果想让WIFI连接路由器,可直接 去掉屏蔽

 

  

 

 

  

 

  如果采用以上步骤,可略过3.3-3.6使用软件给模块配网过程!

 

   

  3.4 由于SmartConfig 当前android9.0以上有兼容性问题,先提供    Airkiss  方式    (微信扫描下方二维码)                 

      

  3.5 调整波动开关位置,长按PB5               指示灯快闪,给WIFI模块配网        

            

  3.6 输入路由器密码,点击连接                                        配网成功(已经配置了WIFI连接了路由器)

                                                              

四,等待大约5S  如果一直不显示!,应该不可能不显示.除非国家气象那个域名有问题了!!!!

  

 

 

 

六,程序说明

  6.1  讲一下这个函数,上一节没有讲

  

  

 

 

  

 

 

 

 

 

   控制发送数据,接收判断数据

  

 

 

 

 

    

 

   真正判断返回处理是放到了

  

 

 

 

 

  

 

 

   

 

 

   我把所有需要注释说明的函数都加了这样的注释

  列如:

  

 

 

  我希望我的代码做到方便让别人移植使用

七 补充,其它城市代码

 

 

Guess you like

Origin www.cnblogs.com/yangfengwu/p/11668487.html