This is for information only - it might help some who were not aware of this mega internal reference voltage and how arduino.h implements it or makes it available. The mega 2560 runs EmonLib perfectly.
It is already implemented in EmonLib.cpp due to the call to arduino.h
I have run Emonlib on a Freetronics Ethermega and the program works fine.
From the Arduino Reference ( http://arduino.cc/en/Reference/AnalogReference?from=Reference.AREF )
Configures the reference voltage used for analog input (i.e. the value used as the top of the input range). The options are:
DEFAULT: the default analog reference of 5 volts (on 5V Arduino boards) or 3.3 volts (on 3.3V Arduino boards)
INTERNAL: an built-in reference, equal to 1.1 volts on the ATmega168 or ATmega328 and 2.56 volts on the ATmega8 (not available on the Arduino Mega) INTERNAL1V1: a built-in 1.1V reference (Arduino Mega only)
INTERNAL2V56: a built-in 2.56V reference (Arduino Mega only)
EXTERNAL: the voltage applied to the AREF pin (0 to 5V only) is used as the reference.
In Arduino.h ( \hardware\arduino\cores\arduino\arduino.h ) IDE V1.0.3 ERW , modified IDE
#if defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
#define DEFAULT 0
#define EXTERNAL 1
#define INTERNAL 2
#else
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644P__)
#define INTERNAL1V1 2 //this is the mega 1.1Volts internal voltage call
#define INTERNAL2V56 3 //and here is the mega 2.56volts internal reference call
#else
#define INTERNAL 3
#endif
#define DEFAULT 1
#define EXTERNAL 0
#endif
Arduino mega internal voltage reference
Submitted by platypus on Sat, 29/06/2013 - 02:55This is for information only - it might help some who were not aware of this mega internal reference voltage and how arduino.h implements it or makes it available. The mega 2560 runs EmonLib perfectly.
It is already implemented in EmonLib.cpp due to the call to arduino.h
I have run Emonlib on a Freetronics Ethermega and the program works fine.
From the Arduino Reference ( http://arduino.cc/en/Reference/AnalogReference?from=Reference.AREF )
Configures the reference voltage used for analog input (i.e. the value used as the top of the input range). The options are:
DEFAULT: the default analog reference of 5 volts (on 5V Arduino boards) or 3.3 volts (on 3.3V Arduino boards)
INTERNAL: an built-in reference, equal to 1.1 volts on the ATmega168 or ATmega328 and 2.56 volts on the ATmega8 (not available on the Arduino Mega)
INTERNAL1V1: a built-in 1.1V reference (Arduino Mega only)
INTERNAL2V56: a built-in 2.56V reference (Arduino Mega only)
EXTERNAL: the voltage applied to the AREF pin (0 to 5V only) is used as the reference.
In Arduino.h ( \hardware\arduino\cores\arduino\arduino.h ) IDE V1.0.3 ERW , modified IDE
#if defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
#define DEFAULT 0
#define EXTERNAL 1
#define INTERNAL 2
#else
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644P__)
#define INTERNAL1V1 2 //this is the mega 1.1Volts internal voltage call
#define INTERNAL2V56 3 //and here is the mega 2.56volts internal reference call
#else
#define INTERNAL 3
#endif
#define DEFAULT 1
#define EXTERNAL 0
#endif