Arduino esp32 not working

Hello i've been trying to do various codes using gfx and i keep getting an error saying

In file included from C:\Users\User\AppData\Local\Temp.arduinoIDE-unsaved202338-16376-1fsg8j6.8j1o\ssd1306_128x64_i2c\ssd1306_128x64_i2c.ino:23:0:
C:\Users\User\Documents\Arduino\libraries\Adafruit_GFX_Library/Adafruit_GFX.h:13:32: fatal error: Adafruit_SPIDevice.h: No such file or directory
compilation terminated.

exit status 1

Compilation error: exit status 1

im new to arduino so i have no idea what to do

You didn't include the library:
Download this, extract it and save it in the Arduino's "libraries" folder. If you need any further help, don't hesitate to write!

1 Like

Could there be a different solution because i extracted it to my library and it still is giving me the same error

I think, you need the Adafruit GFX Library too:

If it still doesn't work, maybe you can send me the code?

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

#include <WiFi.h>
#include "time.h"
#include "sntp.h"

const char* ssid = "YOUR_SSID";
const char* password = "YOUR_PASSWORD";

const char* ntpServer1 = "pool.ntp.org";
const char* ntpServer2 = "time.nist.gov";
const long gmtOffset_sec = 3600;
const int daylightOffset_sec = 3600;

int hrs=0;
int mins=0;
int secs=0;

Adafruit_SSD1306 display(128, 64, &Wire, -1);

const int NUM_POINTS = 60;
const int RADIUS = 28;

int pointsX[NUM_POINTS];
int pointsY[NUM_POINTS];

void setup() {
  Serial.begin(115200);
  // set notification call-back function
  sntp_set_time_sync_notification_cb(timeavailable);
  sntp_servermode_dhcp(1);  // (optional)
  configTime(gmtOffset_sec, daylightOffset_sec, ntpServer1, ntpServer2);

  //connect to WiFi
  Serial.printf("Connecting to %s ", ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println(" CONNECTED");

  /***************************************************/

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  //initialize the display with I2C address 0x3C
  display.clearDisplay();                     //clear the display buffer
  display.display();                          //update the display

  for (int i = 0; i < NUM_POINTS; i++) {
    pointsX[i] = 64 + RADIUS * cos(i * 6.28 / NUM_POINTS);
    pointsY[i] = 32 + RADIUS * sin(i * 6.28 / NUM_POINTS);
  }
}

void loop() {
  setLocalTime();
  //calculate the angle for each hand
  float secAngle = map(secs, 0, 60, 0, 360);
  float minAngle = map(mins, 0, 60, 0, 360);
  float hrAngle = map(hrs, 1, 12, 30, 360);

  //calculate the positions of the hands
  int hrX = 64 + (RADIUS - 11) * cos((hrAngle - 90) * PI / 180);
  int hrY = 32 + (RADIUS - 11) * sin((hrAngle - 90) * PI / 180);
  int minX = 64 + (RADIUS - 6) * cos((minAngle - 90) * PI / 180);
  int minY = 32 + (RADIUS - 6) * sin((minAngle - 90) * PI / 180);
  int secX = 64 + (RADIUS)*cos((secAngle - 90) * PI / 180);
  int secY = 32 + (RADIUS)*sin((secAngle - 90) * PI / 180);

  display.clearDisplay();  //clear the display buffer

  //draw the clock face
  display.drawCircle(64, 32, 32, WHITE);  //Draw a Center Point
  //Draw 12 Clock points
  for (int i = 0; i < NUM_POINTS; i += 5) {
    display.fillCircle(pointsX[i], pointsY[i], 1, WHITE);
  }

  //Display Numbers 12-3-6-9
  display.setTextSize(1);
  display.setTextColor(SSD1306_WHITE);

  for (int i = 12; i > 1; i -= 3) {
    float angle = map(i, 1, 12, 30, 360);
    int xPos = 64 + (RADIUS - 7) * cos((angle - 90) * PI / 180) - 3;
    int yPos = 32 + (RADIUS - 7) * sin((angle - 90) * PI / 180) - 3;
    display.setCursor(xPos, yPos);
    display.print(i);
  }

  //draw the hour hand
  display.drawLine(64, 32, hrX, hrY, WHITE);

  //draw the minute hand
  display.drawLine(64, 32, minX, minY, WHITE);

  //draw the Second hand
  //display.drawLine(64, 32, secX, secY, WHITE);
  display.drawCircle(secX, secY, 2, WHITE);

  //update the display
  display.display();
  delay(1000);
}


void setLocalTime() {
  struct tm timeinfo;
  if (!getLocalTime(&timeinfo)) {
    Serial.println("No time available (yet)");
    return;
  }
  Serial.println(&timeinfo, "%A, %B %d %Y %H:%M:%S");
  
  hrs = timeinfo.tm_hour;
  mins = timeinfo.tm_min;
  secs = timeinfo.tm_sec;

}

// Callback function (get's called when time adjusts via NTP)
void timeavailable(struct timeval* t) {
  Serial.println("Got time adjustment from NTP!");
  setLocalTime();
}

this is the code it is one of the ssd1306 examples

Try this one

I request that you please do not ask help seekers to go offline for help. It detracts from the value the community has to offer.

OP - did you remove the word master from the libraries? they put that on libraries to indicate that it is original code straight from the source. you have to remove it to use the examples. sometimes you have to fiddle with variables in the examples.

there is always one more thing to know in Arduino World.

there is no master files i've tried deleting the ide and reinstalling it but stil i get the error of

In file included from C:\Users\User\AppData\Local\Temp.arduinoIDE-unsaved202338-4700-qxezst.rihy9\sketch_apr8a\sketch_apr8a.ino:7:0:
C:\Users\User\Documents\Arduino\libraries\Adafruit_GFX_Library/Adafruit_GFX.h:13:32: fatal error: Adafruit_SPIDevice.h: No such file or directory
compilation terminated.

exit status 1

Compilation error: exit status 1

i'm just trying to connect my esp32 to my oled screen

Yes. I highly recommend using the Arduino IDE Library Manager to install libraries whenever possible. I'll provide instructions:

  1. Select Sketch > Include Library > Manage Libraries... from the Arduino IDE menus to open the "Library Manager" view in the left side panel.
  2. In the "Filter your search" field, type adafruit_busio
  3. Scroll down through the list of libraries until you see the "Adafruit BusIO" entry.
  4. You will see an "INSTALL" button at the bottom of the entry. Click the button.
  5. Wait for the installation to finish.

Installing the library via Library Manager ensures the installation is done correctly. You will get a stable version of the library and be able to easily update the library whenever a new stable version is released by the library author. Manual library installation as described previously should only be done in cases where Library Manager installation is not possible.

it does seem to change the error but now i have an error of
C:\Users\User\AppData\Local\Temp.arduinoIDE-unsaved202338-27224-1pfyvn7.nbfn\sketch_apr8a\sketch_apr8a.ino:7:18: fatal error: sntp.h: No such file or directory
compilation terminated.

exit status 1

Compilation error: sntp.h: No such file or directory

any suggestions? thank you btw

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.