回到首页 返回首页
回到顶部 回到顶部
返回上一页 返回上一页

#创客来了#炎热夏季天气提醒器 简单

头像 创客维克多 2021.08.20 715 1

创意来源:   

        夏日炎炎,还没开始放暑假,广东的气温都已经高达36℃了。立秋后,秋天还是35℃高温,真的是“全球气候变暖”吗?最近新闻又听到地球上的冰川大面积融化,全球多处台风、洪水等自然灾害,给人民带来了巨大的损失和伤害甚至死亡… …

        每天,上班、上学的人都是匆匆地出门,哪里记得在出门前打开手机或者电视看一下今天的天气预报。走出了门,口渴了才想起忘记带水,下雨了想起忘记带雨伞等等,环绕在我们的身边。

        为此,我想到做一个天气提醒器,可以在人们出门之前就提醒查看掌控板屏幕上当天的天气情况,根据天气情况带上相应的用具,这样可以避免很多不必要的麻烦,给大家的生活、学习、工作带来很大的方便。

        


工作原理:

        当人们出门时,超声波传感器会感应到,反馈给掌控板,于是掌控板的P13口设为高电平,给录放模块的P-L播放引脚供电,触发喇叭播报“您好,请看天气提醒!”,这时人们会去看掌控板上的天气信息,根据不同的天气,带上对应的用具,以做到“不后悔”。

程序优化:

        本来的程序是设置到一直循环判断是否检测到有人通过的,后来考虑到百灵鸽扩展板的锂电池容量不大,不能像18650电池组那样长时间供电,于是在循环程序里加了一个“等待直到...”,这样一来可以不让全部程序循环,节省程序运行的耗电量。


步骤1 接线

project-image

步骤2 LaserMaker设计外壳

project-image

步骤3 按照接线图接线

project-image

步骤4 组装完成(有老师说很有科幻感哦,您觉得呢?)

project-image

不同角度拍摄

project-image
project-image
project-image

因为视频是在楼台拍摄的,外界杂音大,影响了效果。

代码
/*!
 * MindPlus
 * mpython
 *
 */
#include <MPython.h>
#include <DFRobot_Iot.h>
#include <DFRobot_URM10.h>
#include <mPython_Weather.h>
#include <MPython_NtpTime.h>
// 创建对象
DFRobot_Iot     myIot;
mPython_Weather myWeather;
MPython_NtpTime ntptime;
DFRobot_URM10   urm10;


// 主程序开始
void setup() {
	mPython.begin();
	myIot.wifiConnect("wifi名称", "wifi密码");
	while (!myIot.wifiStatus()) {yield();}
	myWeather.init("www.tianqiapi.com", "天气API账号", "天气API秘钥");
	display.setCursorLine(1);
	display.printLine(myIot.getWiFiLocalIP());
	display.fillScreen(0);
	ntptime.setNtpTime(ntptime.UTCEast8_t, "ntp.ntsc.ac.cn");
}
void loop() {
	while (!((urm10.getDistanceCM(P14, P15))<20)) {yield();}
	digitalWrite(P13, HIGH);
	display.setCursor(38, 0);
	display.print("广东 惠州");
	display.setCursor(2, 16);
	display.print((String((String(ntptime.localTime(ntptime.Year)) + String((String("年") + String((String(ntptime.localTime(ntptime.Month)) + String((String("月") + String((String(ntptime.localTime(ntptime.Date)) + String("日"))))))))))) + String((String(ntptime.localTime(ntptime.Hour)) + String((String(":") + String(ntptime.localTime(ntptime.Minute))))))));
	display.setCursor(2, 32);
	display.print((String("今日天气:") + String(myWeather.getWeather("weather", "101280301"))));
	display.setCursor(2, 48);
	display.print((String("气        温:") + String((String((String(myWeather.getWeather("temperaturLow", "101280301")) + String((String("~") + String(myWeather.getWeather("temperaturHigh", "101280301")))))) + String("℃")))));
	delay(5000);
	digitalWrite(P13, LOW);
	display.fillScreen(0);
}
project-image

材料清单

  • 掌控板 X1 链接
  • N+扩展板 X1 链接
  • 超声波传感器 X1
  • ISD1820录放模块 X1
  • 8Ω3W喇叭 X1
  • 8.5*13.5mm船型开关 X1
  • DC005电源插口 X1
  • 103pf电容 X1
  • 牛奶箱提手 X1

待改进的方面:

因为手头上没有语音合成模块,所以用了录放模块播放“你好,请看天气提醒!”。

评论

user-avatar
  • yinz

    yinz2022.05.04

    大师,可不可以发一张清楚的图片?

    0