0
  • 聊天消息
  • 系统消息
  • 评论与回复
登录后你可以
  • 下载海量资料
  • 学习在线课程
  • 观看技术视频
  • 写文章/发帖/加入社区
创作中心

完善资料让更多小伙伴认识你,还能领取20积分哦,立即完善>

3天内不再提示

如何设置带有Arduino IDE的NodeMCU 1.0

454398 来源:网络整理 作者:网络整理 2019-12-09 15:12 次阅读

步骤1:您需要什么

要遵循本教程,您需要以下组件:

Micro USB电缆

NodeMCU 1.0(ESP-12E模块)

LEDstrip

此外,您将需要:

Adafruit IO帐户

Google日历

Zapier帐户

Arduino IDE 1.8.2

步骤2:Google日历

如何设置带有Arduino IDE的NodeMCU 1.0

因为您提醒您,您应该在Google Calender中进行活动。

转到以下网站并进行活动:

https://www.google.com/calendar

步骤3:连接带有Zapier的Google日历

创建一个Zapier帐户(如果尚未执行此操作)。单击“制作一个zap”(右上角的橙色按钮),然后将您的Google Calender与Zapier连接。为此,您需要在搜索字段中输入Google Calender并单击它。这样,您可以将压延机与Zapier连接。

步骤4:触发器

选择事件开始作为触发器并选择您的Google帐户。接下来,在“编辑选项”部分中,您应该写出要触发事件的距离。您将根据自己的回答在LED灯条上收到通知。最后,您需要编写与您在Google日历中命名活动的方式完全匹配的搜索词。立即保存您的Zap。

第5步:将Zapier与Adafruit IO连接

触发触发器之后,执行此操作。要将Adafruit IO与Zapier连接,您需要转到以下链接:https://zapier.com/developer/invite/25310/e5b57f6e084ed73db02db095986ead31/不要创建新的Zap,请进一步处理已经制作的Zap 。现在选择Adafruit作为动作。

步骤6:Adafruit数据和值

添加您的Adafruit帐户并粘贴您的AIO密钥。设置为值“ 1”。我们需要它来触发事件。稍后,您还将在代码中看到该值。转到Adafruit并进行一个名为“测试”的提要。在Zapier中输入此内容。您可以测试Zap是否有效。您应该在Adafruit Feed中看到该值。

步骤7:添加代码以连接到Adafruit

使用MicroUSB电缆将NodeMCU连接到PC。您还应该将LED灯带也连接到NodeMCU的D5,G和3V中。确保以这种方式连接LED灯条。现在将以下代码添加到Arduino草图中。

// Adafruit IO Digital Output Example

// Tutorial Link: https://learn.adafruit.com/adafruit-io-basics-digital-output

//

// Adafruit invests time and resources providing this open source code.

// Please support Adafruit and open source hardware by purchasing

// products from Adafruit!

//

// Written by Todd Treece for Adafruit Industries

// Copyright (c) 2016 Adafruit Industries

// Licensed under the MIT license.

//

// All text above must be included in any redistribution.

/************************** Configuration ***********************************

/ edit the config.h tab and enter your Adafruit IO credentials

// and any additional configuration needed for WiFi, cellular,

// or ethernet clients.

#include “config.h”

#include “Adafruit_NeoPixel.h”

/************************ Example Starts Here *******************************

/ digital pin 5

#define PIXEL_PIN D5

#define PIXEL_COUNT 24

#define PIXEL_TYPE NEO_GRB + NEO_KHZ800

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);

// set up the ‘digital’ feed

AdafruitIO_Feed *Test = io.feed(“Test”);

void setup() {

// start the serial connection

Serial.begin(115200);

// wait for serial monitor to open

while(! Serial);

// connect to io.adafruit.com

Serial.print(“Connecting to Adafruit IO”);

io.connect();

// set up a message handler for the ‘digital’ feed.

// the handleMessage function (defined below)

// will be called whenever a message is

// received from adafruit io.

Test-》onMessage(handleMessage);

// wait for a connection

while(io.status() 《 AIO_CONNECTED) {

Serial.print(“。”);

delay(500);

}

// we are connected

Serial.println();

Serial.println(io.statusText());

pinMode(D5, OUTPUT);

}

void loop() {

// io.run(); is required for all sketches.

// it should always be present at the top of your loop

// function. it keeps the client connected to

// io.adafruit.com, and processes any incoming data.

io.run();

}

步骤8:Arduino中的新标签

新建一个标签页并将其命名“config.h中”。您实际上需要包含config.h(请参见前面的代码)。在以下代码中,您需要编写您自己的Adafruit用户名和您自己的密钥。如果您还不知道密钥,请转到Adafruit IO,然后单击“查看AIO密钥”。将其粘贴到Arduino中。确保已安装Arduino Neopixel库,否则代码将无法正常工作。

/************************ Adafruit IO Config *******************************/

// visit io.adafruit.com if you need to create an account,

// or if you need your Adafruit IO key.

#define IO_USERNAME “Your AIO username”

#define IO_KEY “Your AIO key”

/******************************* WIFI **************************************

/ the AdafruitIO_WiFi client will work with the following boards:

// - HUZZAH ESP8266 Breakout -》 https://www.adafruit.com/products/2471

// - Feather HUZZAH ESP8266 -》 https://www.adafruit.com/products/2821

// - Feather M0 WiFi -》 https://www.adafruit.com/products/3010

// - Feather WICED -》 https://www.adafruit.com/products/3056

#define WIFI_SSID “Your wifi or hotspot name”

#define WIFI_PASS “Your wifi or hotspot password”

// comment out the following two lines if you are using fona or ethernet

#include “AdafruitIO_WiFi.h”

AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);

/******************************* FONA **************************************

/ the AdafruitIO_FONA client will work with the following boards:

// - Feather 32u4 FONA -》 https://www.adafruit.com/product/3027

// uncomment the following two lines for 32u4 FONA,

// and comment out the AdafruitIO_WiFi client in the WIFI section

// #include “AdafruitIO_FONA.h”

// AdafruitIO_FONA io(IO_USERNAME, IO_KEY);

/**************************** ETHERNET ************************************

/ the AdafruitIO_Ethernet client will work with the following boards:

// - Ethernet FeatherWing -》 https://www.adafruit.com/products/3201

// uncomment the following two lines for ethernet,

// and comment out the AdafruitIO_WiFi client in the WIFI section

// #include “AdafruitIO_Ethernet.h”

// AdafruitIO_Ethernet io(IO_USERNAME, IO_KEY);

步骤9:测试是否已连接到Adafruit

如果复制正确,则在串行监视器中上传后应该会看到以下内容:

Connecting to Adafruit IO.。..

Adafruit IO connected.

步骤10:更新代码以接收数据

在初始选项卡中添加以下代码,以在LED灯条上接收颜色。如果您的活动即将开始,您将获得这些颜色。

if (data-》toPinLevel() == 1) {

for(int i=0; i

pixels.setPixelColor(i, 0, 255, 0);

pixels.show();

}

Serial.println(“Event is about to start!”);

}

digitalWrite(PIXEL_PIN, data-》toPinLevel());

}

}

步骤11:最终通知

如果执行了以下步骤正确并且您的事件即将开始,您将在串行监视器上收到通知。您将看到以下内容:

Connecting to Adafruit IO.。.

Adafruit IO connected.

received 《- Event is about to start!

责任编辑:wv

声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉
  • Arduino
    +关注

    关注

    184

    文章

    6428

    浏览量

    184902
  • NODEMCU
    +关注

    关注

    13

    文章

    289

    浏览量

    21031
收藏 人收藏

    评论

    相关推荐

    NodeMCUArduino之间的串口通信

    电子发烧友网站提供《NodeMCUArduino之间的串口通信.zip》资料免费下载
    发表于 07-12 09:44 3次下载
    <b class='flag-5'>NodeMCU</b>和<b class='flag-5'>Arduino</b>之间的串口通信

    Arduino在线气象站(NodeMCU)

    电子发烧友网站提供《Arduino在线气象站(NodeMCU).zip》资料免费下载
    发表于 07-04 10:39 0次下载
    <b class='flag-5'>Arduino</b>在线气象站(<b class='flag-5'>NodeMCU</b>)

    使用Arduino IDE对其进行闪存但是毫无作用怎么处理?

    嗨,我有一个 ESP8266 版本 12E (NodeMCU),我正在使用 Arduino IDE 对其进行闪存。 我在同一网络上有一个树莓派,它运行着 Mosquitto MQTT。 我正在尝试
    发表于 06-12 07:48

    #include 板nodemcu编译错误怎么解决?

    io.h 文件更改为旧版本的 arduino IDE,但它对我不起作用。 但显然,如果我将我的板设置更改为 Arduino Uno,它就会起作用。但不适用于
    发表于 06-09 07:07

    无法使用Arduino IDE将MAX31855或MAX6675用于我的NodeMCU V3?

    我无法使用 Arduino IDE 将 MAX31855 或 MAX6675 用于我的 NodeMCU V3 (LoLin)。我已经使用 Arduino UNO 板进行了检查,并在该平
    发表于 06-07 08:54

    NodeMCU Amica无法设置是为什么?

    过去 3 天我一直在尝试设置我的 NodeMCU amics,但无济于事。在 youtube 许多网站、arduino 论坛等上尝试几个小时。 它是全新的,led 会做出应有的响应。但是当我将它插入
    发表于 06-07 07:24

    带有ESP8266的备用NodeMCU,Wifi AP无法正常工作怎么解决?

    我完全是这种物联网的初学者。我找到了带有 ESP8266 的备用 NodeMCU,我尝试将各种项目(例如使用 ESP8266.h 库)代码复制到 arduino IDE,它成功地刷新了
    发表于 06-06 06:14

    如何为NodeMCU添加以太网连接?

    我正在尝试为我的 NodeMCU 添加以太网连接,因为我使用它的地方并不总是有 WiFi 信号。 我正在使用带有 MNI ENC28J60 的 Lolin v1.0。我使用 Arduino
    发表于 06-02 08:37

    有没有人使用Arduino IDE成功地将新代码闪烁到NodeMCU板上?

    我买了一堆 NodeMCU 板,原来是 AiThinker 的,标有 ESP8266MOD。 有没有人使用 Arduino IDE 成功地将新代码闪烁到这个板上?
    发表于 05-31 07:36

    NodeMCU V1.0可以在DIO模式下编程吗?

    我已经使用了我的 NodeMCU 的所有 GPIO,我需要一个额外的 GPIO。 所以我尝试在 DIO 模式下对其进行编程(这样我就可以使用 GPIO10(S3))。 在 Arduino IDE
    发表于 05-30 08:05

    如何在Arduino IDE中使用ESP-100进行开发?

    CH340 驱动程序的 COMx 端口上被识别。到目前为止,一切都很好。 现在使用 Arduino IDE 上传草图总是失败,因为 * Generic ESP8266 * NodeMCU 0.9
    发表于 05-12 08:06

    Arduino IDE无法连接Feriot NodeMCU Lolin V3的原因?

    Arduino IDE 无法连接 Feriot NodeMCU Lolin V3
    发表于 05-11 08:14

    LoLIN NodeMCU V3、ESP8266 12E和Arduino IDE 1.8.9上传程序时报错怎么解决?

    我使用的是 LoLIN NodeMCU V3、ESP8266 12E 和 Arduino IDE 1.8.9。当我上传程序时,发生错误: 我知道这个错误发生在文件 upload.py 中,因为导入
    发表于 05-08 08:14

    NodeMCU停止响应的原因?

    ,在此先感谢。平台硬件:[ESP-8266]开发环境:[Arduino IDE]操作系统:[Windows] IDE模块中的设置:[Nodemcu
    发表于 05-08 07:19

    使用NodeMCU ESP8266 ESP12E,Arduino IDE报错的原因?

    您好,我正在使用 NodeMCU ESP8266 ESP12E 我的 Arduino IDE 出现以下错误 请帮忙 请告诉我我做错了什么? “无法打开 COM3”- 您没有 COM3 或 COM3 已被另一个应用程序打开。
    发表于 05-08 07:08