Implementation of the alternating current reading algorithm on the AVR line

Good morning. First, check if you have implemented the technology that relates to SCT-013-000. An excellent sensor. Tests on the arduino plant. During the tests they showed excellent precision and practicality.
We want to implement this technology in other microcontrollers in the AVR line, but precisely those in the ATTiny family. He found it difficult to apply the algorithm using ATMEL STUDIO 7.0.
In principle, I would like to analyze the operation of the sensor in the ATEMGA 328 and then implement it in other AVRS.
Our configuration for ATMEGA’s ADC is as follows.

01 - ADMUX recorder set for reference voltage in VCC. ADMUX multiplexed for three channels. In principle, three sensors will be used.
02 - Prescaling at 125 KHz (16MHz / 128).
03 - Trigger Source for simple conversion. As the system will be multiplexed, a conversion will begin and end each time.
04 - The DIRD0 register configured for the three inputs on the analog converter. A0, A1 and A2, respectively.
05 - Total samples 125KHz / 13 = 9600 samples.
From the arduino library I got the code snippet:

    for (unsigned int n = 0; n <Number_of_Samples; n ++)
        sampleI = analogRead (inPinI);

        // Digital low pass filter extracts the 2.5 V or 1.65 V dc offset,
        // then subtract this - signal is now centered on 0 counts.
        offsetI = (offsetI + (sampleI-offsetI) / 1024);
        filteredI = sampleI - offsetI;

        // Root-mean-square method current
        // 1) square current values
        sqI = filteredI * filteredI;
        // 2) sum
        sumI + = sqI;

          double I_RATIO = ICAL * ((SupplyVoltage / 1000.0) / (ADC_COUNTS));
          Irms = I_RATIO * sqrt (sumI / Number_of_Samples);

          // Reset accumulators
          sumI = 0;

We are not very familiar with Arduino and would like to understand how these variables work.
Apparently “Number_of_Samples” would be a constant, so it can be defined at the beginning of the program. Regarding the application of the load resistor and other hardware components, we have no doubts. The question is in the code for readPreformatted texting the samples. Thank you very much in advance. If possible an explanation of each variable.

A possibly better source of information, especially as you say you intend to apply this to other AVR-series microcontrollers, would be Atmel’s own Application Note AVR465: Single-Phase Power/Energy Meter with Tamper Detection.

See this based on ATMEL AVR465: Single-Phase Power/Energy Meter.
Some comments on the old forum