Servet ErogluAaron Buckley
Published © MIT

Light News

The screen displays a news headline and whether the light is on or off.

IntermediateShowcase (no instructions)4 hours688
Light News

Things used in this project

Hardware components

Photon
Particle Photon
×2
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×2
Jumper wires (generic)
Jumper wires (generic)
×14
Resistor 10k ohm
Resistor 10k ohm
×2
Photo resistor
Photo resistor
×2
OLED Expansion
Onion Corporation OLED Expansion
×2

Software apps and online services

Maker service
IFTTT Maker service
ThingSpeak API
ThingSpeak API

Story

Read more

Custom parts and enclosures

Picture 1: Light sensor and news display

Picture fkcnbwx8ar

Picture 2: Both Photons at angle

1 wuzxggya1k

Picture 3: Single Photon closeup

2 aaqpfz7xb8

Graph 1: Aaron's Light Graph

https://thingspeak.com/channels/476324
Aarons light w2ero82txp

Geaph 2: Servet's Light Graph

https://thingspeak.com/channels/476851
Servets light oeis6uxh5j

Schematics

SCHEMATICS

Photo resistor setup
Breadboard Configuration
Circuit af2gbzkyzu

Photo resistor setup

Circuit Diagram
Servet 0wt7ksfocv

Code

Photon1

C/C++
This is the code for Photon1
#include "Adafruit_SSD1306.h"
/*********************************************************************
This is a library for our Monochrome OLEDs based on SSD1306 drivers

  Pick one up today in the adafruit shop!
  ------> http://www.adafruit.com/category/63_98

These displays use SPI to communicate, 4 or 5 pins are required to  
interface

Adafruit invests time and resources providing this open source code, 
please support Adafruit and open-source hardware by purchasing 
products from Adafruit!

Written by Limor Fried/Ladyada  for Adafruit Industries.  
BSD license, check license.txt for more information
All text above, and the splash screen must be included in any redistribution
*********************************************************************/

#define OLED_DC A1 // Define the OLED display pins that are used
#define OLED_CS A2
#define OLED_RESET A0

SYSTEM_THREAD(ENABLED); // Photon will crash and screen will not update quickly without this

const String key = "XXXXXXXXXXXXXXXX"; // ThingSpeak Write API Key

int photoresistor = D1; // Create names for Photon pins that are used for light sensing
int power = D0;

Adafruit_SSD1306 display(OLED_DC, OLED_RESET, OLED_CS);


void setup() {
    display.begin(SSD1306_SWITCHCAPVCC); // Start the display
    display.display(); // Displays the splash screen
    delay(2000);
    display.clearDisplay(); // Clears the display
    display.display();

    Particle.subscribe("Photon2", light); // Subscribe to other Photon
    Particle.subscribe("IFTTTapplet", GoogleNews); // Subscribe to IFTTT Google News RSS reader
    
    pinMode(photoresistor, INPUT); // Tell the Photon's pins for the photoresistor what to do
    pinMode(power, OUTPUT);
    digitalWrite(power, HIGH);
}


void GoogleNews(const char *event, const char *data) {
    display.clearDisplay();
    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.setCursor(0,0);
    display.println(data);
    display.display(); // Displays the feedback from IFTTT to the OLED display
}


void light(const char *event, const char *data) {
    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.setCursor(0,55);
    display.println("Light is:");
    display.setCursor(60,55);
    display.setTextColor(BLACK, WHITE); // Inverts the colors so the display will not write over itself
    display.println(data);
    display.display(); // Displays the feedback from the other Photon to the OLED display
}


void loop() {
    int counts = 0;
    while (counts <= 30) { // Publish data to the other Photon every second, but publish data to ThingSpeak every thirty seconds
        String light = "ERROR";
        if (digitalRead(photoresistor) == 1) { // The light is on if the reading pin receives 3.3 volts
            light = " ON ";
        }
        if (digitalRead(photoresistor) == 0) { // The light is of if the reading pin does not receive 3.3 volts
            light = " OFF";
        }
        
        Particle.publish("Photon1", light); // Tell the other Photon if the light is on or off
        
        delay(1000);
        counts = counts + 1;
    }
        String light = "0";
        if (digitalRead(photoresistor) == 1) { // Determine if the light is on or off for the ThingSpeak live graph
            light = "1";
        }
    Particle.publish("thingSpeakWrite_", "{ \"1\": \"" + light + "\"," + "\"k\": \"" + key + "\" }", PRIVATE); // Publish light level to ThingSpeak
}

Photon2

C/C++
This is the code for Photon2
#include "Adafruit_SSD1306.h"
/*********************************************************************
This is a library for our Monochrome OLEDs based on SSD1306 drivers

  Pick one up today in the adafruit shop!
  ------> http://www.adafruit.com/category/63_98

These displays use SPI to communicate, 4 or 5 pins are required to  
interface

Adafruit invests time and resources providing this open source code, 
please support Adafruit and open-source hardware by purchasing 
products from Adafruit!

Written by Limor Fried/Ladyada  for Adafruit Industries.  
BSD license, check license.txt for more information
All text above, and the splash screen must be included in any redistribution
*********************************************************************/

#define OLED_DC A1 // Define the OLED display pins that are used
#define OLED_CS A2
#define OLED_RESET A0

SYSTEM_THREAD(ENABLED); // Photon will crash and screen will not update quickly without this

const String key = "XXXXXXXXXXXXXXXX"; // ThingSpeak Write API Key

int photoresistor = D1; // Create names for Photon pins that are used for light sensing
int power = D0;

Adafruit_SSD1306 display(OLED_DC, OLED_RESET, OLED_CS);


void setup() {
    display.begin(SSD1306_SWITCHCAPVCC); // Start the display
    display.display(); // Displays the splash screen
    delay(2000);
    display.clearDisplay(); // Clears the display
    display.display();

    Particle.subscribe("Photon1", light); // Subscribe to other Photon
    Particle.subscribe("IFTTTapplet", GoogleNews); // Subscribe to IFTTT Google News RSS reader
    
    pinMode(photoresistor, INPUT); // Tell the Photon's pins for the photoresistor what to do
    pinMode(power, OUTPUT);
    digitalWrite(power, HIGH);
}


void GoogleNews(const char *event, const char *data) {
    display.clearDisplay();
    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.setCursor(0,0);
    display.println(data);
    display.display(); // Displays the feedback from IFTTT to the OLED display
}


void light(const char *event, const char *data) {
    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.setCursor(0,55);
    display.println("Light is:");
    display.setCursor(60,55);
    display.setTextColor(BLACK, WHITE); // Inverts the colors so the display will not write over itself
    display.println(data);
    display.display(); // Displays the feedback from the other Photon to the OLED display
}


void loop() {
    int counts = 0;
    while (counts <= 30) { // Publish data to the other Photon every second, but publish data to ThingSpeak every thirty seconds
        String light = "ERROR";
        if (digitalRead(photoresistor) == 1) { // The light is on if the reading pin receives 3.3 volts
            light = " ON ";
        }
        if (digitalRead(photoresistor) == 0) { // The light is of if the reading pin does not receive 3.3 volts
            light = " OFF";
        }
        
        Particle.publish("Photon2", light); // Tell the other Photon if the light is on or off
        
        delay(1000);
        counts = counts + 1;
    }
        String light = "0";
        if (digitalRead(photoresistor) == 1) { // Determine if the light is on or off for the ThingSpeak live graph
            light = "1";
        }
    Particle.publish("thingSpeakWrite_", "{ \"1\": \"" + light + "\"," + "\"k\": \"" + key + "\" }", PRIVATE); // Publish light level to ThingSpeak
}

Credits

Servet Eroglu

Servet Eroglu

2 projects • 2 followers
My name is Servet Eroglu and I was born in Turkey. pursuing a mechanical engineering degree with a concentration in biomedical eng.
Contact
Aaron Buckley

Aaron Buckley

0 projects • 1 follower
Contact

Comments

Add projectSign up / Login