1

I've been working on this for 4+ hours, and have gotten nowhere.

I have an array of weather conditions, and a number is sent over serial port to indicate which member of the array to print to the LCD.

I'm guessing the problem is in how I'm defining the array. These are my current 2 guesses for how to define it:

String weatherConditions[49] = { "tornado","hurricane","tropical storm","sev tstorms","tstorms","mix rain-snow","mix rain-sleet","mix snow-sleet","freez drizzle","drizzle","freez rain","showers","showers","snow flur","lt snow show","blowing snow","snow","hail","sleet","dust","foggy","haze","smoky","blustery","windy","cold","cloudy","mostly cloud","mostly cloud","part cloud","part cloud","clear","sunny","fair","fair","mix rain-hail","hot","isol tstorms","scat tstorms","scat tstorms","scat showers","heavy snow","scat snowshow","heavy snow","part cloudy","tshowers","snow showers","isol tshowers","not available" };

or:

char weatherConditions[49][16] = { "tornado","hurricane","tropical storm","sev tstorms","tstorms","mix rain-snow","mix rain-sleet","mix snow-sleet","freez drizzle","drizzle","freez rain","showers","showers","snow flur","lt snow show","blowing snow","snow","hail","sleet","dust","foggy","haze","smoky","blustery","windy","cold","cloudy","mostly cloud","mostly cloud","part cloud","part cloud","clear","sunny","fair","fair","mix rain-hail","hot","isol tstorms","scat tstorms","scat tstorms","scat showers","heavy snow","scat snowshow","heavy snow","part cloudy","tshowers","snow showers","isol tshowers","not available" };

I've tried many other ways of defining the array (including "char* weatherConditions"), but I'm sure most of them were just ignorant guesses.

Later in the code I have this to display a member of the array:

lcd.clear();
lcd.setCursor(0, 0);
lcd.print(weatherTodayHigh);lcd.print("/");lcd.print(weatherTodayLow);lcd.print(" ");lcd.print(weatherConditions[weatherCurrentConditionsCode]);
lcd.setCursor(0, 1);
lcd.print(weatherTomorrowHigh);lcd.print("/");lcd.print(weatherTomorrowLow);lcd.print(" ");lcd.print(weatherConditions[weatherTomorrowConditionsCode);
break;

Everything I try ends up causing nothing to be printed on the 1602 LCD display (I have 15 other scrollable "screens" that are displaying just fine on the LCD). The earlier text on this screen (the highs and lows for today and tomorrow) is displaying fine, but after that, where the weather condition text is supposed to be shown, there is nothing.

I'm able to easily display the same weather condition text on the serial monitor (for that I was using "String weatherConditions[49] = {..." and then "Serial.println(weatherConditions[currentValue]);").

How can I get members of a text array to be printed on the LCD?

  • 1
    Sounds like you're out of SRAM. – Ignacio Vazquez-Abrams Oct 30 '15 at 2:50
  • That's very possible. I'm so glad you mentioned it. The IDE was giving me warnings about low RAM whenever I uploaded. I've never seen that before. I'll take a closer look at it tomorrow. – Jerry Oct 30 '15 at 4:49
1

Ignacio hit the nail on the head. Once I moved the weatherConditions array to EEPROM, the sketch worked perfectly. Also the IDE stopped giving me errors about low RAM.

  • 1
    Try using const char weatherConditions[49][16] or PROGMEM. Those might be more convenient than using EEPROM. – Gerben Oct 30 '15 at 13:43
  • Does const char not use SRAM? I thought I read that it does? I was deciding between PROGMEM and EEPROM (both of which I'm not fluent with), and I happened to find a nice short EEPROM code for storing and reading strings. It ended up to be way easier than I would've thought, so i stuck with that. Maybe I'll post the code in my answer because it might be helpful for others who stumble upon this question. – Jerry Oct 30 '15 at 21:51
  • 1
    Adding const doesn't seem to do anything in this case (I think it doesn't optimize when used on arrays). The only downside with EEPROM is, you have to fill the EEPROM with your data before uploading your main program. But use whatever is easiest for you. Best of luck – Gerben Oct 31 '15 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.