I am new and am asking for help

Hello everybody. I am new to arduino and have been trying to build a 3d printed LED clock and am using a sketch that was provided by the designer of the clock but I am running into errors in trying to upload the sketch. I have an arduino mini esp 32. I am getting a lot of errors with the time library and I am unable to figure out what I am doing wrong. If anybody can help me and look at the sketch and tell me what I am not doing correctly I would be very appreciative

#include <Arduino_BuiltIn.h>

#include "FastLED.h"


#define TIMEZONE -5  // timezone (GMT = 0, Japan = 9)
#define NUM_LEDS 60
#define DATA_PIN 4
#define PLPIN 16
#define MOPIN 17
#define DEBOUNCE_TIME 250

const char ssid[] = "XXXX";  // XXXX = your WiFi's SSID
const char password[] = "YYYY";          // YYYY = your WiFi's password
struct   getLocalTime(&tmtime);
int hh;
int hr;
int mmm;
int ss;
int flagPL = 0;
int flagMO = 0;
int blanc = 47;
volatile uint32_t DebounceTimer = 0;

CRGB leds[NUM_LEDS];

void PLbutton() {
  if (millis() - DEBOUNCE_TIME >= DebounceTimer) {
    DebounceTimer = millis();
    flagPL = 1;
  }
}

void MObutton() {
  if (millis() - DEBOUNCE_TIME >= DebounceTimer) {
    DebounceTimer = millis();
    flagMO = 1;
  }
}

void setup() {
  FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
  for (int i = 0; i <= NUM_LEDS; i++) {
    leds[i].setHSV(i * 255 / 60, 255, 255);
    FastLED.show();
    delay(20);
  }
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);
  // Attempt to connect to Wifi network:
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
  }
  configTime(TIMEZONE * 3600L, 0, "pool.ntp.org", "time.nis.gov");
  delay(4000);
  WiFi.disconnect();
  delay(100);

  pinMode(PLPIN, INPUT_PULLUP);
  attachInterrupt(PLPIN, PLbutton, FALLING);
  pinMode(MOPIN, INPUT_PULLUP);
  attachInterrupt(MOPIN, MObutton, FALLING);

  // leds[i].setRGB( 255, 255, 255);
  // leds[i].setHSV( 224, 187, 255);

  FastLED.clear();
}

void loop() {

  getLocalTime(&tmtime);
  hh = &tmtime.tm_hour;
  mmm = &tmtime.tm_min;
  ss = &tmtime.tm_sec;
  if (flagPL == 1) {
    blanc = blanc + 16;
    if (blanc > 255) { blanc = 255; }
    flagPL = 0;
  }
  if (flagMO == 1) {
    blanc = blanc - 16;
    if (blanc < 0) { blanc = 0; }
    flagMO = 0;
  }
  fill_solid(&(leds[0]), 60, CRGB(blanc, blanc, blanc));
  hr = (hh % 12) * 5;
  hr = hr + mmm / 12;
  leds[(hr + 30) % 60].setRGB(255, 0, 0);
  leds[(mmm + 30) % 60].setRGB(0, 255, 0);
  leds[(ss + 30) % 60].setRGB(0, 0, 255);

  FastLED.show();

  delay(100);
}

Hi @joeyjojojrshabadoo. I'm going to ask you to provide some additional information that might help us to identify the problem.


:red_exclamation_mark: This procedure is not intended to solve the problem. The purpose is to gather more information.


Please do this:

  1. When you encounter an error, there should be an error notification at the bottom right corner of the Arduino IDE window. Click the "COPY ERROR MESSAGES" button on that notification.
  2. Open a reply here on this forum topic by clicking the "Reply" button.
  3. Click the <CODE/> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
  4. Press the Ctrl+V keyboard shortcut (Command+V for macOS users).
    This will paste the copied output into the code block.
  5. Move the cursor outside of the code block before you add any additional text to your reply.
  6. Click the "Reply" button to publish the post.

In case the output is longer than the forum software will allow to be added to a post, you can instead save it to a .txt file and then attach that file to a reply here.

Click here for attachment instructions

  1. Open any text editor program.
  2. Paste the copied output into the text editor.
  3. Save the file in .txt format.
  4. Open a reply here on this forum topic by clicking the "Reply" button.
  5. Click the "Upload" icon (Upload icon) on the post composer toolbar:

    The "Open" dialog will open.
  6. Select the .txt file you saved from the "Open" dialog.
  7. Click the "Open" button.
    The dialog will close.
  8. Click the "Reply" button to publish the post.

Alternatively, instead of using the "Upload" icon on the post composer toolbar as described in steps (5) - (7) above, you can simply drag and drop the .txt file onto the post composer field to attach it.

C:\Users\parin\OneDrive\Desktop\LED_Ring_V01\LED_Ring_V01.ino:15:30: error: 'tmtime' declared as reference but not initialized
 struct   getLocalTime(&tmtime);
                              ^
C:\Users\parin\OneDrive\Desktop\LED_Ring_V01\LED_Ring_V01.ino: In function 'void setup()':
C:\Users\parin\OneDrive\Desktop\LED_Ring_V01\LED_Ring_V01.ino:48:3: error: 'WiFi' was not declared in this scope
   WiFi.mode(WIFI_STA);
   ^~~~
C:\Users\parin\OneDrive\Desktop\LED_Ring_V01\LED_Ring_V01.ino:48:13: error: 'WIFI_STA' was not declared in this scope
   WiFi.mode(WIFI_STA);
             ^~~~~~~~
C:\Users\parin\OneDrive\Desktop\LED_Ring_V01\LED_Ring_V01.ino:53:27: error: 'WL_CONNECTED' was not declared in this scope
   while (WiFi.status() != WL_CONNECTED) {
                           ^~~~~~~~~~~~
C:\Users\parin\OneDrive\Desktop\LED_Ring_V01\LED_Ring_V01.ino:53:27: note: suggested alternative: 'FL_DEPRECATED'
   while (WiFi.status() != WL_CONNECTED) {
                           ^~~~~~~~~~~~
                           FL_DEPRECATED
C:\Users\parin\OneDrive\Desktop\LED_Ring_V01\LED_Ring_V01.ino:56:3: error: 'configTime' was not declared in this scope
   configTime(TIMEZONE * 3600L, 0, "pool.ntp.org", "time.nis.gov");
   ^~~~~~~~~~
C:\Users\parin\OneDrive\Desktop\LED_Ring_V01\LED_Ring_V01.ino: In function 'void loop()':
C:\Users\parin\OneDrive\Desktop\LED_Ring_V01\LED_Ring_V01.ino:74:23: error: 'tmtime' declared as reference but not initialized
   getLocalTime(&tmtime);
                       ^
C:\Users\parin\OneDrive\Desktop\LED_Ring_V01\LED_Ring_V01.ino:75:9: error: invalid use of incomplete type 'struct getLocalTime'
   hh = &tmtime.tm_hour;
         ^~~~~~
C:\Users\parin\OneDrive\Desktop\LED_Ring_V01\LED_Ring_V01.ino:15:10: note: forward declaration of 'struct getLocalTime'
 struct   getLocalTime(&tmtime);
          ^~~~~~~~~~~~
C:\Users\parin\OneDrive\Desktop\LED_Ring_V01\LED_Ring_V01.ino:75:9: error: invalid use of incomplete type 'struct getLocalTime'
   hh = &tmtime.tm_hour;
         ^~~~~~
C:\Users\parin\OneDrive\Desktop\LED_Ring_V01\LED_Ring_V01.ino:15:10: note: forward declaration of 'struct getLocalTime'
 struct   getLocalTime(&tmtime);
          ^~~~~~~~~~~~
C:\Users\parin\OneDrive\Desktop\LED_Ring_V01\LED_Ring_V01.ino:76:10: error: invalid use of incomplete type 'struct getLocalTime'
   mmm = &tmtime.tm_min;
          ^~~~~~
C:\Users\parin\OneDrive\Desktop\LED_Ring_V01\LED_Ring_V01.ino:15:10: note: forward declaration of 'struct getLocalTime'
 struct   getLocalTime(&tmtime);
          ^~~~~~~~~~~~
C:\Users\parin\OneDrive\Desktop\LED_Ring_V01\LED_Ring_V01.ino:76:10: error: invalid use of incomplete type 'struct getLocalTime'
   mmm = &tmtime.tm_min;
          ^~~~~~
C:\Users\parin\OneDrive\Desktop\LED_Ring_V01\LED_Ring_V01.ino:15:10: note: forward declaration of 'struct getLocalTime'
 struct   getLocalTime(&tmtime);
          ^~~~~~~~~~~~
C:\Users\parin\OneDrive\Desktop\LED_Ring_V01\LED_Ring_V01.ino:77:9: error: invalid use of incomplete type 'struct getLocalTime'
   ss = &tmtime.tm_sec;
         ^~~~~~
C:\Users\parin\OneDrive\Desktop\LED_Ring_V01\LED_Ring_V01.ino:15:10: note: forward declaration of 'struct getLocalTime'
 struct   getLocalTime(&tmtime);
          ^~~~~~~~~~~~
C:\Users\parin\OneDrive\Desktop\LED_Ring_V01\LED_Ring_V01.ino:77:9: error: invalid use of incomplete type 'struct getLocalTime'
   ss = &tmtime.tm_sec;
         ^~~~~~
C:\Users\parin\OneDrive\Desktop\LED_Ring_V01\LED_Ring_V01.ino:15:10: note: forward declaration of 'struct getLocalTime'
 struct   getLocalTime(&tmtime);
          ^~~~~~~~~~~~
exit status 1

Compilation error: 'tmtime' declared as reference but not initialized

You are missing a WiFi library and a time library. You need to copy more accuratly.

I agree with @sonofcy that it appears you may have either not copied the entirety of the sketch code provided by the clock designer, or perhaps you later broke the code by modifying it.

So go back and get a fresh copy of the original sketch. Hopefully that will solve the problem. If you still have problems, let us know and we'll provide further assistance.

The clues are in the sketch with references to WiFi password and configTime

You don't have the appropriate libraries.

First one you should ask is the designer of the clock.

When you seek for help here, please post ALL information you got. A link to the project, a description of that project and if nothing is online - at least a picture of your project so we can see what you have got.

Hi, @joeyjojojrshabadoo
Welcome to the forum.

Can you please post a link to where you got the code?

Tom.... :smiley: :+1: :coffee: :australia:

What exactly is that. There are many different ESP32 boards.

The code seems outdated.
Most ESP32 boards don't need a time library, because it's already included in the latest core.
NTP for an ESP32 can be done with a single line of code in setup().
See this example sketch.
Post#16 there includes code to wait for a valid NTP update.
Leo..

Hi, @joeyjojojrshabadoo

Can you please post a link to where you purchased your ESP32, and/or a picture?

Tom.... :smiley: :+1: :coffee: :australia: