Arduino uno wifi rev 2 pin outs compared to Arduino uno rev 3

[URGENT]
Hello,

I am new to the arduino world and I am experiencing a problem when I am trying to do some current/voltage measurements with my arduino. I am using the following library (emonlib):

When I run this on arduino uno rev 3, it works perfectly (getting the data from the ADC registers) however when I run it on the arduino uno wifi rev 2 I get the following error:

Arduino: 1.8.13 Hourly Build 2020/02/19 04:12 (Mac OS X), Board: "Arduino Uno WiFi Rev2, None (ATMEGA4809)"

/Users/omarsaid/Documents/Arduino/libraries/EmonLib-master/EmonLib.cpp: In member function 'long int EnergyMonitor::readVcc()':
/Users/omarsaid/Documents/Arduino/libraries/EmonLib-master/EmonLib.cpp:251:3: error: 'ADCSRA' was not declared in this scope
   ADCSRA |= _BV(ADSC);                             // Convert
   ^~~~~~
/Users/omarsaid/Documents/Arduino/libraries/EmonLib-master/EmonLib.cpp:251:3: note: suggested alternative: 'ADC_t'
   ADCSRA |= _BV(ADSC);                             // Convert
   ^~~~~~
   ADC_t
In file included from /Users/omarsaid/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/avr/include/avr/io.h:99:0,
                 from /Users/omarsaid/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/avr/include/avr/pgmspace.h:90,
                 from /Users/omarsaid/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.5/cores/arduino/api/String.h:30,
                 from /Users/omarsaid/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.5/cores/arduino/api/Print.h:24,
                 from /Users/omarsaid/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.5/cores/arduino/api/Stream.h:25,
                 from /Users/omarsaid/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.5/cores/arduino/api/Client.h:22,
                 from /Users/omarsaid/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.5/cores/arduino/api/ArduinoAPI.h:29,
                 from /Users/omarsaid/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.5/cores/arduino/Arduino.h:23,
                 from /Users/omarsaid/Documents/Arduino/libraries/EmonLib-master/EmonLib.h:15,
                 from /Users/omarsaid/Documents/Arduino/libraries/EmonLib-master/EmonLib.cpp:13:
/Users/omarsaid/Documents/Arduino/libraries/EmonLib-master/EmonLib.cpp:251:17: error: 'ADSC' was not declared in this scope
   ADCSRA |= _BV(ADSC);                             // Convert
                 ^
/Users/omarsaid/Documents/Arduino/libraries/EmonLib-master/EmonLib.cpp:251:17: note: suggested alternative: 'ADC0'
/Users/omarsaid/Documents/Arduino/libraries/EmonLib-master/EmonLib.cpp:253:12: error: 'ADCL' was not declared in this scope
   result = ADCL;
            ^~~~
/Users/omarsaid/Documents/Arduino/libraries/EmonLib-master/EmonLib.cpp:253:12: note: suggested alternative: 'ADC0'
   result = ADCL;
            ^~~~
            ADC0
/Users/omarsaid/Documents/Arduino/libraries/EmonLib-master/EmonLib.cpp:254:13: error: 'ADCH' was not declared in this scope
   result |= ADCH<<8;
             ^~~~
/Users/omarsaid/Documents/Arduino/libraries/EmonLib-master/EmonLib.cpp:254:13: note: suggested alternative: 'ADC0'
   result |= ADCH<<8;
             ^~~~
             ADC0
exit status 1
Error compiling for board Arduino Uno WiFi Rev2.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

I have tried changing to the suggested changes but it didnt work. I am not sure how to map the pins from the rev 3 to the wifi rev 2. I have attached the cpp file for emonlib, I would greatly appreciate it if you can give me some sort of help that can progress this. The script I am running is the following:

#include "EmonLib.h"             // Include Emon Library
#define VOLT_CAL 128.5
EnergyMonitor emon1;             // Create an instance

void setup()
{  
  Serial.begin(115200);
  emon1.current(0, 30);               // Initialize emon library for current
  emon1.voltage(1, VOLT_CAL, 1.7);  // Voltage: input pin, calibration, phase_shift
}

void loop()
{

  float amps = emon1.calcIrms(1480);   // Calculate Irms only

  emon1.calcVI(20,2000);  // Calculate all. No.of half wavelengths (crossings), time-out
  float supplyVoltage   = emon1.Vrms;   //extract Vrms into Variable
  Serial.println(supplyVoltage);        //print the voltage reading
  Serial.println(amps);            //print the current reading
  Serial.println(supplyVoltage*amps);            //print the power usage
  
}

EmonLib-master.zip (18.8 KB)

Your board is not supported by this library. The Arduino UNO WiFi Rev.2 is completely different to an Arduino UNO Rev.3 (despite it's name, a very bad naming decision of Arduino LLC). It uses another processor with another architecture.

The only routine that seems to be problematic is readVcc(), which simply measures how accurate the the voltage regulator works by comparing it to the internal reference voltage.

I don't know the megaAVR4809 (processor of the UNO WiFi Rev.2) very well, but it seems it doesn't offer a functionality to measure the Vcc voltage. You might fall back as the original developer does for ARM based boards: return a constant value.

Can you supply me a way of reading the analog values from certain ports.

You mean other than analogRead()?