Go Down

Topic: ESP8266 NodeMCU hangs up (Read 355 times) previous topic - next topic

wvijay

Hello all
I am building a NTP clock using NodeMCU with WS2812B. I have built the LED array and was testing it before I can get the NTP part included in the sketch. I have just used a count up to display on a 4 - 7 segment type LED strips. The code i guess is understandable even by beginners and novice ( like me as well).

Testing:

I had both the hour tenths and hour unit to work fine, but when i included the Minutes tens and minutes unit digit had a error as mentioned below. I guess its got some thing to do with the boot, and no clue about it. Look forward to your guidance and assistance. Thank you in advance. Keep well and Stay Safe. Regards

The Error message on my Serial Monitor:

 ets Jan  8 2013,rst cause:4, boot mode:(3,6)
wdt reset
load 0x4010f000, len 3456, room 16
tail 0
chksum 0x84
csum 0x84
va5432625
~ld

My Code:

Code: [Select]

#define FASTLED_ESP8266_RAW_PIN_ORDER
#include<ESP8266WiFi.h>
#include <FastLED.h>
#define LED_TYPE WS2812
#define COLOR_ORDER GRB
#define PIN D5
#define NUM_LEDS 44
CRGB leds[NUM_LEDS];
int speedx = 10;
int brightness = 120;
int colors;
int blinkers; int colorval = 195; int briteval = 200;
int i; int j; int z; int l = 0; int ledcount = 0; int segled = 21; int numbers = 0;
int nos = 0; int hourt; int hrt; int hru;
void setup() {
  FastLED.addLeds<WS2812, PIN, GRB>(leds, NUM_LEDS);
  Serial.begin(115200);
}
void loop() {
  doClockDisplay();
  delay(1000);
  if(nos>99){
    nos=0;
  }
}

void doClockDisplay() {
  hrt = nos / 10; // hour tens digit
  hru = nos % 10; // hour unit digit

  for (z = 1; z <= 4; z += 1) {
    if (z == 1) {
      hourt = hrt;
      ledcount = 0;
    }
    if (z == 2) {
      hourt = hru;
      ledcount = ledcount + 22;
    }
/*   
  Serial.print(nos);
  Serial.print("-->");
  Serial.print(hrt);
  Serial.print(":");
  Serial.println(hru);
  Serial.println();
  */
    switch (hourt) {
      case 0:
        // 0
        for (int i = 0 + ledcount; i < 18 + ledcount; i += 1) {
          leds[i] = CHSV( colorval, 255, briteval );
        }
        for (int i = 18 + ledcount; i < 21 + ledcount; i += 1) {
          leds[i] = CHSV(0, 0, 0);
        }
        FastLED.show();
        break;
      case 1:
        // 1
        for (int i = 3 + ledcount; i < 9 + ledcount; i += 1) {
          leds[i] = CHSV( colorval, 255, briteval);
        }
        for (int i = 0 + ledcount; i < 3 + ledcount; i += 1) {
          leds[i] = CHSV( 0, 0, 0);
        }
        for (int i = 9 + ledcount; i < 21 + ledcount; i += 1) {
          leds[i] = CHSV( 0, 0, 0);
        }
        FastLED.show();
        break;
      case 2:
        // 2
        for (int i = 0 + ledcount; i < 6 + ledcount; i += 1) {
          leds[i] = CHSV( colorval, 255, briteval);
        }
        for (int i = 9 + ledcount; i < 15 + ledcount; i += 1) {
          leds[i] = CHSV( colorval, 255, briteval);
        }
        for (int i = 18 + ledcount; i < 21 + ledcount; i += 1) {
          leds[i] = CHSV( colorval, 255, briteval);
        }
        for (int i = 15 + ledcount; i < 18 + ledcount; i += 1) {
          leds[i] = CHSV( 0, 0, 0);
        }
        for (int i = 6 + ledcount; i < 9 + ledcount; i += 1) {
          leds[i] = CHSV( 0, 0, 0);
        }
        FastLED.show();
        break;
      case 3:
        // 3
        for (int i = 0 + ledcount; i < 12 + ledcount; i += 1) {
          leds[i] = CHSV( colorval, 255, briteval);
        }
        for (int i = 18 + ledcount; i < 21 + ledcount; i += 1) {
          leds[i] = CHSV( colorval, 255, briteval);
        }
        for (int i = 12 + ledcount; i < 18 + ledcount; i += 1) {
          leds[i] = CHSV( 0, 0, 0);
        }
        FastLED.show();
        break;
      case 4:
        // 4
        for (int i = 3 + ledcount; i < 9 + ledcount; i += 1) {
          leds[i] = CHSV( colorval, 255, briteval);
        }
        for (int i = 15 + ledcount; i < 21 + ledcount; i += 1) {
          leds[i] = CHSV( colorval, 255, briteval);
        }
        for (int i = 0 + ledcount; i < 3 + ledcount; i += 1) {
          leds[i] = CHSV( 0, 0, 0);
        }
        for (int i = 9 + ledcount; i < 15 + ledcount; i += 1) {
          leds[i] = CHSV( 0, 0, 0);
        }
        FastLED.show();
        break;
      case 5:
        // 5
        for (int i = 0 + ledcount; i < 3 + ledcount; i += 1) {
          leds[i] = CHSV( colorval, 255, briteval);
        }
        for (int i = 6 + ledcount; i < 12 + ledcount; i += 1) {
          leds[i] = CHSV( colorval, 255, briteval);
        }
        for (int i = 15 + ledcount; i < 21 + ledcount; i += 1) {
          leds[i] = CHSV( colorval, 255, briteval);
        }
        for (int i = 3 + ledcount; i < 6 + ledcount; i += 1) {
          leds[i] = CHSV( 0, 0, 0);
        }
        for (int i = 12 + ledcount; i < 15 + ledcount; i += 1) {
          leds[i] = CHSV( 0, 0, 0);
        }
        FastLED.show();
        break;
      case 6:
        // 6
        for (int i = 0 + ledcount; i < 3 + ledcount; i += 1) {
          leds[i] = CHSV( colorval, 255, briteval);
        }
        for (int i = 6 + ledcount; i < 21 + ledcount; i += 1) {
          leds[i] = CHSV( colorval, 255, briteval);
        }
        for (int i = 3 + ledcount; i < 6 + ledcount; i += 1) {
          leds[i] = CHSV( 0, 0, 0);
        }
        FastLED.show();
        break;
      case 7:
        // 7
        for (int i = 0 + ledcount; i < 9 + ledcount; i += 1) {
          leds[i] = CHSV( colorval, 255, briteval);
        }
        for (int i = 9 + ledcount; i < 21 + ledcount; i += 1) {
          leds[i] = CHSV( 0, 0, 0);
        }
        FastLED.show();
        break;
      case 8:
        // 8
        for (int i = 0 + ledcount; i < 21 + ledcount; i += 1) {
          leds[i] = CHSV( colorval, 255, briteval);
        }
        FastLED.show();
        break;
      case 9:
        // 9
        for (int i = 0 + ledcount; i < 12 + ledcount; i += 1) {
          leds[i] = CHSV( colorval, 255, briteval);
        }
        for (int i = 15 + ledcount; i < 21 + ledcount; i += 1) {
          leds[i] = CHSV( colorval, 255, briteval);
        }
        for (int i = 12 + ledcount; i < 15 + ledcount; i += 1) {
          leds[i] = CHSV( 0, 0, 0);
        }
        FastLED.show();
        break;
    }
  }
  nos=nos+1;
}





m_k_akash

to simplify your work on the NTP part use this highly useful NTPClient library which is very helpful
You asked me and I am here

hzrnbgy

The error seems to show wdt reset has caused the reboot

My guess is one of your many for loops is stucked in an infinite loop i.e. the condition is never made false. Maybe one of your counter variable is incremented and decremented at the same time causing the for loop to stay for looping...

wvijay

to simplify your work on the NTP part use this highly useful NTPClient library which is very helpful
Thank you. Yes I am planning to use the NTPClient.

wvijay

The error seems to show wdt reset has caused the reboot

My guess is one of your many for loops is stucked in an infinite loop i.e. the condition is never made false. Maybe one of your counter variable is incremented and decremented at the same time causing the for loop to stay for looping...
Hello,
It was a silly mistake on my side. The error was caused by stack over flow by WS2812b call. I have 21 leds for the each segment + 1 for the decimal point which makes it 22 leds per segment. So we have 4 such segments which accounts for 88 leds. On my declaration I had only declared 44 leds ( 2 segments ) instead on 88 LEDS. Sometimes you are in a hurry to see your project working and land up with such silly errors.  Had no errors and compiled and works fine. Thank you very much for your time. Keep WELL and be SAFE. Regards

Go Up