OLED Display Code Help


#1

Hi all,

I am working on a project for a class where we have to use a photon. I am completely new to this area and the world of programming and I am currently at a stand still with my project. What I am trying to do is connect my photon with my google calendar using IFTTT. When an event is coming up my photon will then display “Yes” on the OLED that comes in the maker kit. I believe the problem I am facing is in my code. I am hoping that someone on here can help me with this project. All that I have done is below:

Connection Between Photon and OLED

3V3          =>     VCC
GND          =>     GND
A3           =>      D0
A5           =>      D1
D3           =>      DC
D4           =>      CS
D5           =>      RES

IFTTT Applet

IFTTT seems to be working because I will get notifications on my console.

Code

//libraries included
#include "Adafruit_SSD1306/Adafruit_GFX.h"
#include "Adafruit_SSD1306/Adafruit_SSD1306.h"

//define pins used
#define OLED_DC     D3  
#define OLED_CS     D4
#define OLED_RESET  D5
Adafruit_SSD1306 display(OLED_DC, OLED_RESET, OLED_CS);  //define display

void setup()
{
    Particle.subscribe("Upcoming_Event10_4", writetoscreen); 
    //receive from IFTTTT send to function
}
void loop()
{}
  
void writetoscreen(const char *event, const char *data)
{
    if(strcmp(data,"Upcoming_Event10_4")==0) 
    { //compare variable and determine meaning
        //display settings an upcoming event
        Particle.publish("photon_phanatics_com7","Upcoming_Event10_4");
        display.setTextSize(1); 
        display.setTextColor(WHITE);
        display.setCursor(0,0);
        display.println("YES");
        display.display();
        delay(15000);
        display.clearDisplay();
    }       //if upcoming event display yes for 15 seconds
} 

In the code above the large bolded text’s have “#” in front of them but I cannot get them to display, again I am new and I apologize.

Thank you for any help, I have been trying to do research on my own to figure this out but I am currently lost and confused.

Andrew


#2

About the formating look at this thread
Forum Tips and Tricks

What exactly is your problem? I can’t quite get that from your post.

  • receiving the event
  • parsing the data
  • displaying the data

About that particular display there are several threads that show how to get it to work
e.g.
Adafruit SSD1306 [SOLVED]
or
https://community.particle.io/search?q=ssd1306

One thing to not tho’ is that you should not have a delay(15000) in the subscription handler


#3

Sorry I guess I left that part out. But my problem is that nothing will display. I ran through a demo that displayed various shapes and snow flakes, but I cannot get the end goal for my project to display.

Also thanks for the formatting!


#4

It seems your if() condition is not satisfied for some reason.
If it was I’d expect to see a "photon_phanatics_com7","Upcoming_Event10_4" event in your console screenshot.

You should have an else branch too - that way you could print out what data your device received but didn’t satisfy the condition.


#5

In my string compare I changed “data” to “event” and I get these two logs in my console:

I still get no display and now after this runs my photon no longer communicates with the cloud (breathes green).


#6

That breathing green indicates that your code is starving the cloud thread.
There most likely is some loop that doesn’t finish in time (possibly inside a library).

You can add SYSTEM_THREAD(ENABLED) to the top of your code.

Try to print something on your dislplay by default - e.g in loop() to make sure the display as such works.

To reenable the cloud connection for an OTA update with corrected code, put the device in Safe Mode (breathing magenta).