Webhook display on OLED not compiling, Bitcoin price api

Hi,
I am having problems getting this bitcoin api webhook I created to compile.

does anyone see any obvious issues? I appreciate it

I tested the webhook and its working…

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

void setup() {
  Serial.begin(9600);

  // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // Don't proceed, loop forever
  }

  
  // Subscribe to the integration response event
  Particle.subscribe("hook-response/bitcoin", myHandler, MY_DEVICES); // webhook instructions
}

void myHandler(const char *event, const char *data) {  // webhook instructions
  // Handle the integration response
}
         
void loop() {
    bitcoin();
}

void bitcoin(void) {
  // Get some data
  String data = String(10); // webhook instructions
  // Trigger the integration
  Particle.publish("bitcoin", data, PRIVATE); // webhook instructions
  display.clearDisplay();

  display.setTextSize(2); // Draw 2X-scale text
  display.setTextColor(WHITE);
  display.setCursor(10, 0);
  display.myHandler;
  //display.display();      // Show initial text
 
  delay(60000);   // Wait 60 seconds // webhook instructions
}

The error log would be helpful.

If the errors have to do with the SSD1306 library chances are that you will find other threads that deal with some errors caused by that :wink:

1 Like

here is the error log.

bitcoin-oled.ino:51:11: ‘class Adafruit_SSD1306’ has no member named ‘myHandler’

This is the line and it has multiple issues.

  1. as the error message states myHandler is neither a method nor a field of the display object
  2. you have a function myHandler(const char* event, const char* data)) but in order to call it you’d write myHandler(someString, someOtherString) - neither display.myHandler nor display.myHandler()
  3. however, it’s not your task to call myHandler() at all, that’s done by device OS triggered when receiving the event you subscribed to
1 Like