Manual: How to Send Events From Google Calender to ESP8266 Board

by SimonINSTRUCT in Circuits > Arduino

348 Views, 2 Favorites, 0 Comments

Manual: How to Send Events From Google Calender to ESP8266 Board

zap to calendar.png

In this manual I will describe step by step how you can send data from your google calendar to the ESP8266. We are going to do this with Adafruit and Zapier. Before you start make sure you have downloaded Arduino IDE and you have the NodeMCU ESP8266 board. You will need this to set up the connection.

Supplies

So what do you need for this setup:

  • Arduino IDE or older version
  • Adafruit IO installed libraries
  • NodeMCU 1.0 ESP8266 board
  • USB cable (type C to micro-usb or type A to micro-usb)
  • Adafruit IO account
  • Zapier account
  • Google account
  • Google Calendar event (this could be anything but you will need it to send to Adafruit and Arduino)
  • Hotspot wifi connection (2.4 ghz)
  • Bonus for step 11: LEDstrip (not necessary for the other steps)

Create an Account on Adafruit IO

1666786739158.png
feed.png
  • Go to Adafruit IO and create an account, click in the top right corner on sign up
  • If you already have an account then sign in
  • When signed in click on the tab IO in the navigation bar and click on Feeds
  • Create a new feed (use a convenient name, we are going to need this later on)
  • When this is done you must see the feed you just created
  • The created feed will be empty for now

Create a Zap

zap.png
create zap.png
  • First go to Zapier and connect with your google account (you will need this to connect with google calendar)
  • Then click on the big orange button: Create Zap
  • First we are going to create a trigger
  • Choose Google Calendar

Connect Google Calendar

event zap.png
connect calendar.png
  • Select Google Calendar
  • Select the event: Event Start
  • This is the trigger which will start the Zap
  • Click on Continue
  • Then connect to your Google Calendar Account (you might need to sign in)
  • Click on continue to set up trigger (see image)
  • Then test trigger

Connect to Adafruit IO

key.png
sign in adafruit.png
  • Now we will setup the action to make the connection
  • Choose Adafruit IO
  • Then choose event: Create Feed Data
  • Then sign in with your Adafruit account you created in step 1
  • You will need your key from Adafruit, you will see it when you click on the yellow key (see image)
  • Copy your key and paste it in API key, and fill in your username
  • Now your Adafruit account is connected
  • Then we will setup the action


Setup Action

event begins.png
test data feed.png
done zap.png
  • First you will need to select your feed key from Adafruit
  • Choose the one you created earlier: In my case it's Smart Cook
  • Then under value select: 1.Event Begins and 1.Event Ends. This is the value to sent (don't choose the Pretty version)
  • Now test Action
  • If everything went on succesfull you should see the data in your Adafruit IO feed which you have just tested (see image)
  • Click on Publish Zap and Turn on
  • When done you must see your Zap (see image)

Alright now everything is setup we are going to connect our Arduino to Adafruit. Make sure everything works and you didn't miss a step.

Arduino Libraries Installation

arduino.png
  • First we are going to install the Adafruit IO libraries
  • Open Arduino > Go to Sketch > Libraries > Manage libraries > search for Adafruit IO Arduino
  • Click on install and select the newest version (see image)
  • Run installation (I have an older version of Arduino, the interface of the IDE version is different)
  • When the installation is done restart Arduino

Open the File

file feed read.png
  • Open Arduino and go to File > Examples > Adafruit IO Arduino > adafruitio_21_feed_read
  • Guess what, you will need this file to read your feed :)
  • This file includes two files: The feed read file and the config.h file
  • Connect your ESP board to your laptop with the usb cable
  • I have already setup the board earlier so I won't describe how to install and connect your ESP board
  • If you have already done this go to step 8


  • If you haven't done this click on this link to setup your board (note: this link works only on windows)
  • Or try these links instead: link 1 and link 2
  • After you have done this and your board is installed come back to this manual and continue to step 8

Setup the Config.h File

username key.png
wifi hotspot.png
hotspot.png
  • Click on the config.h file
  • Here you are going to change some code
  • Fill in your username and key from Adafruit IO (you will find the key on Adafruit IO described in step 4 remember?)
  • Turn on your hotspot on your phone and make sure the connection is on 2.4ghz (it won't work on 5ghz)
  • Fill in your SSID and Password from your hotspot connection (you will find this on your phone)
  • Make sure that your username, key, wifi ssid and password are correct otherwise it won't make any connection

Setup the Main File

smart cook.png
seriele upload-01.png
received.png
  • You need to change some code in the fead read file as well
  • Add your username as the name of the feed owner: in my case SimonIO
  • Add the name of your feed: in my case it is Smart Cook
  • Now upload the sketch to your board!!
  • Open the serial monitor when the code is uploaded!
  • In the serial monitor you need to select 115200 baud otherwise it won't work
  • If nothing happens sent a new test Zap (like we did in step 5)
  • Open the serial monitor and see if you can see a received event

Modify the Serial Monitor Print

yellow.png
cooking modified.png
yaay it worked.png
  • Alright after this is all done we are going to modify the text which we receive in the serial monitor because now we won't see the events details
  • We are going add some code to do this
  • You can find the code here
  • Copy the code from rule 54 untill rule 106 (don't forget the bracket)
  • Deleate the code in yellow (see image) in your own Arduino file and paste the code you copied
  • Modify the code to your preferation (see image)
  • Upload the code and see what happens in your serial monitor
  • Yaay it worked! You can now see the upcoming event
  • Add a new event to your Google Calendar and see if anything happens (keep in mind you have set the trigger to go off 15 minutes before the event happens)
  • Or run a new test in Zapier to receive the event in your serial monitor

Try to Step Up a Level

define.png
connection.png
turn on.png

Try to set a LEDstrip to your event (you can only do this if you have a LEDstrip)

  • First you need to connect the LEDstrip onto your NodeMCU board
  • The LEDstrip has three cables:
  • Connect the Grey/Brown cable to the 3V3 Pin
  • Connect the Orange cable to the DNG Pin
  • And connect the Red cable to the D5 Pin
  • Adafruit IO has a file called adafruitio_14_Neopixel (you will find this under File > Examples > Adafruit IO Arduino)
  • Include this file into your main file, on the top of your document you will see #include ''config.h''
  • Paste #include <Adafruit_NeoPixel.h> in the next rule
  • Now paste this code under #define FEED_OWNER "USERNAME" (see image)

#define PIXEL_PIN D5

#define PIXEL_COUNT 10

#define PIXEL_TYPE NEO_GRB + NEO_KHZ800

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


  • Then paste the following code to set on the led when a connection is made: (see image)

pixels.begin();

pixels.show();


  • As the last step you will need to define the led light, in my code it is set to RED
  • We will do this in a function
  • Copy this code (make sure you don't forget to copy the brackets otherwise you will get an error)

if (data > 0) {

  

 for( int i = 0; i<PIXEL_COUNT; i++) {

 pixels.setPixelColor(i, 250, 0, 0); //color is red

 pixels.show();

    }

 }

  • And paste it in the function (see image)
  • Upload your code
  • The Led will turn on when it has made an connection!
  • I didn't manage to control the led when an event is set due to lack of time
  • If you do manage to pull this off please let me know!!

Sources I Used