色哟哟视频在线观看-色哟哟视频在线-色哟哟欧美15最新在线-色哟哟免费在线观看-国产l精品国产亚洲区在线观看-国产l精品国产亚洲区久久

電子發(fā)燒友App

硬聲App

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評(píng)論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫(xiě)文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示
創(chuàng)作
電子發(fā)燒友網(wǎng)>電子資料下載>電子資料>智能恒溫器開(kāi)源分享

智能恒溫器開(kāi)源分享

2022-11-16 | zip | 0.32 MB | 次下載 | 2積分

資料介紹

描述

只需發(fā)短信即可連接到這個(gè)智能恒溫器,無(wú)需額外的儀表板或平臺(tái)。

了解電報(bào)機(jī)器人

Telegram 提供了一組超級(jí)有用的 API ?,您可以在項(xiàng)目中使用。

您可以在 Arduino 板上托管一個(gè)機(jī)器人,并使用一個(gè)名為?Telegram Bot的簡(jiǎn)單庫(kù)與它聊天您可以通過(guò) Arduino 桌面 IDE 中的庫(kù)管理器安裝此庫(kù),或者通過(guò)在Arduino Web 編輯器上導(dǎo)入 .Zip 文件來(lái)安裝此庫(kù)

您可以在此處了解有關(guān)如何在 MKR1000 上管理 Telegram Bot 的所有?信息在本教程?中,我們將跳過(guò)這一步,但您將看到如何在最終代碼中實(shí)現(xiàn) Telegram 機(jī)器人。

時(shí)間管理

這個(gè)恒溫器允許你編程一整周并循環(huán)它。

為此,恒溫器發(fā)出 UDP 調(diào)用并使用接收到的數(shù)據(jù)來(lái)設(shè)置實(shí)時(shí)時(shí)鐘 (RTC)。

安裝?RTCZero?和WiFi101庫(kù)?并上傳此草圖以測(cè)試此功能。


#include 
#include 
#include 
#include 

RTCZero rtc;
WiFiUDP Udp; // A UDP instance to let us send and receive packets over UDP

// Initialize Wifi connection to the router
char ssid[] = "xxxx";             // your network SSID (name)
char pass[] = "yyyy";           // your network key

WiFiSSLClient client;
unsigned long epoch;
unsigned int localPort = 2390;      // local port to listen for UDP packets
IPAddress timeServer(129, 6, 15, 28); // time.nist.gov NTP server
const int NTP_PACKET_SIZE = 48; // NTP time stamp is in the first 48 bytes of the message
byte packetBuffer[ NTP_PACKET_SIZE]; //buffer to hold incoming and outgoing packets

void setup() {

  Serial.begin(115200);

  // attempt to connect to Wifi network:
  Serial.print("Connecting Wifi: ");
  Serial.println(ssid);
  while (WiFi.begin(ssid, pass) != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println("");
  Serial.println("WiFi connected");

  rtc.begin();
  GetCurrentTime();
}

void loop() {
  Serial.print("Unix time = ");
  Serial.println(rtc.getEpoch());

  // Print date...
  Serial.print(rtc.getDay());
  Serial.print("/");
  Serial.print(rtc.getMonth());
  Serial.print("/");
  Serial.print(rtc.getYear());
  Serial.print("\t");

  // ...and time
  print2digits(rtc.getHours());
  Serial.print(":");
  print2digits(rtc.getMinutes());
  Serial.print(":");
  print2digits(rtc.getSeconds());
  Serial.println();

  delay(1000);
}

void print2digits(int number) {
  if (number < 10) {
    Serial.print("0");
  }
  Serial.print(number);
}

void GetCurrentTime() {

  int numberOfTries = 0, maxTries = 6;
  do {
    epoch = readLinuxEpochUsingNTP();
    numberOfTries++;
  }
  while ((epoch == 0) || (numberOfTries > maxTries));

  if (numberOfTries > maxTries) {
    Serial.print("NTP unreachable!!");
    while (1);
  }
  else {
    Serial.print("Epoch received: ");
    Serial.println(epoch);
    rtc.setEpoch(epoch);
    Serial.println();
  }

}

unsigned long readLinuxEpochUsingNTP()
{
  Udp.begin(localPort);
  sendNTPpacket(timeServer); // send an NTP packet to a time server
  // wait to see if a reply is available
  delay(1000);

  if ( Udp.parsePacket() ) {
    Serial.println("NTP time received");
    // We've received a packet, read the data from it
    Udp.read(packetBuffer, NTP_PACKET_SIZE); // read the packet into the buffer
    //the timestamp starts at byte 40 of the received packet and is four bytes,
    // or two words, long. First, esxtract the two words:

    unsigned long highWord = word(packetBuffer[40], packetBuffer[41]);
    unsigned long lowWord = word(packetBuffer[42], packetBuffer[43]);
    // combine the four bytes (two words) into a long integer
    // this is NTP time (seconds since Jan 1 1900):
    unsigned long secsSince1900 = highWord << 16 | lowWord;
    // now convert NTP time into everyday time:
    // Unix time starts on Jan 1 1970. In seconds, that's 2208988800:
    const unsigned long seventyYears = 2208988800UL;
    // subtract seventy years:
    Udp.stop();
    return (secsSince1900 - seventyYears);
  }
  else {
    Udp.stop();
    return 0;
  }
}
// send an NTP request to the time server at the given address
unsigned long sendNTPpacket(IPAddress & address)
{
  // set all bytes in the buffer to 0
  memset(packetBuffer, 0, NTP_PACKET_SIZE);
  // Initialize values needed to form NTP request
  // (see URL above for details on the packets)

  packetBuffer[0] = 0b11100011;   // LI, Version, Mode
  packetBuffer[1] = 0;     // Stratum, or type of clock
  packetBuffer[2] = 6;     // Polling Interval
  packetBuffer[3] = 0xEC;  // Peer Clock Precision
  // 8 bytes of zero for Root Delay & Root Dispersion
  packetBuffer[12]  = 49;
  packetBuffer[13]  = 0x4E;
  packetBuffer[14]  = 49;
  packetBuffer[15]  = 52;

  // all NTP fields have been given values, now
  // you can send a packet requesting a timestamp:
  Udp.beginPacket(address, 123); //NTP requests are to port 123
  Udp.write(packetBuffer, NTP_PACKET_SIZE);
  Udp.endPacket();
}

保存設(shè)置

當(dāng)然你不希望你的恒溫器在每次關(guān)閉時(shí)都忘記它的設(shè)置:)

為避免此問(wèn)題,您可以使用FlashStorage庫(kù)將數(shù)據(jù)存儲(chǔ)在電路板的閃存中。

在這種特殊情況下,我們使用此功能來(lái)存儲(chǔ) 7 天 7*24 小時(shí)的結(jié)構(gòu),以及所需溫度的值。

上傳此示例以測(cè)試此功能。


/*
  Store and retrieve an integer value in Flash memory.
  The value is increased each time the board is restarted.
  This example code is in the public domain.
  Written 30 Apr 2015 by Cristian Maglie 
*/

#include 

// Reserve a portion of flash memory to store an "int" variable
// and call it "my_flash_store".
FlashStorage(my_flash_store, int);

// Note: the area of flash memory reserved for the variable is
// lost every time the sketch is uploaded on the board.

void setup() {
  SERIAL_PORT_MONITOR.begin(9600);

  int number;

  // Read the content of "my_flash_store" and assign it to "number"
  number = my_flash_store.read();

  // Print the current number on the serial monitor
  SERIAL_PORT_MONITOR.println(number);

  // Save into "my_flash_store" the number increased by 1 for the
  // next run of the sketch
  my_flash_store.write(number + 1);
}

void loop() {
  // Do nothing...
}

傳感器讀取值

在這個(gè)項(xiàng)目中,我們使用可以檢測(cè)濕度和溫度的 DHT 傳感器。這個(gè)傳感器有自己的庫(kù),你可以?在這里下載

由于草圖實(shí)現(xiàn)了許多功能,我們將其組織在不同的選項(xiàng)卡中,以下這些代碼片段指的是傳感器。

在 Config 選項(xiàng)卡中,我們聲明傳感器的類:

//#define USE_fahrenheit true  // Uncomment this to use Fahrenheit insted of Celsius

class Sensor {
  public:
      Sensor(void);
      void begin();
      bool ReadSensors();
      float GetTemp();
      float GetHumidity();
  private:
      float t;
      float f;
      float h;
};
extern Sensor DHTSensor;

?

在另一個(gè)選項(xiàng)卡中,我們定義了傳感器類:

#include "DHT.h"
#include "config.h"

DHT dht(DHTPIN, DHTTYPE);

Sensor::Sensor(void) {
}

bool  Sensor::ReadSensors() {
  h = dht.readHumidity();
  t = dht.readTemperature(); // Read temperature as Celsius (the default)
  f = dht.readTemperature(true);  // Read temperature as Fahrenheit (isFahrenheit = true)
  if (isnan(h) || isnan(t) || isnan(f)) {             // Check if any reads failed and exit early (to try again).
    Serial.println("Failed to read from DHT sensor!");
    return false;
  }

  return true;
}

void Sensor::begin() {
  dht.begin();
}

float  Sensor::GetTemp() {
#ifdef USE_fahrenheit
  return f;
#else
  return t;
#endif
}

float Sensor::GetHumidity() {
  return h;
}

硬件組件和庫(kù)

現(xiàn)在您可以開(kāi)始連接恒溫器了。考慮到 LCD 顯示器需要GFX和?ST7735庫(kù),而 DHT 傳感器需要 ?DHT-sensor-library。?


下載該資料的人也在下載 下載該資料的人還在閱讀
更多 >

評(píng)論

查看更多

下載排行

本周

  1. 1山景DSP芯片AP8248A2數(shù)據(jù)手冊(cè)
  2. 1.06 MB  |  532次下載  |  免費(fèi)
  3. 2RK3399完整板原理圖(支持平板,盒子VR)
  4. 3.28 MB  |  339次下載  |  免費(fèi)
  5. 3TC358743XBG評(píng)估板參考手冊(cè)
  6. 1.36 MB  |  330次下載  |  免費(fèi)
  7. 4DFM軟件使用教程
  8. 0.84 MB  |  295次下載  |  免費(fèi)
  9. 5元宇宙深度解析—未來(lái)的未來(lái)-風(fēng)口還是泡沫
  10. 6.40 MB  |  227次下載  |  免費(fèi)
  11. 6迪文DGUS開(kāi)發(fā)指南
  12. 31.67 MB  |  194次下載  |  免費(fèi)
  13. 7元宇宙底層硬件系列報(bào)告
  14. 13.42 MB  |  182次下載  |  免費(fèi)
  15. 8FP5207XR-G1中文應(yīng)用手冊(cè)
  16. 1.09 MB  |  178次下載  |  免費(fèi)

本月

  1. 1OrCAD10.5下載OrCAD10.5中文版軟件
  2. 0.00 MB  |  234315次下載  |  免費(fèi)
  3. 2555集成電路應(yīng)用800例(新編版)
  4. 0.00 MB  |  33566次下載  |  免費(fèi)
  5. 3接口電路圖大全
  6. 未知  |  30323次下載  |  免費(fèi)
  7. 4開(kāi)關(guān)電源設(shè)計(jì)實(shí)例指南
  8. 未知  |  21549次下載  |  免費(fèi)
  9. 5電氣工程師手冊(cè)免費(fèi)下載(新編第二版pdf電子書(shū))
  10. 0.00 MB  |  15349次下載  |  免費(fèi)
  11. 6數(shù)字電路基礎(chǔ)pdf(下載)
  12. 未知  |  13750次下載  |  免費(fèi)
  13. 7電子制作實(shí)例集錦 下載
  14. 未知  |  8113次下載  |  免費(fèi)
  15. 8《LED驅(qū)動(dòng)電路設(shè)計(jì)》 溫德?tīng)栔?/a>
  16. 0.00 MB  |  6656次下載  |  免費(fèi)

總榜

  1. 1matlab軟件下載入口
  2. 未知  |  935054次下載  |  免費(fèi)
  3. 2protel99se軟件下載(可英文版轉(zhuǎn)中文版)
  4. 78.1 MB  |  537798次下載  |  免費(fèi)
  5. 3MATLAB 7.1 下載 (含軟件介紹)
  6. 未知  |  420027次下載  |  免費(fèi)
  7. 4OrCAD10.5下載OrCAD10.5中文版軟件
  8. 0.00 MB  |  234315次下載  |  免費(fèi)
  9. 5Altium DXP2002下載入口
  10. 未知  |  233046次下載  |  免費(fèi)
  11. 6電路仿真軟件multisim 10.0免費(fèi)下載
  12. 340992  |  191187次下載  |  免費(fèi)
  13. 7十天學(xué)會(huì)AVR單片機(jī)與C語(yǔ)言視頻教程 下載
  14. 158M  |  183279次下載  |  免費(fèi)
  15. 8proe5.0野火版下載(中文版免費(fèi)下載)
  16. 未知  |  138040次下載  |  免費(fèi)
主站蜘蛛池模板: 女攻男受高h全文肉肉 | 久久婷婷五月综合色丁香 | 久久4k岛国高清一区二区 | 美女被C污黄网站免费观看 美女白虎穴 | WWW久久只有这里有精品 | 亚洲精品www久久久久久久软件 | qovd电影| 男人的天堂黄色片 | jizzjizz丝袜 | chinese情侣自拍啪hd | 色欲AV精品人妻一区二区三区 | 亚洲欧美综合在线中文 | 丁香成人网址 | 一二三四中文字幕在线看 | 色综合 亚洲 自拍 欧洲 | 国产乱子影视频上线免费观看 | 琪琪电影午夜理论片77网 | 在线观看中文字幕码2021不用下载 | 伊人久久大香线蕉综合电影网 | gay吊粗大双龙 | 色小妹影院 | 国产精品xxxav免费视频 | 国产区在线不卡视频观看 | 日本最新在线不卡免费视频 | 扒开粉嫩的小缝末成年小美女 | 伊人在线高清视频 | 国精产品一区一区三区有限 | 胸大的姑娘中文字幕视频 | 狠狠狠的在啪线香蕉 | 人妻夜夜爽天天爽三区麻豆AV网站 | 99久久精品互换人妻AV | 老熟女重囗味HDXX | 97国产在线播放 | 亚洲日本欧美国产在线视 | 999久久久无码国产精蜜柚 | 欧洲最大无人区免费高清完整版 | 18国产精品白浆在线观看免费 | 国产精品爽爽久久久久久竹菊 | 麻豆传煤网站网址入口在线下载 | 双性诱受灌满哭求饶BL | DASD-700美谷朱里 |