主要目标
1.从和风天气API获取天气数据,解析后通过串口发送到战舰开发板上
2.战舰开发板驱动传感器进行实时天气数据的采集,通过串口传到PC机
参考工程
感谢机智云物联网开发者社区的帖子,本系统STM32端很短代码参考自这位大神发的帖子:战舰V3通过ESP8266获得网络天气,电脑端Java串口的编写主要参考(下载):使用Java实现串口通信,虽然很多代码都不是我动手写的,但是为了这个课设仍然做了许多努力,希望能记录下来。再次感谢这两位大神!
项目笔记
Json字符串的解析
和风天气API返回的是一个Json字符串比如
{"HeWeather6":[{"basic":{"cid":"CN101010100","location":"北京","parent_city":"北京","admin_area":"北京","cnty":"中国","lat":"39.90498734","lon":"116.4052887","tz":"+8.0"},"update":{"loc":"2018-01-27 16:50","utc":"2018-01-27 08:50"},"status":"ok","daily_forecast":[{"cond_code_d":"101","cond_code_n":"101","cond_txt_d":"多云","cond_txt_n":"多云","date":"2018-01-27","hum":"34","mr":"13:16","ms":"02:41","pcpn":