如何用ESP8266做一个天气预报

1、硬件
用一个四博智联提供的nodemcu。一个OLED屏,一个USB线,4根杜邦线,可以上网的路由器,电脑。

     3V3---VCC
     GND---GND
     GPIO4(D2)---SDA
     GPIO5(D1)---SCL

2、设置路由器
把路由器账号设置为把路由器账号设置为
账号:xh003
密码:zxd+19901120=
3、烧录程序
打开ESP_TOOLS下载工具,选择8266.

点击START.等待烧录完成。

烧录完成后复位一下nodemcu。等待10s左右。
测试结果如下:

 


 

Arduino代码如下:
#include <ESP8266WiFi.h>
#include <ArduinoJson.h>
#include <Wire.h>
#include "OLED.h"
static const char logo[] PROGMEM={
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,
0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,
0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,
0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,
0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0x7f,
0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0x7f,
0xff,0xff,0xff,0xff,0xff,0xe0,0xff,0x03,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0x7f,
0xff,0xff,0xff,0xff,0x1f,0x1c,0xf0,0x1f,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0x7f,
0xff,0xff,0xff,0xff,0x0f,0x00,0x80,0x7f,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0x7f,
0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0xff,0x01,0x00,0xfc,0xff,0xff,0xff,0xff,0x7f,
0xff,0xff,0xff,0xff,0x07,0x00,0x00,0xfe,0x03,0x00,0xf8,0xff,0xff,0xff,0xff,0x7f,
0xff,0xff,0xff,0xff,0x03,0x00,0x00,0xfc,0x07,0x00,0xf8,0xff,0xff,0xff,0xff,0x7f,
0xff,0xff,0xff,0xff,0x01,0x00,0x00,0xf8,0x0f,0x00,0xf0,0xff,0xff,0xff,0xff,0x7f,
0xff,0xff,0xff,0xff,0x00,0x00,0x00,0xf0,0x1f,0x00,0xf0,0xff,0xff,0xff,0xff,0x7f,
0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0xf0,0x1f,0x00,0xf0,0xff,0xff,0xff,0xff,0x7f,
0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0xf0,0x1f,0x00,0xf0,0xff,0xff,0xff,0xff,0x7f,
0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0xf0,0x1f,0x00,0xf0,0xff,0xff,0xff,0xff,0x7f,
0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0xf0,0x3f,0x00,0xf0,0xff,0xff,0xff,0xff,0x7f,
0xff,0xff,0xff,0x07,0x00,0x00,0x00,0xf0,0x1f,0x00,0xf8,0xff,0xff,0xff,0xff,0x7f,
0xff,0xff,0xff,0x07,0x00,0x00,0x00,0xf0,0x0f,0x00,0xf8,0xff,0xff,0xff,0xff,0x7f,
0xff,0xff,0xff,0x03,0x00,0x00,0x00,0xf8,0x03,0x00,0xfc,0xff,0xff,0xff,0xff,0x7f,
0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xfc,0x00,0x00,0x7e,0xff,0xff,0xff,0xff,0x7f,
0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x7f,0x00,0x00,0x7f,0xf8,0xff,0xff,0xff,0x7f,
0xff,0xff,0xff,0x00,0x00,0x00,0x80,0x1f,0x00,0x80,0x7f,0xf8,0xff,0xff,0xff,0x7f,
0xff,0xff,0xff,0x00,0x00,0x00,0
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
该设计仿制国外ESP8266+OLED Weather Station成功,原文链接:https://blog.squix.org/2017/01/esp8266-weather-sta... 下面介绍本人的设计 安卓手机app下载地址:https://espressif.com/zh-hans/products/software/esp-touch/resources,ios直接在AppStore里搜索 esptouch即可。 最新进展,源码经过修改可以通过官方的手机app让Weather Station快连到WiFi,并自动记录最后一次快连成功的路由器,下次会自动连接。如果换了WiFi环境自动进入快连界面,这时在手机运行官方app(esptouch)输入WiFi密码即可连接。 附件zip已经打包好库文件,解压后放在没有中文路径的文件夹下面,再在arduino的“首选项”-- “项目文件夹位置” 指向这个文件夹。重启arduino,然后打开“文件”--”项目文件夹“--WeatherStationDemo,选择对应的板和COM口下载即可。 源码里面有一个wunderground 的key给大家试用,每天500次的API访问量,记得把城市改到对应的城市。从下午开始想着再申请几个key结果死活不行,或许对ip有限制吧? 源码改的乱七八糟,高手大侠见笑了。。。笑过之后请抽时间多指点能改进完善一下程序最好了! 注:修改好的源码及库文件见附件内容下载。 WIFI 气象站实物图展示: 使用NodeMCU1.0(ESP8266-12E),集成了CP2102,可以直接电脑USB ;OLED是SSD1306的128×64,IIC接口 初接触Arduino和ESP8266,现在仿制阶段。 所有资料来自网络,感兴趣的一起来完善它,高手大侠们多多指教! 作者博客:https://blog.squix.org/ 制作网页:https://www.instructables.com/id/ESP8266-Weather-Widget/ Arduino源码:https://github.com/squix78/esp8266-weather-station Arduino IDE可以像使用UNO一样使用ESP8266,编译环境的搭建:https://www.geek-workshop.com/thread-26170-1-1.html 目前改进设想 1、加入SmartConfig(WIFI快连),在手机或者PC上面通过APP配置路由器密码,不用再在源码里改动 2、把OLED换成LCD或者LED点阵屏,OLED太小了
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值