当前位置:网站首页>【ESP8266-01s】获取天气,城市,北京时间
【ESP8266-01s】获取天气,城市,北京时间
2022-06-23 16:49:00 【来碗豆腐脑】
先讲下一个调试时发现的问题,使用TCP透传模拟HTTP GET请求时的一个注意:
- 那就是通过串口助手直接发送给ESP8266时手打的
\r\n是无效的!!!!
这说明什么,使用CIPSEND命令或者透传模式发送数据时不支持转义字符。。。。。。。。。。。。。
想想也没毛病,编译器是支持的,如果模块支持,敲代码时就要转义两遍了。。。。。。。。。。。。。
调试时也会有个问题,就是串口助手不能用一行文本通过转义字符来模拟多行了,唉,多条发送不用就不用吧,还是去单条发送里面敲回车吧。。。。。。。。。。
- 连接wifi
AT+CWMODE=1
AT+CWJAP="wifi名","wifi密码"
获取北京时间
- 注意勾选发送新行。。
AT+CIPSTART="TCP","quan.suning.com",80
AT+CIPSEND=42
GET http://quan.suning.com/getSysTime.do
回复如下:
- 注意有时候会回复一大堆乱七八糟的东西,不清楚原因,也没找到其他合适的接口,有知道的小伙伴可以留言。
获取天气
- 先去www.tianqiapi.com注册个账号,然后会得到
appid和appsecret
AT+CIPSTART="TCP","tianqiapi.com",80
AT+CIPSEND=77
GET https://tianqiapi.com/api?version=v61&appid=******&appsecret=******
回复如下:
解码后是这样的,里面信息还挺多:
{
"cityid": "101180101",
"date": "2022-06-18",
"week": "星期六",
"update_time": "21:23",
"city": "郑州",
"cityEn": "zhengzhou",
"country": "中国",
"countryEn": "China",
"wea": "多云",
"wea_img": "yun",
"tem": "33",
"tem1": "37",
"tem2": "26",
"win": "东南风",
"win_speed": "2级",
"win_meter": "5km/h",
"humidity": "34%",
"visibility": "30km",
"pressure": "988",
"air": "106",
"air_pm25": "26",
"air_level": "轻度污染",
"air_tips": "儿童、老年人及心脏病、呼吸系统疾病患者应尽量减少体力消耗大的户外活动。",
"alarm": {
"alarm_type": "高温",
"alarm_level": "橙色",
"alarm_title": "河南省发布高温橙色预警",
"alarm_content": "河南省气象台2022年6月18日17时00分继续发布高温橙色预警:预计6月19日白天,郑州、开封、洛阳(主城区,偃师区,孟津区,新安县,汝阳县,宜阳县,伊川县,伊滨区)、平顶山、安阳、鹤壁、新乡、焦作、许昌、漯河、商丘、周口、驻马店(西平县,上蔡县,平舆县,遂平县)、济源、濮阳最高气温将升至37℃以上,其中郑州(上街区,荥阳市)、开封(杞县,通许县)、安阳、鹤壁、新乡(红旗区,卫滨区,凤泉区,牧野区,新乡县,获嘉县,卫辉市,辉县市)、焦作(主城区,修武县,博爱县,武陟县,城乡一体化示范区)、濮阳、商丘(主城区,民权县,睢县,宁陵县)最高气温升至40℃以上。\n6月20日白天,郑州、洛阳、平顶山、许昌、三门峡、南阳、信阳(平桥区,罗山县,固始县,淮滨县,息县)、周口、驻马店、济源、开封、安阳、鹤壁、新乡、焦作、濮阳、漯河、商丘最高气温将升至37℃以上,其中郑州(主城区,上街区,中牟县,航空港区,巩义市,荥阳市,新郑市)、开封、洛阳(老城区,西工区,瀍河区,涧西区,偃师区,孟津区,洛龙区,伊滨区)、平顶山(卫东区,叶县,高新区)、安阳、鹤壁、新乡、焦作、濮阳、许昌、漯河、商丘、周口(川汇区,"
},
"aqi": {
"update_time": "21:22",
"cityid": "101180101",
"city": "郑州",
"cityEn": "zhengzhou",
"country": "中国",
"countryEn": "China",
"air": "106",
"air_level": "轻度污染",
"air_tips": "儿童、老年人及心脏病、呼吸系统疾病患者应尽量减少体力消耗大的户外活动。",
"pm25": "26",
"pm25_desc": "优",
"pm10": "41",
"pm10_desc": "优",
"o3": "212",
"o3_desc": "轻度污染",
"no2": "6",
"no2_desc": "优",
"so2": "6",
"so2_desc": "优",
"co": "-",
"co_desc": "-",
"kouzhao": "建议佩戴口罩",
"yundong": "不建议运动",
"waichu": "较不宜外出",
"kaichuang": "减少开窗时间",
"jinghuaqi": "关闭净化器"
}
}
工具
- 一个测试WEB请求的网站Getman.cn
边栏推荐
- [mae]masked autoencoders mask self encoder
- 论文阅读 (54):DeepFool: A Simple and Accurate Method to Fool Deep Neural Networks
- The mail function is normal locally, and the ECS reports an error
- First use of kubernetes cronjob
- Which securities company is good for opening a mobile account? Is online account opening safe?
- Réponse 02: pourquoi le cercle Smith peut - il "se sentir haut et bas et se tenir à droite et à droite"?
- [Hyperf]Entry “xxxInterface“ cannot be resolved: the class is not instantiable
- Easygbs playback screen is continuously loading. Troubleshooting
- 如何通过线上股票开户?在线开户安全么?
- Importance of ERP management system
猜你喜欢

美团三面:聊聊你理解的Redis主从复制原理?
![[qsetting and.Ini configuration files] and [create resources.qrc] in QT](/img/67/85a5e7f6ad4220600acd377248ef46.png)
[qsetting and.Ini configuration files] and [create resources.qrc] in QT

Hands on data analysis unit 2 section 4 data visualization

C # connection to database

qYKVEtqdDg
![[30. concatenate substrings of all words]](/img/e7/453c8524a23fbb7501e85140547ce1.png)
[30. concatenate substrings of all words]

Alien world, real presentation, how does the alien version of Pokemon go achieve?

MySQL transaction and its characteristics and locking mechanism

论文阅读 (54):DeepFool: A Simple and Accurate Method to Fool Deep Neural Networks

Meituan Sanmian: how do you understand the principle of redis master-slave replication?
随机推荐
[qsetting and.Ini configuration files] and [create resources.qrc] in QT
Async/await
手机开户流程是什么?现在网上开户安全么?
C. Set or Decrease-Educational Codeforces Round 120 (Rated for Div. 2)
Company offensive operation guide
First use of kubernetes cronjob
Discussion on five kinds of zero crossing detection circuit
This time, thoroughly understand the SparseArray implementation principle
How to quickly obtain and analyze the housing price in your city?
Ner's past, present and future Overview - Future
How to open an account through online stock? Is online account opening safe?
Lighthouse open source application practice: o2oa
Analysis of three battery capacity monitoring schemes
How code 39 check bits are calculated
What if the website is poisoned
torch学习(一):环境配置
Transaction processing of cloud development database
一文读懂麦克风典型应用电路
论文阅读 (49):Big Data Security and Privacy Protection (科普文)
论文阅读 (58):Research and Implementation of Global Path Planning for Unmanned Surface Vehicle Based...