Quite new to programming so I guess this is easy, but I need help.
I've been developing a project on a UNO device which includes a DS3231 RTC and a LCD module, both connected via the I2C bus.
Things are working well, but the final project is planned to work from a MKR1010.
I've attempted to compile the sketch for the MKR1010 and received errors which I've attributed to the DS3231.H header file.
The header file info says it's compatible with the MKR1010. What I've noticed is if I press the "include" button in the IDE (in the library section, next to the DS3231 library) it only added the following lines to the sketch:
// DS3231 - Version: 1.0.2 #include <Wire.h>
To me this is implying the DS3231 library is incorporated into the Wire.h library.
I'm lost, was making so much good progress with my project, using the square wave output of the DS2321 to hardware interrupt the Arduino, every 0.5s.
Below is an extract of a few relevant lines of code I was using when connected to an UNO.
ianhindle:
I've attempted to compile the sketch for the MKR1010 and received errors which I've attributed to the DS3231.H header file.
When you encounter an error, you'll see a button that looks like two pieces of paper at the top right corner of the black console pane below the Arduino Web Editor's sketch pane. Click that button.
In a forum reply here, click on the reply field.
Click the </> button on the forum toolbar. This will add the forum's code tags markup to your reply.
Press "Ctrl + V". This will paste the error between the code tags.
Move the cursor outside of the code tags before you add any additional text to your reply.
Click the "Post" button./li]
If the text exceeds the forum's 9000 character limit, save it to a .txt file and post it as an attachment. If you click the "Reply" button here, you will see an "Attachments and other settings" link.
ianhindle:
What I've noticed is if I press the "include" button in the IDE (in the library section, next to the DS3231 library) it only added the following lines to the sketch:
// DS3231 - Version: 1.0.2 #include <Wire.h>
To me this is implying the DS3231 library is incorporated into the Wire.h library.
No. It means the author of the library didn't bother to read the documentation to learn how to use the includes field in library.properties:
The DS3231 library is NOT incorporated into the Wire.h library. You need to add this line to your sketch if you want to use the DS3231 library:
#include <DS3231.h>
I submitted a pull request to the DS3231 to fix that bug:
Have followed your instructions. I should have mentioned I'm using the online IDE from a Chromebook.
Thanks for your help
Ian
/home/builder/opt/arduino-builder/arduino-builder -compile -core-api-version 10611 -hardware /home/builder/opt/arduino-builder/hardware -hardware /home/builder/.arduino15/packages -tools /home/builder/opt/arduino-builder/tools -tools /home/builder/.arduino15/packages -built-in-libraries /home/builder/opt/libraries/latest -logger humantags -fqbn arduino:samd:mkrwifi1010 -build-cache /tmp -build-path /tmp/313909984/build -verbose -prefs runtime.tools.CMSIS.path=/home/builder/.arduino15/packages/arduino/tools/CMSIS/4.5.0 -prefs runtime.tools.arc-elf32.path=/home/builder/.arduino15/packages/Intel/tools/arc-elf32/1.6.9+1.0.1 -prefs runtime.tools.openocd.path=/home/builder/.arduino15/packages/arduino/tools/openocd/0.10.0-arduino7 -prefs runtime.tools.bossac.path=/home/builder/.arduino15/packages/arduino/tools/bossac/1.7.0-arduino3 -prefs runtime.tools.x86-linux-gcc.path=/home/builder/.arduino15/packages/arduino/tools/x86-linux-gcc/7.2.0 -prefs runtime.tools.arduinoOTA.path=/home/builder/.arduino15/packages/arduino/tools/arduinoOTA/1.2.1 -prefs runtime.tools.arduino101load.path=/home/builder/.arduino15/packages/Intel/tools/arduino101load/2.0.1 -prefs runtime.tools.i586-poky-linux-uclibc.path=/home/builder/.arduino15/packages/Intel/tools/i586-poky-linux-uclibc/1.6.2+1.0 -prefs runtime.tools.avr-gcc.path=/home/builder/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5 -prefs runtime.tools.avrdude.path=/home/builder/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino8 -prefs runtime.tools.dfu-util.path=/home/builder/.arduino15/packages/arduino/tools/dfu-util/0.9.0-arduino1 -prefs runtime.tools.CMSIS-Atmel.path=/home/builder/.arduino15/packages/arduino/tools/CMSIS-Atmel/1.2.0 -prefs runtime.tools.sketchUploader.path=/home/builder/.arduino15/packages/Intel/tools/sketchUploader/1.6.2+1.0 -prefs runtime.tools.core2-32-poky-linux.path=/home/builder/.arduino15/packages/Intel/tools/core2-32-poky-linux/1.6.2+1.0 -prefs runtime.tools.linuxuploader.path=/home/builder/.arduino15/packages/arduino/tools/linuxuploader/1.5.1 -prefs runtime.tools.nrf5x-cl-tools.path=/home/builder/.arduino15/packages/arduino/tools/nrf5x-cl-tools/9.3.1 -prefs runtime.tools.arm-none-eabi-gcc.path=/home/builder/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4 -prefs runtime.tools.flashpack.path=/home/builder/.arduino15/packages/Intel/tools/flashpack/2.0.0 -prefs runtime.tools.arm-linux-gcc.path=/home/builder/.arduino15/packages/arduino/tools/arm-linux-gcc/4.9.3 -libraries /tmp/313909984/custom -libraries /tmp/313909984/pinned /tmp/313909984/SCADA_Main_003_1010
WARNING: library liquidcrystal_i2c_1_1_2 claims to run on (avr) architecture(s) and may be incompatible with your current board which runs on (samd) architecture(s).
Multiple libraries were found for "DS3231.h"
Used: /tmp/313909984/pinned/ds3231_1_0_2
Not used: /home/builder/opt/libraries/latest/ds3231_1_0_2
Using library Wire at version 1.0 in folder: /home/builder/.arduino15/packages/arduino/hardware/samd/1.8.1/libraries/Wire
Using library liquidcrystal_i2c_1_1_2 at version 1.1.2 in folder: /home/builder/opt/libraries/latest/liquidcrystal_i2c_1_1_2
In file included from /home/builder/.arduino15/packages/arduino/tools/CMSIS-Atmel/1.2.0/CMSIS/Device/ATMEL/samd21/include/samd21.h:69:0,
from /home/builder/.arduino15/packages/arduino/tools/CMSIS-Atmel/1.2.0/CMSIS/Device/ATMEL/samd.h:105,
from /home/builder/.arduino15/packages/arduino/tools/CMSIS-Atmel/1.2.0/CMSIS/Device/ATMEL/sam.h:540,
from /home/builder/.arduino15/packages/arduino/hardware/samd/1.8.1/cores/arduino/Arduino.h:48,
from /tmp/313909984/SCADA_Main_003_1010/SCADA_Main_003_1010.ino:47:
/home/builder/.arduino15/packages/arduino/tools/CMSIS-Atmel/1.2.0/CMSIS/Device/ATMEL/samd21/include/samd21g18a.h:474:27: error: expected ',' or '...' before '(' token
#define PM ((Pm *)0x40000400UL) /**< \brief (PM) APB Base Address */
^
/tmp/313909984/pinned/ds3231_1_0_2/DS3231.h:71:33: note: in expansion of macro 'PM'
byte getHour(bool& h12, bool& PM);
^~
exit status 1
from /tmp/313909984/SCADA_Main_003_1010/SCADA_Main_003_1010.ino:47:
/home/builder/.arduino15/packages/arduino/tools/CMSIS-Atmel/1.2.0/CMSIS/Device/ATMEL/samd21/include/samd21g18a.h:474:27: error: expected ',' or '...' before '(' token
/tmp/313909984/pinned/ds3231_1_0_2/DS3231.h:71:33: note: in expansion of macro 'PM'
byte getHour(bool& h12, bool& PM);
^
The problem is there is a macro named PM defined in the SAMD toolchain that is having a collision with the completely unrelated parameter name used in the DS3231 library's getHour function. Luckily, someone already fixed this problem in the DS3231 library:
Although that fix was included in the 1.0.3 release of the DS3231 library, unfortunately the library author didn't do the release correctly so the 1.0.3 version of the library is not available via the default installation in the online IDE. I submitted a bug report about this:
The solution is to import the 1.0.3 release of the library into the online IDE yourself. I don't have any experience with the Arduino Create app for ChromeOS, so the below instructions are for using the online IDE via the browser and might need to be modified a little for the app, but I think they will still apply fairly well: