电源设计技术信息网站

订阅电子杂志   English   繁體中文   日本語   한국어

下载中心

TECH INFOArduino入门指南

如何制造智能家居电子产品:智能邮箱

这篇文章来源于DevicePlus.com英语网站的翻译稿。

smart home electronics

该项目把物联网和智能家居电子设备的理念相结合,然后应用到一个实用项目中。该项目旨在通过在您接收到新邮件时给您的手机发送通知,来节省您查看邮箱的时间。通过该项目的功能之一“连接覆盖”,您可以在家中查看来自世界任何地方的邮件。

功能描述

 

检测您的邮箱中是否有新邮件。

通过移动应用程序通知用户检测结果。

 

硬件组件:

 

ESP8266

smart home electronics

图1: ESP8266 / ©ACROBOTIC

  • • 带有内置WiFi模块且具有80MHz时钟频率的32位微控制器
  • • 1美元左右的超低成本
  • • 可以在Lua (NodeMCU)、JavaScript (Espruino)和Python (Micro Python)编译器上运行
  • • Arduino 集成开发环境

 

ESP-12E 开发板 (aka NodeMCU DevKit)

smart home electronics

图2: NodeMCU / ©ACROBOTIC

ESP-12E模块划分了开发板上所有可用的ESP8266引脚,以便实现与客户的轻松交互。

  • • 通过微型USB数据线进行轻松编程。
  • • 可见的LED灯,用于指示SoC的Tx引脚的状态。
  • • ESP-12E,一种4MB SPI闪存芯片。
  • • 合理范围内(50英尺处为–70~–80 dBm)的板载天线。
smart home electronics

图3: ESP-12E 开发板 / ©ACROBOTIC

HC-SR04 超声波传感器

smart home electronics

图4:超声波传感器

HC-SR04超声波传感器通过使用声纳超声波来检测与物体之间的距离。它提供了一种出色的非接触范围内物体的检测方式,具有高精准度和读取的稳定性。它的运行不受阳光或黑色物质的影响。配有超声波发射器和接收器模块。

您可以点击此处获取HC-SR04超声波传感器的用户使用手册。

软件组件:

 

Arduino IDE
Blynk 应用程序
Milestones

在Arduino IDE上安装ESP-12E 开发板驱动

 

在Arduino IDE中,打开首选项(Preferences)窗口,复制下面的URL到新增开发板管理器URLs(Additional Boards Manager URLs)中,点击确认(OK)。

http://arduino.esp8266.com/stable/package_esp8266com_index.json

{
  "packages": [
    {
      "maintainer": "ESP8266 Community", 
      "help": {
        "online": "http://esp8266.com/arduino"
      }, 
      "websiteURL": "https://github.com/esp8266/Arduino", 
      "platforms": [
        {
          "category": "ESP8266", 
          "name": "esp8266", 
          "url": "https://github.com/esp8266/Arduino/releases/download/2.3.0/esp8266-2.3.0.zip", 
          "checksum": "SHA-256:884188a54bc75f1f2e7f827619f8cb1980dc3f430f92f9b07186ed7f4db8c738", 
          "help": {
            "online": "http://esp8266.github.com/Arduino/versions/2.3.0/"
          }, 
          "version": "2.3.0", 
          "architecture": "esp8266", 
          "archiveFileName": "esp8266-2.3.0.zip", 
          "boards": [
            {
              "name": "Generic ESP8266 Module"
            }, 
            {
              "name": "Olimex MOD-WIFI-ESP8266(-DEV)"
            }, 
            {
              "name": "NodeMCU 0.9 (ESP-12 Module)"
            }, 
            {
              "name": "NodeMCU 1.0 (ESP-12E Module)"
            }, 
            {
              "name": "Adafruit HUZZAH ESP8266 (ESP-12)"
            }, 
            {
              "name": "ESPresso Lite 1.0"
            }, 
            {
              "name": "ESPresso Lite 2.0"
            }, 
            {
              "name": "Phoenix 1.0"
            }, 
            {
              "name": "Phoenix 2.0"
            }, 
            {
              "name": "SparkFun Thing"
            }, 
            {
              "name": "SweetPea ESP-210"
            }, 
            {
              "name": "WeMos D1"
            }, 
            {
              "name": "WeMos D1 mini"
            }, 
            {
              "name": "ESPino (ESP-12 Module)"
            }, 
            {
              "name": "ESPino (WROOM-02 Module)"
            }, 
            {
              "name": "WifInfo"
            }, 
            {
              "name": "ESPDuino"
            }
          ], 
          "toolsDependencies": [
            {
              "packager": "esp8266", 
              "version": "0.4.9", 
              "name": "esptool"
            }, 
            {
              "packager": "esp8266", 
              "version": "1.20.0-26-gb404fb9-2", 
              "name": "xtensa-lx106-elf-gcc"
            }, 
            {
              "packager": "esp8266", 
              "version": "0.1.2", 
              "name": "mkspiffs"
            }
          ], 
          "size": "8595050"
        }, 
        {
          "category": "ESP8266", 
          "help": {
            "online": "http://esp8266.github.com/Arduino/versions/2.1.0/"
          }, 
          "url": "https://github.com/esp8266/Arduino/releases/download/2.1.0/esp8266-2.1.0.zip", 
          "checksum": "SHA-256:000818d500ea90bcb516d667c688387f34003247bb5592e795bc549e91f9ace0", 
          "name": "esp8266", 
          "version": "2.1.0", 
          "architecture": "esp8266", 
          "archiveFileName": "esp8266-2.1.0.zip", 
          "size": "5776332", 
          "toolsDependencies": [
            {
              "packager": "esp8266", 
              "version": "0.4.8", 
              "name": "esptool"
            }, 
            {
              "packager": "esp8266", 
              "version": "1.20.0-26-gb404fb9-2", 
              "name": "xtensa-lx106-elf-gcc"
            }, 
            {
              "packager": "esp8266", 
              "version": "0.1.2", 
              "name": "mkspiffs"
            }
          ], 
          "boards": [
            {
              "name": "Generic ESP8266 Module"
            }, 
            {
              "name": "Olimex MOD-WIFI-ESP8266(-DEV)"
            }, 
            {
              "name": "NodeMCU 0.9 (ESP-12 Module)"
            }, 
            {
              "name": "NodeMCU 1.0 (ESP-12E Module)"
            }, 
            {
              "name": "Adafruit HUZZAH ESP8266 (ESP-12)"
            }, 
            {
              "name": "ESPresso Lite 1.0"
            }, 
            {
              "name": "ESPresso Lite 2.0"
            }, 
            {
              "name": "SparkFun Thing"
            }, 
            {
              "name": "SweetPea ESP-210"
            }, 
            {
              "name": "WeMos D1"
            }, 
            {
              "name": "WeMos D1 mini"
            }, 
            {
              "name": "ESPino (ESP-12 Module)"
            }, 
            {
              "name": "ESPino (WROOM-02 Module)"
            }, 
            {
              "name": "WifInfo"
            }, 
            {
              "name": "ESPDuino"
            }
          ]
        }, 
        {
          "category": "ESP8266", 
          "help": {
            "online": "http://esp8266.github.io/Arduino/versions/2.0.0/"
          }, 
          "url": "https://github.com/esp8266/Arduino/releases/download/2.0.0/esp8266-2.0.0.zip", 
          "checksum": "SHA-256:00911ee9f5d4802b279fd81a5a8177fd6fef4888d04ebe93fc3952bac85d909c", 
          "version": "2.0.0", 
          "architecture": "esp8266", 
          "archiveFileName": "esp8266-2.0.0.zip", 
          "boards": [
            {
              "name": "Generic ESP8266 Module"
            }, 
            {
              "name": "Olimex MOD-WIFI-ESP8266(-DEV)"
            }, 
            {
              "name": "NodeMCU 0.9 (ESP-12 Module)"
            }, 
            {
              "name": "NodeMCU 1.0 (ESP-12E Module)"
            }, 
            {
              "name": "Adafruit HUZZAH ESP8266 (ESP-12)"
            }, 
            {
              "name": "SparkFun Thing"
            }, 
            {
              "name": "SweetPea ESP-210"
            }, 
            {
              "name": "WeMos D1"
            }, 
            {
              "name": "WeMos D1 mini"
            }
          ], 
          "size": "5606497", 
          "toolsDependencies": [
            {
              "packager": "esp8266", 
              "version": "0.4.6", 
              "name": "esptool"
            }, 
            {
              "packager": "esp8266", 
              "version": "1.20.0-26-gb404fb9-2", 
              "name": "xtensa-lx106-elf-gcc"
            }, 
            {
              "packager": "esp8266", 
              "version": "0.1.2", 
              "name": "mkspiffs"
            }
          ], 
          "name": "esp8266"
        }, 
        {
          "category": "ESP8266", 
          "help": {
            "online": "http://esp8266.github.com/Arduino/versions/2.2.0/"
          }, 
          "url": "https://github.com/esp8266/Arduino/releases/download/2.2.0/esp8266-2.2.0.zip", 
          "checksum": "SHA-256:c0b57abdcd9ad11c506f79e019a35abadb9ac7921972caaa336e08a35048c1db", 
          "version": "2.2.0", 
          "architecture": "esp8266", 
          "archiveFileName": "esp8266-2.2.0.zip", 
          "boards": [
            {
              "name": "Generic ESP8266 Module"
            }, 
            {
              "name": "Olimex MOD-WIFI-ESP8266(-DEV)"
            }, 
            {
              "name": "NodeMCU 0.9 (ESP-12 Module)"
            }, 
            {
              "name": "NodeMCU 1.0 (ESP-12E Module)"
            }, 
            {
              "name": "Adafruit HUZZAH ESP8266 (ESP-12)"
            }, 
            {
              "name": "ESPresso Lite 1.0"
            }, 
            {
              "name": "ESPresso Lite 2.0"
            }, 
            {
              "name": "SparkFun Thing"
            }, 
            {
              "name": "SweetPea ESP-210"
            }, 
            {
              "name": "WeMos D1"
            }, 
            {
              "name": "WeMos D1 mini"
            }, 
            {
              "name": "ESPino (ESP-12 Module)"
            }, 
            {
              "name": "ESPino (WROOM-02 Module)"
            }, 
            {
              "name": "WifInfo"
            }, 
            {
              "name": "ESPDuino"
            }
          ], 
          "size": "5981702", 
          "toolsDependencies": [
            {
              "packager": "esp8266", 
              "version": "0.4.8", 
              "name": "esptool"
            }, 
            {
              "packager": "esp8266", 
              "version": "1.20.0-26-gb404fb9-2", 
              "name": "xtensa-lx106-elf-gcc"
            }, 
            {
              "packager": "esp8266", 
              "version": "0.1.2", 
              "name": "mkspiffs"
            }
          ], 
          "name": "esp8266"
        }, 
        {
          "category": "ESP8266", 
          "help": {
            "online": "http://arduino.esp8266.com/versions/1.6.5-947-g39819f0/doc/reference.html"
          }, 
          "url": "http://arduino.esp8266.com/versions/1.6.5-947-g39819f0/esp8266-1.6.5-947-g39819f0.zip", 
          "checksum": "SHA-256:79a395801a94c77f4855f3921b9cc127d679d961ec207e7fb89f90754123d66a", 
          "version": "1.6.5-947-g39819f0", 
          "architecture": "esp8266", 
          "archiveFileName": "esp8266-1.6.5-947-g39819f0.zip", 
          "boards": [
            {
              "name": "Generic ESP8266 Module"
            }, 
            {
              "name": "Olimex MOD-WIFI-ESP8266(-DEV)"
            }, 
            {
              "name": "NodeMCU 0.9 (ESP-12 Module)"
            }, 
            {
              "name": "NodeMCU 1.0 (ESP-12E Module)"
            }, 
            {
              "name": "Adafruit HUZZAH ESP8266 (ESP-12)"
            }, 
            {
              "name": "SweetPea ESP-210"
            }
          ], 
          "size": "2295584", 
          "toolsDependencies": [
            {
              "packager": "esp8266", 
              "version": "0.4.5", 
              "name": "esptool"
            }, 
            {
              "packager": "esp8266", 
              "version": "1.20.0-26-gb404fb9", 
              "name": "xtensa-lx106-elf-gcc"
            }
          ], 
          "name": "esp8266"
        }
      ], 
      "tools": [
        {
          "version": "1.20.0-26-gb404fb9-2", 
          "name": "xtensa-lx106-elf-gcc", 
          "systems": [
            {
              "url": "http://arduino.esp8266.com/win32-xtensa-lx106-elf-gb404fb9-2.tar.gz", 
              "checksum": "SHA-256:10476b9c11a7a90f40883413ddfb409f505b20692e316c4e597c4c175b4be09c", 
              "host": "i686-mingw32", 
              "archiveFileName": "win32-xtensa-lx106-elf-gb404fb9-2.tar.gz", 
              "size": "153527527"
            }, 
            {
              "url": "http://arduino.esp8266.com/osx-xtensa-lx106-elf-gb404fb9-2.tar.gz", 
              "checksum": "SHA-256:0cf150193997bd1355e0f49d3d49711730035257bc1aee1eaaad619e56b9e4e6", 
              "host": "x86_64-apple-darwin", 
              "archiveFileName": "osx-xtensa-lx106-elf-gb404fb9-2.tar.gz", 
              "size": "35385382"
            }, 
            {
              "url": "http://arduino.esp8266.com/osx-xtensa-lx106-elf-gb404fb9-2.tar.gz", 
              "checksum": "SHA-256:0cf150193997bd1355e0f49d3d49711730035257bc1aee1eaaad619e56b9e4e6", 
              "host": "i386-apple-darwin", 
              "archiveFileName": "osx-xtensa-lx106-elf-gb404fb9-2.tar.gz", 
              "size": "35385382"
            }, 
            {
              "url": "http://arduino.esp8266.com/linux64-xtensa-lx106-elf-gb404fb9.tar.gz", 
              "checksum": "SHA-256:46f057fbd8b320889a26167daf325038912096d09940b2a95489db92431473b7", 
              "host": "x86_64-pc-linux-gnu", 
              "archiveFileName": "linux64-xtensa-lx106-elf-gb404fb9.tar.gz", 
              "size": "30262903"
            }, 
            {
              "url": "http://arduino.esp8266.com/linux32-xtensa-lx106-elf.tar.gz", 
              "checksum": "SHA-256:b24817819f0078fb05895a640e806e0aca9aa96b47b80d2390ac8e2d9ddc955a", 
              "host": "i686-pc-linux-gnu", 
              "archiveFileName": "linux32-xtensa-lx106-elf.tar.gz", 
              "size": "32734156"
            }, 
            {
              "url": "http://arduino.esp8266.com/linuxarm-xtensa-lx106-elf-g46f160f-2.tar.gz", 
              "checksum": "SHA-256:f693946288f2ffa17288ef75ae16fa08573993f2b0a2a5e6bc35a68dc6087443", 
              "host": "arm-linux-gnueabihf", 
              "archiveFileName": "linuxarm-xtensa-lx106-elf-g46f160f-2.tar.gz", 
              "size": "34938475"
            }
          ]
        }, 
        {
          "version": "1.20.0-26-gb404fb9", 
          "name": "xtensa-lx106-elf-gcc", 
          "systems": [
            {
              "url": "http://arduino.esp8266.com/win32-xtensa-lx106-elf-gb404fb9.tar.gz", 
              "checksum": "SHA-256:1561ec85cc58cab35cc48bfdb0d0087809f89c043112a2c36b54251a13bf781f", 
              "host": "i686-mingw32", 
              "archiveFileName": "win32-xtensa-lx106-elf-gb404fb9.tar.gz", 
              "size": "153807368"
            }, 
            {
              "url": "http://arduino.esp8266.com/osx-xtensa-lx106-elf-gb404fb9-2.tar.gz", 
              "checksum": "SHA-256:0cf150193997bd1355e0f49d3d49711730035257bc1aee1eaaad619e56b9e4e6", 
              "host": "x86_64-apple-darwin", 
              "archiveFileName": "osx-xtensa-lx106-elf-gb404fb9-2.tar.gz", 
              "size": "35385382"
            }, 
            {
              "url": "http://arduino.esp8266.com/osx-xtensa-lx106-elf-gb404fb9-2.tar.gz", 
              "checksum": "SHA-256:0cf150193997bd1355e0f49d3d49711730035257bc1aee1eaaad619e56b9e4e6", 
              "host": "i386-apple-darwin", 
              "archiveFileName": "osx-xtensa-lx106-elf-gb404fb9-2.tar.gz", 
              "size": "35385382"
            }, 
            {
              "url": "http://arduino.esp8266.com/linux64-xtensa-lx106-elf-gb404fb9.tar.gz", 
              "checksum": "SHA-256:46f057fbd8b320889a26167daf325038912096d09940b2a95489db92431473b7", 
              "host": "x86_64-pc-linux-gnu", 
              "archiveFileName": "linux64-xtensa-lx106-elf-gb404fb9.tar.gz", 
              "size": "30262903"
            }, 
            {
              "url": "http://arduino.esp8266.com/linux32-xtensa-lx106-elf.tar.gz", 
              "checksum": "SHA-256:b24817819f0078fb05895a640e806e0aca9aa96b47b80d2390ac8e2d9ddc955a", 
              "host": "i686-pc-linux-gnu", 
              "archiveFileName": "linux32-xtensa-lx106-elf.tar.gz", 
              "size": "32734156"
            }
          ]
        }, 
        {
          "version": "0.4.9", 
          "name": "esptool", 
          "systems": [
            {
              "url": "https://github.com/igrr/esptool-ck/releases/download/0.4.9/esptool-0.4.9-win32.zip", 
              "checksum": "SHA-256:9c4162cedf05fcb09fd829bfb90e34ae12458365980d79525a072ff5ca44751c", 
              "host": "i686-mingw32", 
              "archiveFileName": "esptool-0.4.9-win32.zip", 
              "size": "32436"
            }, 
            {
              "url": "https://github.com/igrr/esptool-ck/releases/download/0.4.9/esptool-0.4.9-osx.tar.gz", 
              "checksum": "SHA-256:57938b473765723a7e6602d55973017b7719bda69bdcff4250b24fcbf7a399f5", 
              "host": "x86_64-apple-darwin", 
              "archiveFileName": "esptool-0.4.9-osx.tar.gz", 
              "size": "29310"
            }, 
            {
              "url": "https://github.com/igrr/esptool-ck/releases/download/0.4.9/esptool-0.4.9-osx.tar.gz", 
              "checksum": "SHA-256:57938b473765723a7e6602d55973017b7719bda69bdcff4250b24fcbf7a399f5", 
              "host": "i386-apple-darwin", 
              "archiveFileName": "esptool-0.4.9-osx.tar.gz", 
              "size": "29310"
            }, 
            {
              "url": "https://github.com/igrr/esptool-ck/releases/download/0.4.9/esptool-0.4.9-linux64.tar.gz", 
              "checksum": "SHA-256:fab9d1be8a648bea6728ad5c9d18ce972508187700cf90baf1897ac9cdf4db15", 
              "host": "x86_64-pc-linux-gnu", 
              "archiveFileName": "esptool-0.4.9-linux64.tar.gz", 
              "size": "15564"
            }, 
            {
              "url": "https://github.com/igrr/esptool-ck/releases/download/0.4.9/esptool-0.4.9-linux32.tar.gz", 
              "checksum": "SHA-256:bc4444d73d59be74608be5e1431353a0a9ae9e308e99c76a271d68a6ae145b7b", 
              "host": "i686-pc-linux-gnu", 
              "archiveFileName": "esptool-0.4.9-linux32.tar.gz", 
              "size": "15984"
            }, 
            {
              "url": "https://github.com/igrr/esptool-ck/releases/download/0.4.9/esptool-0.4.9-linux-armhf.tar.gz", 
              "checksum": "SHA-256:d0364492599d90b8305125f8212de5be05397e4efde2fc7d0ed3676bb7018164", 
              "host": "arm-linux-gnueabihf", 
              "archiveFileName": "esptool-0.4.9-linux-armhf.tar.gz", 
              "size": "13763"
            }
          ]
        }, 
        {
          "version": "0.4.8", 
          "name": "esptool", 
          "systems": [
            {
              "url": "https://github.com/igrr/esptool-ck/releases/download/0.4.8/esptool-0.4.8-win32.zip", 
              "checksum": "SHA-256:8d09cb0df6234c2a0562389ceedd11482b44a3f538695f9a4df80f9f10411ece", 
              "host": "i686-mingw32", 
              "archiveFileName": "esptool-0.4.8-win32.zip", 
              "size": "32192"
            }, 
            {
              "url": "https://github.com/igrr/esptool-ck/releases/download/0.4.8/esptool-0.4.8-osx.tar.gz", 
              "checksum": "SHA-256:2bcbf19934543fb06c505b2a595b68a76e4cab8e3d8968a4d1802195c87126cf", 
              "host": "x86_64-apple-darwin", 
              "archiveFileName": "esptool-0.4.8-osx.tar.gz", 
              "size": "28798"
            }, 
            {
              "url": "https://github.com/igrr/esptool-ck/releases/download/0.4.8/esptool-0.4.8-osx.tar.gz", 
              "checksum": "SHA-256:2bcbf19934543fb06c505b2a595b68a76e4cab8e3d8968a4d1802195c87126cf", 
              "host": "i386-apple-darwin", 
              "archiveFileName": "esptool-0.4.8-osx.tar.gz", 
              "size": "28798"
            }, 
            {
              "url": "https://github.com/igrr/esptool-ck/releases/download/0.4.8/esptool-0.4.8-linux64.tar.gz", 
              "checksum": "SHA-256:1cd9a6014bbbc37ba6dc249f4fc027f0ca9bbc6dd0e203ebc7d146dfd78a6e78", 
              "host": "x86_64-pc-linux-gnu", 
              "archiveFileName": "esptool-0.4.8-linux64.tar.gz", 
              "size": "15479"
            }, 
            {
              "url": "https://github.com/igrr/esptool-ck/releases/download/0.4.8/esptool-0.4.8-linux32.tar.gz", 
              "checksum": "SHA-256:b0d6e71e6f41d4ed7e167bb4b3f4f0b1b3e49d69af50ab7fbe952cbfed83f164", 
              "host": "i686-pc-linux-gnu", 
              "archiveFileName": "esptool-0.4.8-linux32.tar.gz", 
              "size": "15444"
            }, 
            {
              "url": "https://github.com/igrr/esptool-ck/releases/download/0.4.8/esptool-0.4.8-linux-armhf.tar.gz", 
              "checksum": "SHA-256:e9c4dfb81781610556a6af0377c8efc7cde359e0e2cda2fd48e0a32bae10f506", 
              "host": "arm-linux-gnueabihf", 
              "archiveFileName": "esptool-0.4.8-linux-armhf.tar.gz", 
              "size": "13630"
            }
          ]
        }, 
        {
          "version": "0.4.5", 
          "name": "esptool", 
          "systems": [
            {
              "url": "https://github.com/igrr/esptool-ck/releases/download/0.4.5/esptool-0.4.5-win32.zip", 
              "checksum": "SHA-256:1b0a7d254e74942d820a09281aa5dc2af1c8314ae5ee1a5abb0653d0580e531b", 
              "host": "i686-mingw32", 
              "archiveFileName": "esptool-0.4.5-win32.zip", 
              "size": "17408"
            }, 
            {
              "url": "https://github.com/igrr/esptool-ck/releases/download/0.4.5/esptool-0.4.5-osx.tar.gz", 
              "checksum": "SHA-256:924d31c64f4bb9f748e70806dafbabb15e5eb80afcdde33715f3ec884be1652d", 
              "host": "x86_64-apple-darwin", 
              "archiveFileName": "esptool-0.4.5-osx.tar.gz", 
              "size": "11359"
            }, 
            {
              "url": "http://arduino.esp8266.com/esptool-0.4.5-1-gfaa5794-osx.tar.gz", 
              "checksum": "SHA-256:722142071f6cf4d8c02dea42497a747e06abf583d86137a6a256b7db71dc61f6", 
              "host": "i386-apple-darwin", 
              "archiveFileName": "esptool-0.4.5-1-gfaa5794-osx.tar.gz", 
              "size": "20751"
            }, 
            {
              "url": "https://github.com/igrr/esptool-ck/releases/download/0.4.5/esptool-0.4.5-linux64.tar.gz", 
              "checksum": "SHA-256:4ce799e13fbd89f8a8f08a08db77dc3b1362c4486306fe1b3801dee80cfa3203", 
              "host": "x86_64-pc-linux-gnu", 
              "archiveFileName": "esptool-0.4.5-linux64.tar.gz", 
              "size": "12789"
            }, 
            {
              "url": "https://github.com/igrr/esptool-ck/releases/download/0.4.5/esptool-0.4.5-linux32.tar.gz", 
              "checksum": "SHA-256:a7a2c3200786d7396e8cafca1b9aefe56db8ec1dab5e9163d4a19358232a7d87", 
              "host": "i686-pc-linux-gnu", 
              "archiveFileName": "esptool-0.4.5-linux32.tar.gz", 
              "size": "12055"
            }
          ]
        }, 
        {
          "version": "0.4.6", 
          "name": "esptool", 
          "systems": [
            {
              "url": "https://github.com/igrr/esptool-ck/releases/download/0.4.6/esptool-0.4.6-win32.zip", 
              "checksum": "SHA-256:0248bf78514a3195f583e29218ca7828a66e13c6e5545a078f1c1257033e4927", 
              "host": "i686-mingw32", 
              "archiveFileName": "esptool-0.4.6-win32.zip", 
              "size": "17481"
            }, 
            {
              "url": "https://github.com/igrr/esptool-ck/releases/download/0.4.6/esptool-0.4.6-osx.tar.gz", 
              "checksum": "SHA-256:0fe87ba7e29ee90a9fc72492aada8c0796f9e8f8a1c594b6b26cee2610d09bb3", 
              "host": "x86_64-apple-darwin", 
              "archiveFileName": "esptool-0.4.6-osx.tar.gz", 
              "size": "20926"
            }, 
            {
              "url": "https://github.com/igrr/esptool-ck/releases/download/0.4.6/esptool-0.4.6-osx.tar.gz", 
              "checksum": "SHA-256:0fe87ba7e29ee90a9fc72492aada8c0796f9e8f8a1c594b6b26cee2610d09bb3", 
              "host": "i386-apple-darwin", 
              "archiveFileName": "esptool-0.4.6-osx.tar.gz", 
              "size": "20926"
            }, 
            {
              "url": "https://github.com/igrr/esptool-ck/releases/download/0.4.6/esptool-0.4.6-linux64.tar.gz", 
              "checksum": "SHA-256:f9f456e9a42bb2597126c513cb8865f923fb978865d4838b9623d322216b74d0", 
              "host": "x86_64-pc-linux-gnu", 
              "archiveFileName": "esptool-0.4.6-linux64.tar.gz", 
              "size": "12885"
            }, 
            {
              "url": "https://github.com/igrr/esptool-ck/releases/download/0.4.6/esptool-0.4.6-linux32.tar.gz", 
              "checksum": "SHA-256:85275ca03a82bfc456f5a84e86962ca1e470ea2e168829c38ca29ee668831d93", 
              "host": "i686-pc-linux-gnu", 
              "archiveFileName": "esptool-0.4.6-linux32.tar.gz", 
              "size": "13417"
            }
          ]
        }, 
        {
          "version": "0.1.2", 
          "name": "mkspiffs", 
          "systems": [
            {
              "url": "https://github.com/igrr/mkspiffs/releases/download/0.1.2/mkspiffs-0.1.2-windows.zip", 
              "checksum": "SHA-256:0a29119b8458b61a877408f7995e4944623a712e0d313a2c2f76af9ab55cc9f2", 
              "host": "i686-mingw32", 
              "archiveFileName": "mkspiffs-0.1.2-windows.zip", 
              "size": "230802"
            }, 
            {
              "url": "https://github.com/igrr/mkspiffs/releases/download/0.1.2/mkspiffs-0.1.2-osx.tar.gz", 
              "checksum": "SHA-256:df656fae21a41c1269ea50cb53752dcaf6a4e1437255f3a9fb50b4025549b58e", 
              "host": "x86_64-apple-darwin", 
              "archiveFileName": "mkspiffs-0.1.2-osx.tar.gz", 
              "size": "115091"
            }, 
            {
              "url": "https://github.com/igrr/mkspiffs/releases/download/0.1.2/mkspiffs-0.1.2-osx.tar.gz", 
              "checksum": "SHA-256:df656fae21a41c1269ea50cb53752dcaf6a4e1437255f3a9fb50b4025549b58e", 
              "host": "i386-apple-darwin", 
              "archiveFileName": "mkspiffs-0.1.2-osx.tar.gz", 
              "size": "115091"
            }, 
            {
              "url": "https://github.com/igrr/mkspiffs/releases/download/0.1.2/mkspiffs-0.1.2-linux64.tar.gz", 
              "checksum": "SHA-256:1a1dd81b51daf74c382db71b42251757ca4136e8762107e69feaa8617bac315f", 
              "host": "x86_64-pc-linux-gnu", 
              "archiveFileName": "mkspiffs-0.1.2-linux64.tar.gz", 
              "size": "46281"
            }, 
            {
              "url": "https://github.com/igrr/mkspiffs/releases/download/0.1.2/mkspiffs-0.1.2-linux32.tar.gz", 
              "checksum": "SHA-256:e990d545dfcae308aabaac5fa9e1db734cc2b08167969e7eedac88bd0839667c", 
              "host": "i686-pc-linux-gnu", 
              "archiveFileName": "mkspiffs-0.1.2-linux32.tar.gz", 
              "size": "45272"
            }, 
            {
              "url": "https://github.com/igrr/mkspiffs/releases/download/0.1.2/mkspiffs-0.1.2-linux-armhf.tar.gz", 
              "checksum": "SHA-256:5a8836932cd24325d69054cebdd46359eba02919ffaa87b130c54acfecc13f46", 
              "host": "arm-linux-gnueabihf", 
              "archiveFileName": "mkspiffs-0.1.2-linux-armhf.tar.gz", 
              "size": "41685"
            }
          ]
        }
      ], 
      "email": "ivan@esp8266.com", 
      "name": "esp8266"
    }
  ]
}

 

如果您在开发板管理器的URL中已经添加了一些其他开发板,请在添加上述URL前加一个逗号和空格。

smart home electronics

 

smart home electronics

选择菜单选项中的工具(Tools)→开发板(Board)→开发板管理(Boards Manager)……向下滚动,找到ESP8266 Community中的esp8266选项,这是列表中的最后一项,然后点击安装(Install)。

如果您在设置开发板时需要额外的帮助,请参考本教程:

连接ESP-12E开发板和超声波传感器的电路设计

 

连接

smart home electronics

图5:系统接线

显然,这里我们只需要进行少数的几个连接,因为大部分功能已经在我们的电路设计部分实现了。

编写代码

跳转到用于检测您邮箱中新邮件的程序代码部分:

您无需在这部分程序中添加任何库;只需在您的NodeMCU上显示以下代码即可。

[https://github.com/formus14/Smart_mailbox/tree/master/Ultrasonic_HC_SR04_ESP8266]

您可以从Arduino IDE的串行监视器中查看结果。

连接程序代码和Blynk应用程序

这部分包含两个内容:1. Arduino程序代码; 2. 使用Blynk构建移动应用程序。

程序设计

在程序设计这部分涉及到很多内容。我会尽量把它划分成更简单的步骤。

Blynk是一款可以与至今市面上大部分的微控制器进行交互的应用程序,它的功能是通过移动应用程序和微控制器之间发送和接收数据来实现的。

  • • 下载并安装Blynk库,这样我们就可以使用Blynk的所有功能了。

[https://github.com/formus14/Smart_mailbox/tree/master/blynk-library-0.3.4]

[https://github.com/formus14/Smart_mailbox/tree/master/SimpleTimer-library]

  • • 如果您使用的是简单的LCD,请用虚拟引脚来发送数据到移动应用程序上。在本项目中,我们从应用程序发送数据到硬件时使用常规的数字或模拟引脚。
  • • 如果您使用的是高级LCD,只需为LCD创建一个对象即可,就像程序代码中显示的那样。

在这里下载所有的程序代码和库:[https://github.com/formus14/Smart_mailbox]

smart home electronics

Blynk 移动应用程序

使用Blynk,您可以通过使用小部件来控制和监视来自iOS或者Android设备的硬件项目来创建界面。Blynk支持Arduino、Raspberry Pi、Particle Core,以及其他常见的微控制器。

您还可以在其他平台通过网络来控制硬件。但是,对于本项目,我们使用Blynk,因为它非常易于操作。

您在程序代码中需要注意的一些事项:

  • • char auth[] = ” “;

mailbox.ino程序代码中的这一行应填写您在创建应用程序时获得的身份认证信息。

Blynk.begin(auth, “WIFI Network”, “WIFI PASSWORD”);

对于设置功能中的这一行,您应该将“WI-FI Network”更改为自己的Wi-Fi网络名称。对“Wi-Fi PASSWORD”也是如此。

除了启动Blynk的相关内容,以下还有通过屏幕快照来展示如何创建您自己的应用程序的分步指南:

1) 使用您的账户信息登录后,会看到以下画面:

smart home electronics

2) 按下“创建新项目”(Create New Project)后,输入您的项目名称,然后选择“ESP8266”作为硬件型号。

smart home electronics

 

smart home electronics

3) 保存身份认证信息这一步非常重要,因为我们要把它添加到ESP8266的主程序中。您可以选择通过按下e-mail键来将它发送到您登录时所用的邮箱。

smart home electronics

4) 发送完成后,您可以点击“创建”(Create)以完成项目的创建。项目创建后,您就可以添加其他的小部件到您的应用程序中了。

smart home electronics

5) 在屏幕的右上角点击添加“+”,您将看到所有的小部件框,然后将LCD部件拖拽到您的工作区中。

smart home electronics

 

smart home electronics

6) 对于我们的系统,我们只需要LCD,但是您也可以尽情尝试其他可获取的小部件。

LCD上有两种打印方式(简单或高级)。本教程介绍高级方式。

smart home electronics

 

smart home electronics

7) 点击颜色(COLORS)下的“O屏幕”(O Screen),更改LCD的背光;对(T)文本((T) Text)通过相同的操作来编辑颜色。

现在,您应将LCD连接到虚拟引脚,这样它就可以通过Blynk服务器与ESP8266进行通信了。

在主程序中,我将LCD与虚拟引脚1进行连接。

smart home electronics

 

smart home electronics

 

smart home electronics

 

smart home electronics

8) 现在应用程序已经可以与您的硬件系统之间进行交互了。

smart home electronics

9) 将程序上传到ESP8266中,并在Blynk上运行您的应用程序。

如果您没有任何邮件,将会在LCD上看到以下消息:

smart home electronics

如果在您的邮箱中收到邮件,那么您将会在屏幕上看到以下另一种信息:

smart home electronics

现在您就可以仅在收到邮件时查看邮箱,从而节省时间了。

smart home electronics

DevicePlus 编辑团队
Omar Hussein

自学成才的业余爱好者和极客。Omar喜欢学习新的技能,并且热衷于将Arduino与其他任何他能接触到的东西进行交互。他喜欢构建可以在他的日常生活中可以使用的项目。

分享到社交媒体