[Solved] How do I use arrays with a Wemos D1 mini?

Trying this simple piece of code but it keeps crashing. This is the same example of AdvancedTineInput from the widgets example provided in version v0.4.8.
The only additional code is to populate the days selected into and int array for further calculations. I am going to try gdbstub later on when I setup and Linux dev env for troubleshooting this issue.
But till then does anyone know of any similar issue? or any mistakes that I am making.

  Download latest Blynk library here:

  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.

    Downloads, docs, tutorials: http://www.blynk.cc
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Social networks:            http://www.fb.com/blynkapp

  Blynk library is licensed under MIT license
  This example code is in public domain.

  This example runs directly on ESP8266 chip.

  Note: This requires ESP8266 support package:

  Please be sure to select the right ESP8266 module
  in the Tools -> Board menu!

  Change WiFi ssid, pass, and Blynk auth token to run :)
  Feel free to apply it to any other example. It's simple!

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "6ae852cb840f43f494986b226872debf";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "sss";
char pass[] = "ppp";
int days1[6];

void setup()
  // Debug console

  Blynk.begin(auth, ssid, pass);


  TimeInputParam t(param);

  // Process start time

  if (t.hasStartTime())
    Serial.println(String("Start: ") +
                   t.getStartHour() + ":" +
                   t.getStartMinute() + ":" +
  else if (t.isStartSunrise())
    Serial.println("Start at sunrise");
  else if (t.isStartSunset())
    Serial.println("Start at sunset");
    // Do nothing

  // Process stop time

  if (t.hasStopTime())
    Serial.println(String("Stop: ") +
                   t.getStopHour() + ":" +
                   t.getStopMinute() + ":" +
  else if (t.isStopSunrise())
    Serial.println("Stop at sunrise");
  else if (t.isStopSunset())
    Serial.println("Stop at sunset");
    // Do nothing: no stop time was set

  // Process timezone
  // Timezone is already added to start/stop time

  Serial.println(String("Time zone: ") + t.getTZ());

  // Get timezone offset (in seconds)
  Serial.println(String("Time zone offset: ") + t.getTZ_Offset());

  // Process weekdays (1. Mon, 2. Tue, 3. Wed, ...)

  for (int i = 1; i <= 7; i++) 
    Serial.print("Count: ");
    if (t.isWeekdaySelected(i)) 
      Serial.println(String("Day ") + i + " is selected");
      Serial.print("Array insert is: ");
  for(int i=0;i<=6;i++)
    Serial.print ("count: ");
    Serial.print(" ");
   Serial.println("Done printing");  

void loop()
  //Serial.println("Before start"); had added these for debug, commenting out as I  dont want others to get confused that this is the problem
  //Serial.println("After start"); had added these for debug, commenting out as I  dont want others to get confused that this is the problem
Output on the com terminal
Start: 5:5:0
Time zone: America/New_York
Time zone offset: -14400
Count: 1
Count: 2
Count: 3
Day 3 is selected
Array insert is: 2
Count: 4
Day 4 is selected
Array insert is: 3
Count: 5
Count: 6
Count: 7
count: 0 0
count: 1 0
count: 2 1
count: 3 1
count: 4 0
count: 5 0
count: 6 0
Done printing
After start
Before start

Exception (28):
epc1=0x402027dc epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000012 depc=0x00000000

ctx: cont 
sp: 3ffefba0 end: 3ffefdc0 offset: 01a0

3ffefd40:  3ffe8300 00000000 3ffeebc8 402027dc  
3ffefd50:  3fffdad0 00000000 3ffeebc8 402031f7  
3ffefd60:  3ffe8e6c 00000000 3ffefe00 4020444d  
3ffefd70:  3ffe86fc 3ffefe00 3ffefe00 40204478  
3ffefd80:  3ffe834c feefeffe 3ffefe00 3ffeed90  
3ffefd90:  3fffdad0 00000000 3ffefe00 40203420  
3ffefda0:  3fffdad0 00000000 3ffeed88 40204084  
3ffefdb0:  feefeffe feefeffe 3ffeeda0 40100718  

Those print statements are trying to run hundreds of times a second… take them out of the main loop.

@Gunner yeah I know that I added that as a last attempt to find out was it failing before the blynk.run call or after that. I have removed that from the main sketch I use else it floods, so ignore that for now as that was just for debug.

Ignore the “Before start” and “After start” lines for now. I had added them for debug purpose and forgot to remove while pasting the code. I have the same problem with or without these line.

Use the official sketch and that will confirm the bugs are in your code.

@Costas I did use the official sketch and it works fine, I am not saying that the official sketch is not working. I am trying to store and use the value of selected days into an array and its crashing.

Changed the title of the thread so Blynkers know you need assistance with arrays and TimeInput doesn’t crash a WeMos.

I think you are getting me wrong, I know how to use arrays in Blynk and have used it before. I figured out the mistake its my typo that I was overlooking all the time. How do I mark this solved?

Would you like me to change the title to “Help me find typos in my code?”

1 Like

Haha sorry my mistake, can mark it “People asking stupid questions” if that helps :slight_smile: . sometimes it happens that I keep looking at something specific where I think the issue is and ignore the rest of the part. How to mark solved?

I think your declaration int days1[6] is incorrect. This reserves 6 locations indexed from 0 to 5, while your for-loop code tries to manipulate 7 locations indexed from 0 to 6. Try the declaration int days1[7]. Good luck.

1 Like

@omari I think the OP found his bug but it’s nice to see your fix in writing. I think we have all slipped up at some time with arrays :slight_smile: