adding more board options to emonlib

In emonlib.cpp this code selects and pins the board to only the 328P

//#if defined(ARDUINO) && ARDUINO >= 100

#include "Arduino.h"

//#else

//#include "WProgram.h"

#endif

Even when this following line was added for the ethermega (2560), the compiler still gave an error

#if defined (__AVR_ATmega328P__) || defined (__AVR_ATmega2560__)

How can I add the 2560?l

 

Robert Wall's picture

Re: adding more board options to emonlib

You are talking about EnergyMonitor::readVcc( ) ?

It would appear that you have a very old EmonLib there. The current version has many more processors defined and a note in the comments that might help:

// Without this the function always returns -1 on the ATmega2560

platypus's picture

Re: adding more board options to emonlib

WProgram.h is used in versions 23 and less while Arduino.h is used from ver1.0 and >

i found the reason that the program would not compile was in the simple naming of a variable - changing from short form to a longer name fixed the issue and it finished compiling.

After this it also compiled for the 1280 etc

I have also posted in 'Hardware' about using the mega and how Arduino.h defines a number of processors which I see have been redefined in the ReadVcc() - seems it is doubling up on definitions.

Even with my 'older version of ReadVcc() there are no issues with compiling or using the mega, 1280 etc, so I wonder why the additions were made in ReadVcc() to define the extra boards.

Robert Wall's picture

Re: adding more board options to emonlib

"Submitted by platypus on Fri, 28/06/2013 - 09:37

In emonlib.cpp this code selects and pins the board to only the 328P

//#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
//#else
//#include "WProgram.h"
#endif

Even when this following line was added for the ethermega (2560), the compiler still gave an error

#if defined (__AVR_ATmega328P__) || defined (__AVR_ATmega2560__)

How can I add the 2560?l"

How do you expect anyone to guess from what you wrote above that the real problem was elsewhere in your sketch? I think you need to learn how to (a) interpret compiler error messages, and (b) give enough accurate information to allow people to help you.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.