Introduction: IoT Agenda With NodeMCU 1.0 (ESP-12E Module)
What if you never have to miss another event ever again? In this manual, I will show you how you can create your own reminder. It's easy, yet very useful. You set the time how far before the event you want to be triggered. You will see the color on your LEDstrip change so you know the event is about to start.
The following setup was used for NodeMCU 1.0 (ESP-12E Module) with Arduino IDE.
- Windows 10
- Arduino IDE v. 1.8.4
Step 1: What Do You Need
What you need in order to follow this tutorial are the following components:
- Micro USB cable
- NodeMCU 1.0 (ESP-12E Module)
- LEDstrip
Furthermore, you will need:
- Adafruit IO account
- Google calender
- Zapier account
- Arduino IDE 1.8.2
Step 2: Google Calender
Because you want to be reminded, you should make an event in Google Calender.
Go to the following website and make an event:
Step 3: Connect Google Calender With Zapier
Make an Zapier account if you haven't done that yet. Click on Make a zap (orange button in the right corner), and connect your Google Calender with Zapier. In order to do that, you need to type in Google Calender in the search field and click on it. In that way, you can connect your calender with Zapier.
Step 4: Trigger
Choose event start as trigger and choose your Google account. Next in the edit options section, you should write how far before the event you want to be triggered. You will get the notification on your LEDstrip based on your answer. At last, you need to write the search term that must match exactly with how you named your event in the Google Calender. Save your Zap now.
Step 5: Connect Zapier With Adafruit IO
After trigger follows the action. To connect Adafruit IO with Zapier, you need to go to the following link: https://zapier.com/developer/invite/25310/e5b57f6e084ed73db02db095986ead31/ Don't make a new Zap, go further with the Zap you're already making. Choose now as action Adafruit.
Step 6: Adafruit Feed and Values
Add your Adafruit account and paste your AIO key. Set as value "1". We need that to trigger the event. You'll see the value back in the code later as well. Go to Adafruit and make a feed called "Test". Type this in Zapier. You could test the Zap if it's working. You should see the value in your Adafruit feed.
Step 7: Add Code to Connect to Adafruit
Connect your NodeMCU to your PC with the MicroUSB cable. You should have your LEDstrip connected to the NodeMCU as well in D5, G and 3V. Make sure you have your LEDstrip connected in this way. Add now the following Code to an Arduino sketch.
// 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();
}
Step 8: New Tab in Arduino
Make a new tab and name it "config.h". You need this to actually include the config.h (see previous code). In the following code, you need to write your own Adafruit username and your own key. If you don't know your key yet, go to Adafruit IO and click "view AIO key". Paste it in Arduino. Make sure you have the Arduino Neopixel library installed, otherwise the code won't work.
<p>/************************ Adafruit IO Config *******************************/</p><p>// 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"</p><p>/******************************* WIFI **************************************</p><p>/ 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</p><p>#define WIFI_SSID "Your wifi or hotspot name" #define WIFI_PASS "Your wifi or hotspot password"</p><p>// 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);</p><p>/******************************* FONA **************************************</p><p>/ the AdafruitIO_FONA client will work with the following boards: // - Feather 32u4 FONA -> https://www.adafruit.com/product/3027</p><p>// 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);</p><p>/**************************** ETHERNET ************************************</p><p>/ the AdafruitIO_Ethernet client will work with the following boards: // - Ethernet FeatherWing -> https://www.adafruit.com/products/3201</p><p>// 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);</p>
Step 9: Test If You're Connected to Adafruit
If you copied it correctly, you should see the following after uploading in the serial monitor:
Connecting to Adafruit IO.... Adafruit IO connected.
Step 10: Update Your Code to Receive Data
Add the following code in the initial tab to receive colors on your LEDstrip. You will get these colors if your event is about to start.
if (data->toPinLevel() == 1) {
for(int i=0; i<PIXEL_COUNT; ++i) {pixels.setPixelColor(i, 0, 255, 0);
pixels.show(); } Serial.println("Event is about to start!"); }digitalWrite(PIXEL_PIN, data->toPinLevel());
} }
Step 11: Final Notification
If you did the following steps correctly and your event is about to start, you will get a notification at the time in your serial monitor. You will see the following:
Connecting to Adafruit IO...
Adafruit IO connected. received <- Event is about to start!
And your LEDstrip will turn green. And that's it! You have created your own reminder!