Montag, 11. August 2014

Arduino and the Time.h library error

Hey,

so you wanna use your Arduino with the time library and get the
"error: variable ‘monthNames_P’ must be const in order to be put into read-only section by means of [...]"
message?
No problem! Open your Time-library folder ( f.e. ~/sketchbook/libraries/Time ) and edit the DateStrings.cpp - or just type in the terminal:
nano ~/sketchbook/libraries/Time/DateStrings.cpp
Replace the following lines:
41: PGM_P monthNames_P[] PROGMEM =
58: PGM_P dayNames_P[] PROGMEM =
59: char dayShortNames_P[] PROGMEM = 

with
41: PGM_P const PROGMEM monthNames_P[] =
58: PGM_P const PROGMEM dayNames_P[] =59: const char dayShortNames_P[] PROGMEM =

save, and your sketch should compile without the error above :-)

Good luck!