Skills Dev III: Ambient Orb

Made by Kevin Chou

Goals: This practice exercise will challenge you to create an ambient calendar alert using a neopixel strip. By the end of the project, you’ll have connected your Particle device to your Google Calendar through IFTTT and display an alert using a Neopixel LED array

Created: November 16th, 2022

0
0

Outcome

In this project, a neopixel strip was used to emit and change colors based on IFTTT triggers connected to Google Calendar. By default, the neopixel strip always shines white light; 15minutes before an event on Google Calendar is about to begin, the neopixel begins fading red. Once the meeting time is reached, the neopixel begins fading back to white over the next 15 minutes.
Examples of IFTTT sending successful triggers from Google Calendar events to the Particle function can be seen above.
For the sake of showing off functionality in a small embeddable video, the neopixel color fades are sped up by 100x, and the Particle Function that IFTTT would have triggered with a calendar event is triggered manually instead for the video demonstration.

0

Process

Using the neopixel strip required some soldering, and I  soldered 4 wires to the input pads. I also crimped male jumper pins onto the wires and slipped them into a 4 slot connector housing. The neopixels were very easy to interface with using the neopixel library, and an IFTTT account had to be made to add Google Calendar Integration and trigger a Particle function with a webhook. While IFTTT was simple to set up, actually verifying that calendar events were triggering properly could be difficult to tell at times until you realize that there is massive inconsistent delay for triggers set to go off 15min before an event, but that the platform will always give a near instant update on the applet activity page so you can tell at exactly what time the trigger went off.

0

Reflection

Unfortunately, IFTTT's Google Calendar triggers are quite unreliable, and will almost never actually trigger 15minutes before your event begins- from testing, it appears to trigger within +-8min. Other users online appear to experience similar results, with Pro users having slightly better notification windows. As such, this unreliable behavior should be accounted for when designing with this functionality in mind in the future.

0
// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>

#define PIXEL_PIN D2
#define PIXEL_COUNT 8 //for stick, 16 for ring
#define PIXEL_TYPE WS2812B //for 4pin neopixels, WS2812/WS2813 for 6pin

unsigned long redTimer = 0;

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

bool meetingTrigger = false;

int redValue = 10;
int greenValue = 10;
int blueValue = 10;

// this function automagically gets called upon a matching POST request
int IFTTT_Function1(String command){
    meetingTrigger = !meetingTrigger;
    redTimer = millis(); //in milliseconds, 1000 = 1sec
    if(command == "1"){
        meetingTrigger = !meetingTrigger;
        redTimer = millis(); //in milliseconds, 1000 = 1sec
    }
    if(meetingTrigger){
        return 1;
    }
    return 0;
}

void NeoPixelRedFade(bool fadeIn, unsigned long fadeTime){ //fade to/from white
    
    if(fadeIn && redValue < 255){//decrease r
        redValue = map(millis(), redTimer, redTimer + fadeTime, 10, 240);
        for(int i=0; i<strip.numPixels(); i++){
            strip.setPixelColor(i, redValue, 10, 10);
        }
    }
    else{//fade out, decrease r
        redValue = map(millis(), redTimer + fadeTime, redTimer + fadeTime + fadeTime, 240, 10);
        for(int i=0; i<strip.numPixels(); i++){
            strip.setPixelColor(i, redValue, 10, 10);
        }
        if(redValue == 10){
            meetingTrigger = false;
        }
    }
}
//------------------------------------------------------------------------
void setup() {
    
    //Neopixel
    strip.begin();
    strip.show();
    
    //Cloud Functions
    Particle.function("IFTTT1", IFTTT_Function1);
    //Colors used to debug LED values
    Particle.variable("Red Value", redValue);
    Particle.variable("Green Value", greenValue);
    Particle.variable("Blue Value", blueValue);
}
//------------------------------------------------------------------------
void loop() {
    unsigned long fadeTime = 900000;
    
    if(meetingTrigger){//fade to red if meeting trigger is true
        if(millis() < redTimer + fadeTime){ //1000ms * 60sec/min * 15min = 900,000, 1.5min for 90,000,
            NeoPixelRedFade(true, fadeTime);
        }else{ NeoPixelRedFade(false, fadeTime); }
    }else{//white
        redValue = 10;
        greenValue = 10;
        blueValue = 10;
        for(int i=0; i<strip.numPixels(); i++){
            strip.setPixelColor(i, redValue, greenValue, blueValue);
        }
    }
    strip.show();
    delay(1000);
}
Click to Expand
x
Share this Project

Courses

About

Goals: This practice exercise will challenge you to create an ambient calendar alert using a neopixel strip. By the end of the project, you’ll have connected your Particle device to your Google Calendar through IFTTT and display an alert using a Neopixel LED array