esp8266oled做时钟python_【零知ESP8266】OLED天气时钟

/*

2019年6月13日13:47:26

by 零知实验室

*/

#include

#include

#include

// time

#include                        // time() ctime()

#include                    // struct timeval

#include                   // settimeofday_cb()

#include "SSD1306Wire.h"

#include "OLEDDisplayUi.h"

#include "Wire.h"

#include "OpenWeatherMapCurrent.h"

#include "OpenWeatherMapForecast.h"

#include "WeatherStationFonts.h"

#include "WeatherStationImages.h"

/***************************

* Begin Settings

**************************/

// WIFI

const char* WIFI_SSID = "xx";

const char* WIFI_PWD = "xx";

#define TZ              8       // (utc+) TZ in hours

#define DST_MN          60      // use 60mn for summer time in some countries

// Setup

const int UPDATE_INTERVAL_SECS = 20 * 60; // Update every 20 minutes

// Display Settings

const int I2C_DISPLAY_ADDRESS = 0x3c;

const int SDA_PIN = D3;

const int SDC_PIN = D4;

// OpenWeatherMap Settings

// Sign up here to get an API key:

// [url=https://docs.thingpulse.com/how-tos/openweathermap-key/]https://docs.thingpulse.com/how-tos/openweathermap-key/[/url]

String OPEN_WEATHER_MAP_APP_ID = "xxx"; //你的API KEY

/*

Go to [url=https://openweathermap.org/find?q=]https://openweathermap.org/find?q=[/url] and search for a location. Go through the

result set and select the entry closest to the actual location you want to display

data for. It'll be a URL like [url=https://openweathermap.org/city/2657896.]https://openweathermap.org/city/2657896.[/url] The number

at the end is what you assign to the constant below.

*/

String OPEN_WEATHER_MAP_LOCATION_ID = "1795565"; //city:深圳

// Pick a language code from this list:

// Arabic - ar, Bulgarian - bg, Catalan - ca, Czech - cz, German - de, Greek - el,

// English - en, Persian (Farsi) - fa, Finnish - fi, French - fr, Galician - gl,

// Croatian - hr, Hungarian - hu, Italian - it, Japanese - ja, Korean - kr,

// Latvian - la, Lithuanian - lt, Macedonian - mk, Dutch - nl, Polish - pl,

// Portuguese - pt, Romanian - ro, Russian - ru, Swedish - se, Slovak - sk,

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ESP8266是一种常用的物联网开发板,它与OLED显示屏结合起来可以制作出一个天气时钟。 首先,我们需要连接ESP8266和OLED显示屏。可以使用I2C接口连接它们,这样只需要两条线进行通信。然后,我们需要编写代码来控制ESP8266获取天气信息并在OLED屏幕上显示。 为了获取天气信息,我们可以使用开放的天气API,如OpenWeatherMap。首先,需要在该网站上注册并获取API密钥。然后,使用ESP8266的WiFi功能连接到互联网,并使用该API密钥获取天气数据。可以选择获取温度、湿度、气压等信息。这些数据将以JSON格式返回,需要使用代码解析并提取所需数据。 接下来,我们可以使用OLED显示屏的库函数来在屏幕上显示天气信息。可以创建几个不同的屏幕区域,来显示时间、日期、天气图标和温度等信息。我们可以使用现成的图标库来表示不同的天气状况,例如晴天、多云、雨天等等。 最后,在主循环中,我们可以添加一个定时器,每隔一段时间更新一次天气信息。这样,天气时钟就能实时显示最新的天气情况。 为了使制作的天气时钟更加美观,我们还可以为OLED显示屏添加外壳或悬挂装置。可以使用3D打印技术制作一个适合的外壳,将ESP8266和OLED屏幕放入其中,使其成为一个真正的时钟。 总结来说,ESP8266与OLED显示屏结合,可以制作一个功能强大的天气时钟。我们可以通过获取天气API获取最新的天气数据,并使用OLED显示屏将其实时显示在屏幕上。制作一个天气时钟不仅可以提供准确的日期和时间,还可以让我们随时了解天气情况,为我们的生活提供便利。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值