Arduino Ev ery and Library DS3231_Simple

Hi everyone, I am fairly new to Arduino's so may need a lot of help :slight_smile:

I was using a Nano connected to an DS3231 using the DS3231_Simple library, everything worked fine, as I carried on with my build I needed more interrupt pins so chose to go to the Every, now the example sketch SetDateTime will not load

I get the error

error: expected unqualified-id before numeric constant
static const uint8_t EEPROM_PAGE_SIZE = 32;

Any help would be appreciated

Post your code but read How to get the best out of this forum first and use code tags when you post it

Hi, this is standard code supplied with the DS3231_Simple library, it works fin e on a Nano

I have connected SDA to A4 & SCL tp A5, VCC to 5v & GND to GND

#include <DS3231_Simple.h>

DS3231_Simple Clock;

void setup() {


  Serial.begin(9600);
  Clock.begin();

  Serial.println();
  Serial.println();
}

void loop()
{
  // Create a variable to hold the data
  DateTime MyTimestamp;

  // Load it with the date and time you want to set, for example
  //   Saturday the 3rd of October 2020 at 14:17 and 33 Seconds...
  MyTimestamp.Day    = 3;
  MyTimestamp.Month  = 10;
  MyTimestamp.Year   = 20;
  MyTimestamp.Hour   = 14;
  MyTimestamp.Minute = 17;
  MyTimestamp.Second = 33;

  // Then write it to the clock
  Clock.write(MyTimestamp);

  // And use it, we will read it back for example...
  Serial.print("The time has been set to: ");
  Clock.printTo(Serial);
  Serial.println();

  // Remember, once you set the time, the clock remembers it and keeps
  // running even if you reset or turn off your Arduino, as long as
  // the clock has battery power.

  Serial.print("End Of Program (RESET to run again)");
  while (1);
}

Please post the full error message copied using the "Copy error messages" button in the IDE

Hi, thanks for your help

To make things really simple if I use a blank sketch and just import the lubraryDS3231_Simle it also errors then

Arduino: 1.8.13 (Mac OS X), Board: "Arduino Nano Every, None (ATMEGA4809)"

/Applications/Arduino.app/Contents/Java/arduino-builder -dump-prefs -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -hardware /Users/user/Library/Arduino15/packages -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -tools /Users/user/Library/Arduino15/packages -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/user/Documents/Arduino/libraries -fqbn=arduino:megaavr:nona4809:mode=off -vid-pid=2341_0058 -ide-version=10813 -build-path /var/folders/bl/d4txzrhj2dbbc3g0lj1tv7xr0000gn/T/arduino_build_713803 -warnings=default -build-cache /var/folders/bl/d4txzrhj2dbbc3g0lj1tv7xr0000gn/T/arduino_cache_307377 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=/Users/user/Library/Arduino15/packages/arduino/tools/arduinoOTA/1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=/Users/user/Library/Arduino15/packages/arduino/tools/arduinoOTA/1.3.0 -prefs=runtime.tools.avr-gcc.path=/Users/user/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino5.path=/Users/user/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5 -prefs=runtime.tools.avrdude.path=/Users/user/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=/Users/user/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17 -verbose /var/folders/bl/d4txzrhj2dbbc3g0lj1tv7xr0000gn/T/arduino_modified_sketch_627310/SetDateTime.ino
/Applications/Arduino.app/Contents/Java/arduino-builder -compile -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -hardware /Users/user/Library/Arduino15/packages -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -tools /Users/user/Library/Arduino15/packages -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/user/Documents/Arduino/libraries -fqbn=arduino:megaavr:nona4809:mode=off -vid-pid=2341_0058 -ide-version=10813 -build-path /var/folders/bl/d4txzrhj2dbbc3g0lj1tv7xr0000gn/T/arduino_build_713803 -warnings=default -build-cache /var/folders/bl/d4txzrhj2dbbc3g0lj1tv7xr0000gn/T/arduino_cache_307377 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=/Users/user/Library/Arduino15/packages/arduino/tools/arduinoOTA/1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=/Users/user/Library/Arduino15/packages/arduino/tools/arduinoOTA/1.3.0 -prefs=runtime.tools.avr-gcc.path=/Users/user/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino5.path=/Users/user/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5 -prefs=runtime.tools.avrdude.path=/Users/user/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=/Users/user/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17 -verbose /var/folders/bl/d4txzrhj2dbbc3g0lj1tv7xr0000gn/T/arduino_modified_sketch_627310/SetDateTime.ino
Using board 'nona4809' from platform in folder: /Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6
Using core 'arduino' from platform in folder: /Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6
Detecting libraries used...
/Users/user/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega4809 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_NANO_EVERY -DARDUINO_ARCH_MEGAAVR -DMILLIS_USE_TIMERB3 -DNO_EXTERNAL_I2C_PULLUP -I/Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/cores/arduino/api/deprecated -I/Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/cores/arduino -I/Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/variants/nona4809 /var/folders/bl/d4txzrhj2dbbc3g0lj1tv7xr0000gn/T/arduino_build_713803/sketch/SetDateTime.ino.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
Alternatives for DS3231_Simple.h: [DS3231_Simple-master@1.0.0]
ResolveLibrary(DS3231_Simple.h)
-> candidates: [DS3231_Simple-master@1.0.0]
/Users/user/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega4809 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_NANO_EVERY -DARDUINO_ARCH_MEGAAVR -DMILLIS_USE_TIMERB3 -DNO_EXTERNAL_I2C_PULLUP -I/Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/cores/arduino/api/deprecated -I/Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/cores/arduino -I/Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/variants/nona4809 -I/Users/user/Documents/Arduino/libraries/DS3231_Simple-master /var/folders/bl/d4txzrhj2dbbc3g0lj1tv7xr0000gn/T/arduino_build_713803/sketch/SetDateTime.ino.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
Alternatives for Wire.h: [Wire@1.0]
ResolveLibrary(Wire.h)
-> candidates: [Wire@1.0]
/Users/user/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega4809 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_NANO_EVERY -DARDUINO_ARCH_MEGAAVR -DMILLIS_USE_TIMERB3 -DNO_EXTERNAL_I2C_PULLUP -I/Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/cores/arduino/api/deprecated -I/Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/cores/arduino -I/Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/variants/nona4809 -I/Users/user/Documents/Arduino/libraries/DS3231_Simple-master -I/Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/libraries/Wire/src /var/folders/bl/d4txzrhj2dbbc3g0lj1tv7xr0000gn/T/arduino_build_713803/sketch/SetDateTime.ino.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
/Users/user/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega4809 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_NANO_EVERY -DARDUINO_ARCH_MEGAAVR -DMILLIS_USE_TIMERB3 -DNO_EXTERNAL_I2C_PULLUP -I/Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/cores/arduino/api/deprecated -I/Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/cores/arduino -I/Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/variants/nona4809 -I/Users/user/Documents/Arduino/libraries/DS3231_Simple-master -I/Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/libraries/Wire/src /Users/user/Documents/Arduino/libraries/DS3231_Simple-master/DS3231_Simple.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
/Users/user/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega4809 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_NANO_EVERY -DARDUINO_ARCH_MEGAAVR -DMILLIS_USE_TIMERB3 -DNO_EXTERNAL_I2C_PULLUP -I/Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/cores/arduino/api/deprecated -I/Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/cores/arduino -I/Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/variants/nona4809 -I/Users/user/Documents/Arduino/libraries/DS3231_Simple-master -I/Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/libraries/Wire/src /Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/libraries/Wire/src/Wire.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
/Users/user/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega4809 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_NANO_EVERY -DARDUINO_ARCH_MEGAAVR -DMILLIS_USE_TIMERB3 -DNO_EXTERNAL_I2C_PULLUP -I/Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/cores/arduino/api/deprecated -I/Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/cores/arduino -I/Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/variants/nona4809 -I/Users/user/Documents/Arduino/libraries/DS3231_Simple-master -I/Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/libraries/Wire/src /Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/libraries/Wire/src/utility/twi.c -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
Generating function prototypes...
/Users/user/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega4809 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_NANO_EVERY -DARDUINO_ARCH_MEGAAVR -DMILLIS_USE_TIMERB3 -DNO_EXTERNAL_I2C_PULLUP -I/Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/cores/arduino/api/deprecated -I/Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/cores/arduino -I/Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/variants/nona4809 -I/Users/user/Documents/Arduino/libraries/DS3231_Simple-master -I/Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/libraries/Wire/src /var/folders/bl/d4txzrhj2dbbc3g0lj1tv7xr0000gn/T/arduino_build_713803/sketch/SetDateTime.ino.cpp -o /var/folders/bl/d4txzrhj2dbbc3g0lj1tv7xr0000gn/T/arduino_build_713803/preproc/ctags_target_for_gcc_minus_e.cpp -DARDUINO_LIB_DISCOVERY_PHASE
/Applications/Arduino.app/Contents/Java/tools-builder/ctags/5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives /var/folders/bl/d4txzrhj2dbbc3g0lj1tv7xr0000gn/T/arduino_build_713803/preproc/ctags_target_for_gcc_minus_e.cpp
Compiling sketch...
/Users/user/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/bin/avr-g++ -c -g -Os -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega4809 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_NANO_EVERY -DARDUINO_ARCH_MEGAAVR -DMILLIS_USE_TIMERB3 -DNO_EXTERNAL_I2C_PULLUP -I/Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/cores/arduino/api/deprecated -I/Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/cores/arduino -I/Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/variants/nona4809 -I/Users/user/Documents/Arduino/libraries/DS3231_Simple-master -I/Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/libraries/Wire/src /var/folders/bl/d4txzrhj2dbbc3g0lj1tv7xr0000gn/T/arduino_build_713803/sketch/SetDateTime.ino.cpp -o /var/folders/bl/d4txzrhj2dbbc3g0lj1tv7xr0000gn/T/arduino_build_713803/sketch/SetDateTime.ino.cpp.o
In file included from /Users/user/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/avr/include/avr/io.h:677:0,
from /Users/user/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/avr/include/avr/pgmspace.h:90,
from /Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/cores/arduino/api/String.h:31,
from /Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/cores/arduino/api/Print.h:24,
from /Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/cores/arduino/api/Stream.h:25,
from /Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/cores/arduino/api/Client.h:22,
from /Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/cores/arduino/api/ArduinoAPI.h:29,
from /Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/cores/arduino/Arduino.h:23,
from /var/folders/bl/d4txzrhj2dbbc3g0lj1tv7xr0000gn/T/arduino_build_713803/sketch/SetDateTime.ino.cpp:1:
/Users/user/Documents/Arduino/libraries/DS3231_Simple-master/DS3231_Simple.h:354:27: error: expected unqualified-id before numeric constant
static const uint8_t EEPROM_PAGE_SIZE = 32;
^
/Users/user/Documents/Arduino/libraries/DS3231_Simple-master/DS3231_Simple.h:354:27: error: expected ')' before numeric constant
Using library DS3231_Simple-master at version 1.0.0 in folder: /Users/user/Documents/Arduino/libraries/DS3231_Simple-master
Using library Wire at version 1.0 in folder: /Users/user/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.6/libraries/Wire
exit status 1
Error compiling for board Arduino Nano Every.

You can try my DS323x_Generic Library which supports megaAVR boards such as Nano Every.

I can confirm your issue, and you have run into a fundamental problem with the library you are trying to use, and the architecture of the Atmega4809 which is the controller chip for the Nano Every.

The internal eeprom on the 4809 is divided into pages, where the internal eeprom of the AT328 nano is not. The internal eeprom of the 4809 is managed by something called the Non Volatile Memory Controller(NVMCTRL) which can deal with the pages.

The DS3231 library is designed to work with an i2c external eeprom which also has a page structure. The library uses these declarations in DS3231_Simple.h

static const uint16_t     EEPROM_SIZE_KBIT = 32768;                         // EEPROMs are sized in kilobit
    static const uint8_t      EEPROM_PAGE_SIZE = 32;                            // And have a number of bytes per page
    static const uint16_t     EEPROM_BYTES     = EEPROM_SIZE_KBIT/8;            
    static const uint8_t      EEPROM_PAGES     = EEPROM_BYTES/EEPROM_PAGE_SIZE; 

The EEPEOM_PAGE_SIZE declaration in the library is conflicting with a declaration/definition already used by the ATmega4809's NVMCTRL and the compiler is objecting.

I can't see that the DS3231_Simple library ever does a page write to the external eeprom using EEPROM_PAGE_SIZE , and the most simple fix is to just comment out the line in the .h file.

//static const uint8_t      EEPROM_PAGE_SIZE = 32;

If you don't want to mess with DS3231_Simple.h there are many alternative libraries to chose for the DS3231 and many others to write to an external eeprom. You do not really need a library which integrates the two i2c devices.

Thanks so much what a difference // can make

I have no idea what you said in the thread, only wish that I did, maybe get there one day :slight_smile:

Buy it worked

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.