Yogeshwar SookdeoEllis Young
Published

Calendar Notifier Using Particle Photons

This device setup keeps track of different assignments and events from a Google calendar by displaying a light when an event begins.

BeginnerShowcase (no instructions)5 hours628
Calendar Notifier Using Particle Photons

Things used in this project

Story

Read more

Schematics

Photon Circuit Diagram for Both Photons

Code

Notification Photon

C/C++
This photon receives a notification from the control data photon that tells it to turn on the onboard D7 LED light when there is an assignment. This photon then sends a notification to the control data photon telling it to turn on the D7 LED for confirmation. When the setup button is pressed on the control data photon, this photon will receive a notification to turn off the onboard LED light.
int boardLed = D7;


void setup()
{
    Particle.subscribe("YogiSignal", flickerled);
    Serial.begin(230400);
    pinMode(boardLed,OUTPUT); // Our on-board LED output
    Particle.subscribe("Event_finished",button);
}
void flickerled (const char *event, const char *data)
{

    if(strcmp(data, "Event_Found")==0)
{
        digitalWrite(boardLed,HIGH);
        Serial.println("Event_Found");
        Particle.publish("Event_Confirmed26","1");
}
}
void button(const char *event, const char *data)
{
    if(strcmp(data,"buttonpressed")==0)
    {
        digitalWrite(boardLed,LOW);
        delay(15000);
}
}

Control Data Photon

C/C++
The photon receives the "Event_Found" signal from IFTTT due to an event starting on the Google Calendar. The photon then publishes a variable for the Notification photon to subscribe to. This photon will then receive a variable from the Notification photon and turn on the on board LED. When the setup button is pushed for greater than 0.5 seconds, the on board LED turns off and a variable is published for the Notification photon to read.
SYSTEM_THREAD(ENABLED)
bool buttonset = false;
int boardled= D7;

void setup()
{
Particle.subscribe("Event_Found", writetoscreen); 
//receive from IFTTTT send to function
WiFi.RSSI();
Particle.subscribe("Event_Confirmed26", eventconfirmed);
pinMode(boardled,OUTPUT);
digitalWrite (boardled, LOW);
}

  
void writetoscreen(const char *event, const char *data)
{
    if(strcmp(event,"Event_Found")==0) 
    { //compare variable and determine meaning
        
        Particle.publish("YogiSignal","Event_Found", 60);
}}

void loop() {
    if (System.buttonPushed() > 500) {
        Particle.publish("Event_finished", "buttonpressed", 60); 
        buttonset = true;
        delay(5000);
        digitalWrite (boardled,LOW);
    }
}

void eventconfirmed (const char *event, const char *data) {
    if(strcmp(event, "Event_Confirmed26")==0)
    { digitalWrite(boardled, HIGH);
}}

Credits

Yogeshwar Sookdeo

Yogeshwar Sookdeo

1 project • 0 followers
Ellis Young

Ellis Young

1 project • 1 follower

Comments