Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic sketch works fine when compiled using Arduino 1.0.5 IDE but not when compiled using Visual Micro (Read 4048 times)
Alban
Junior Member
**
Offline


Posts: 26
Location: Holland
Joined: Nov 11th, 2012
sketch works fine when compiled using Arduino 1.0.5 IDE but not when compiled using Visual Micro
Jan 24th, 2017 at 9:27pm
Print Post  
I ran into a peculiar problem that kept me busy for quite some time tonight Sad

I added my Adafruit RTC DS1307 breakout (RTClib from Adafruit) to a project I'm working on and the when I tried to Serial.print the current time it outputted 165:165:85 instead of hh:mm:ss.

When I use the example sketch and upload it using Arduino 1.0.5 (I have a library that isn't compatible with the new Arduino IDE havent tried any versions in between yet) the sketch works fine but when I upload it using Visual Micro I get some errors:

Code
Select All
Compiling 'test' for 'Arduino Mega 2560 or Mega ADK'

test.ino: In function void loop()
Error compiling project sources
Build failed for project 'test'

test.ino: 37: error: 'class DateTime' has no member named 'dayOfTheWeek

test.ino: 53: error: 'TimeSpan' was not declared in this scope 



the complete sketch:
Code (C++)
Select All
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include <Wire.h>
#include "RTClib.h"

RTC_DS1307 rtc;

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

void setup () {
  while (!Serial); // for Leonardo/Micro/Zero

  Serial.begin(57600);
  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }

  if (! rtc.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    // rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
  }
}

void loop () {
    DateTime now = rtc.now();
   
    Serial.print(now.year(), DEC);
    Serial.print('/');
    Serial.print(now.month(), DEC);
    Serial.print('/');
    Serial.print(now.day(), DEC);
    Serial.print(" (");
    Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
    Serial.print(") ");
    Serial.print(now.hour(), DEC);
    Serial.print(':');
    Serial.print(now.minute(), DEC);
    Serial.print(':');
    Serial.print(now.second(), DEC);
    Serial.println();
   
    Serial.print(" since midnight 1/1/1970 = ");
    Serial.print(now.unixtime());
    Serial.print("s = ");
    Serial.print(now.unixtime() / 86400L);
    Serial.println("d");
   
    // calculate a date which is 7 days and 30 seconds into the future
    DateTime future (now + TimeSpan(7,12,30,6));
   
    Serial.print(" now + 7d + 30s: ");
    Serial.print(future.year(), DEC);
    Serial.print('/');
    Serial.print(future.month(), DEC);
    Serial.print('/');
    Serial.print(future.day(), DEC);
    Serial.print(' ');
    Serial.print(future.hour(), DEC);
    Serial.print(':');
    Serial.print(future.minute(), DEC);
    Serial.print(':');
    Serial.print(future.second(), DEC);
    Serial.println();
   
    Serial.println();
    delay(3000);
}
 



I do not need, and didn't use timespan and datetime in my original project so I didn't get any errors in VS. When I reduce the example sketch to:

Code (C++)
Select All
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include <Wire.h>
#include "RTClib.h"

RTC_DS1307 rtc;

char daysOfTheWeek[7][12] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };

void setup() {
	while (!Serial); // for Leonardo/Micro/Zero

	Serial.begin(57600);
	if (!rtc.begin()) {
		Serial.println("Couldn't find RTC");
		while (1);
	}

	if (!rtc.isrunning()) {
		Serial.println("RTC is NOT running!");
		// following line sets the RTC to the date & time this sketch was compiled
		// rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
		// This line sets the RTC with an explicit date & time, for example to set
		// January 21, 2014 at 3am you would call:
		// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
	}
}

void loop() {
	DateTime now = rtc.now();

	Serial.print(now.year(), DEC);
	Serial.print('/');
	Serial.print(now.month(), DEC);
	Serial.print('/');
	Serial.print(now.day(), DEC);
	Serial.print(now.hour(), DEC);
	Serial.print(':');
	Serial.print(now.minute(), DEC);
	Serial.print(':');
	Serial.print(now.second(), DEC);
	Serial.println();

	delay(3000);
}
 


It compiles correctly but the output is completely different than the output when nuploaded using the Arduino IDE:

Code
Select All
2165/165/165165:165:85 



versus

Code
Select All
2017/2/111:49:8 



(I didn't set my RTC to the correct date / time yet)

I hope someone can explain why this difference occurs...

In the meanwhile I'll try to figure out what the highest Arduino IDE version is I can use with all my needed libraries Wink
« Last Edit: Jan 28th, 2017 at 5:15pm by Tim@Visual Micro »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: sketch works fine when compiled using Arduino IDE but not when compiled using Visual Micro
Reply #1 - Jan 24th, 2017 at 9:49pm
Print Post  
Hi,

Thanks for the info.

I suspect that Visual Micro is finding a different RTClib than the arduino ide.

Please switch on vMicro>compiler>verbose and build. Then copy the output into a .txt and email to info[at]visualmicro.com or attach to a post here.

Then open the arduino ide and switch on file>preferences>verbose compile. Then build and copy the output into txt and email or post

Thanks

  
Back to top
IP Logged
 
Alban
Junior Member
**
Offline


Posts: 26
Location: Holland
Joined: Nov 11th, 2012
Re: sketch works fine when compiled using Arduino IDE but not when compiled using Visual Micro
Reply #2 - Jan 24th, 2017 at 10:06pm
Print Post  
you've got mail....
by the way when I use Arduino 1.5.6 in Visual Micro the result is correct.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: sketch works fine when compiled using Arduino IDE but not when compiled using Visual Micro
Reply #3 - Jan 24th, 2017 at 10:15pm
Print Post  
You have an older version of the rtclib installed with arduino 1.0.5 here

F:\Cloud\Box Sync\Arduino\Arduino IDE\arduino-1.0.5\libraries\RTClib

Please delete or move the folder then click "vMicro>General>rescan toolchains and libraries" or restart the ide.

The latest version of the lib you installed is in your "documents\arduino\libraries" folder

Visual Micro should use the one you installed so that is a bug i will look into. The documents\arduino\libraries folder is supposed to take priority.



  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint