Go Down

Topic: UNO WIFI REV2 ERROR With EmonLib.h (Read 269 times) previous topic - next topic


Please help to solve this issue error compile   EmonLib.h with board UNO WIFI REV2


What issue ?
What code ?
What hardware ?
What circuit ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.


#include "EmonLib.h"                   // Include Emon Library

EnergyMonitor emon1;                   // Create an instance

void setup()

  emon1.current(A0, 111.1);             // Current: input pin, calibration.
void loop()

 double Irms = emon1.calcIrms(1480);  // Calculate Irms only
  Serial.print(Irms*230.0);               // Apparent power

  Serial.print(" ");
  Serial.println(Irms);                       // Irms

Error MSG

C:\Users\ctatong\Documents\Arduino\libraries\EmonLib\EmonLib.cpp: In member function 'long int EnergyMonitor::readVcc()':

C:\Users\ctatong\Documents\Arduino\libraries\EmonLib\EmonLib.cpp:258:3: error: 'ADCSRA' was not declared in this scope

   ADCSRA |= _BV(ADSC);                             // Convert


The error is because the EmonLib library is not compatible with the Uno WiFi Rev2. Despite the name, the Uno WiFi Rev2 uses a different microcontroller than the Uno. This microcontroller is fairly new, with significant differences from the traditional AVR microcontrollers, and has never been used by the Arduino world before the release of the Uno WiFi Rev2. For this reason, you will find that some 3rd party libraries are not compatible with the Uno WiFi Rev2. The support will surely improve over time, but for now you can think of yourself as a pioneer in new territory.

Your options are:
  • Study the datasheet for the Uno WiFi Rev2's ATmega4809 microcontroller and modify the EmonLib code to work with it.
  • Use a board that is already compatible with EmonLib.

Go Up