惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
Know Your Adversary
Know Your Adversary
P
Palo Alto Networks Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
K
Kaspersky official blog
L
LINUX DO - 热门话题
P
Proofpoint News Feed
P
Privacy & Cybersecurity Law Blog
Google DeepMind News
Google DeepMind News
Attack and Defense Labs
Attack and Defense Labs
Cisco Talos Blog
Cisco Talos Blog
AI
AI
L
LINUX DO - 最新话题
H
Heimdal Security Blog
Hacker News: Ask HN
Hacker News: Ask HN
Webroot Blog
Webroot Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The GitHub Blog
The GitHub Blog
I
Intezer
Blog — PlanetScale
Blog — PlanetScale
有赞技术团队
有赞技术团队
S
Securelist
博客园_首页
IT之家
IT之家
Schneier on Security
Schneier on Security
博客园 - 叶小钗
罗磊的独立博客
WordPress大学
WordPress大学
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
MongoDB | Blog
MongoDB | Blog
P
Proofpoint News Feed
阮一峰的网络日志
阮一峰的网络日志
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
W
WeLiveSecurity
The Register - Security
The Register - Security
D
DataBreaches.Net
S
Security @ Cisco Blogs
Security Archives - TechRepublic
Security Archives - TechRepublic
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
腾讯CDC
Recorded Future
Recorded Future
NISL@THU
NISL@THU
N
News and Events Feed by Topic
T
Tailwind CSS Blog
N
News and Events Feed by Topic
Cyberwarzone
Cyberwarzone
T
Tor Project blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com

莫拉维克猫屋

4D Radar - A Novel Sensing Paradigm for 3D Object Detection 粗略的cs231n学习笔记 simulink仿真数字通信系统 基于开源的livego搭建直播服务器 EDA实验二 功能可调综合计时器 EDA实验一 指令运算单元设计——第一次用FPGA开发板 SSM框架:导出数据库内容到Excel表格 Java网络编程-TCP通信 我要这差分放大电路有何用? Hello World
NodeMCU-ESP8266联网获取实时天气并使用lcd1602显示
liuzengyun · 2020-09-13 · via 莫拉维克猫屋

实现效果

image

硬件准备

  • NodeMCU-ESP8266开发板
  • lcd1602显示屏(使用I2C总线)
  • 杜邦线若干
  • 可以联网的WiFi信号

软件环境

  • Arduino IDE
  • 心知天气API(免费版够用)

连线:NodeMCU——I2C

  • GPIO4——SDA
  • GPIO5——SCL
  • VIN——VCC
  • GND——GND

这里这个连线还是很坑的。

供电之所以使用VIN而不使用3.3V,是因为VIN的供电是5V的,3.3V供电也不是不行,但是显示效果不太行,几乎看不清。

另外,之前网上看别人做lcd1602显示,都是连D3、D4两个脚,然后一直不管用,直到忍无可忍查了NodeMCU-ESP8266的管脚功能表,如下:(来源: https://tttapa.github.io/

GPIO Function State Restrictions
0 Boot mode select 3.3V No Hi-Z
1 TX0 - Not usable during Serial transmission
2 Boot mode select TX1 3.3V (boot only) Don’t connect to ground at boot time Sends debug data at boot time
3 RX0 - Not usable during Serial transmission
4 SDA (I²C) - -
5 SCL (I²C) - -
6 - 11 Flash connection x Not usable, and not broken out
12 MISO (SPI) - -
13 MOSI (SPI) - -
14 SCK (SPI) - -
15 SS (SPI) 0V Pull-up resistor not usable
16 Wake up from sleep - No pull-up resistor, but pull-down instead Should be connected to RST to wake up

开发过程

开发之前先去心知天气注册一个账户 ,申请一个免费的API,用来获取实时天气。

引入最基本的ESP8266WiFi库,先连接一个能上网的WiFi,使用ESP8266通过http请求获取信息,几秒钟请求一次,更新信息。返回的是一个JSON字符串,使用ArduinoJson库函数解析JSON,得到需要的具体数据。最后通过LiquidCrystal_I2C库将天气情况显示在LCD1602上。

代码与库

本项目: https://github.com/liuzengyun/esp8266_Weather

ArduinoJSON库: https://github.com/bblanchon/ArduinoJson

LiquidCrystal_I2C库:Arduino IDE中库管理中下载即可。