当前位置:网站首页>【ESP8266-01s】获取天气,城市,北京时间
【ESP8266-01s】获取天气,城市,北京时间
2022-06-23 16:49:57【来碗豆腐脑】
先讲下一个调试时发现的问题,使用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
边栏推荐
- 手机开户一般哪个证券公司好?在线开户安全么?
- 百度智能云5月产品升级观察站
- CRMEB 二开短信功能教程
- torch学习(一):环境配置
- README
- 论文阅读 (57):2-hydr_Ensemble: Lysine 2-Hydroxyisobutyrylation Identification with Ensemble Method (任务)
- 论文阅读 (58):Research and Implementation of Global Path Planning for Unmanned Surface Vehicle Based...
- 论文阅读 (56):Mutli-features Predction of Protein Translational Modification Sites (任务)
- Latex编译成功但是无法输出到PDF
- 论文阅读 (55):Dynamic Multi-Robot Task Allocation under Uncertainty and Temporal Constraints
猜你喜欢
全局组织结构控制之抢滩登陆
论文阅读 (54):DeepFool: A Simple and Accurate Method to Fool Deep Neural Networks
视频异常检测数据集 (ShanghaiTech)
论文阅读 (53):Universal Adversarial Perturbations
论文阅读 (52):Self-Training Multi-Sequence Learning with Transformer for Weakly Supervised Video Anomaly
对抗攻击与防御 (2):对抗样本的反制策略
论文阅读 (51):Integration of a Holonic Organizational Control Architecture and Multiobjective...
论文阅读 (50):A Novel Matrix Game with Payoffs of Maxitive Belief Structure
console. Log() is an asynchronous operation???
Kdevtmpfsi processing of mining virus -- Practice
随机推荐
- Also using copy and paste to create test data, try the data assistant!
- Async/await
- Programmers are very useful ten tool websites, which are worth collecting
- Troubleshooting and modification process of easycvr interface dislocation in small screen
- Reinforcement learning series (I) -- basic concepts
- Easygbs playback screen is continuously loading. Troubleshooting
- 13. IP address and subnet partitioning (VLSM)
- 12. Manage network environment
- Illustration of mongodb cluster deployment principle (3)
- 6、VLAN
- What if the website is poisoned
- 7、VLAN-Trunk
- Revil - blackmail Virus Emergency Response
- How to make a badge
- Alien world, real presentation, how does the alien version of Pokemon go achieve?
- How to use R language to draw scatter diagram
- How to make validity table
- Ner's past, present and future Overview - Future
- This time, thoroughly understand the SparseArray implementation principle
- Detailed explanation of ssl/tls principle and packet capturing
- Kotlin practical skills you should know
- New function! Qianfan magic pen apaas December capability monthly report
- Nodejs implements multi process
- Goframe framework: basic auth Middleware
- Crmeb second open SMS function tutorial
- Baidu AI Cloud product upgrade Observatory in May
- Which securities company is good for opening a mobile account? Is online account opening safe?
- Kerberoasting without SPN
- Mobile SSH connection tool
- How to make towel washing label
- Establishment and use of SSL VPN (OpenVPN)
- A set of code to launch seven golang web frameworks at the same time
- Vulnerability in McAfee epolicy orchestrator
- Deploy LNMP environment and install Typecho blog
- Cryptography involved in IOT device end
- [learning notes] tidb learning notes (III)
- Goframe framework: add tracing Middleware
- Call face recognition exception
- Self taught programming introduction, what language to learn first?
- How do I write a small program that can automatically edit new year greetings