I am trying to measure current from an LFG with Arduino Uno and Grove current sensor (A12-200). I found a code at this link you can see Arduino code here.

The code works, but there are some operations that I don't understand. Let me copy and paste the code here (for further information, please follow the link above).

//  Function: Measure the amplitude current of the alternating current and 
//            the effective current of the sinusoidal alternating current.
//  Hardware: Grove - Electricity Sensor        
//  Date:    Jan 19,2013
//  by www.seeedstudio.com
#define ELECTRICITY_SENSOR A0 // Analog input pin that sensor is attached to

float amplitude_current;               //amplitude current
float effective_value;       //effective current 

void setup() 
void loop() 
    int sensor_max;
    sensor_max = getMaxValue();
    Serial.print("sensor_max = ");
    //the VCC on the Grove interface of the sensor is 5v
                        //Only for sinusoidal alternating current
    Serial.println("The amplitude of the current is(in mA)");
    Serial.println(amplitude_current,1);//Only one number after the decimal point
    Serial.println("The effective value of the current is(in mA)");
void pins_init()
/*Function: Sample for 1000ms and get the maximum value from the SIG pin*/
int getMaxValue()
    int sensorValue;             //value read from the sensor
    int sensorMax = 0;
    uint32_t start_time = millis();
    while((millis()-start_time) < 1000)//sample for 1000ms
        sensorValue = analogRead(ELECTRICITY_SENSOR);
        if (sensorValue > sensorMax) 
            /*record the maximum sensor value*/
            sensorMax = sensorValue;
    return sensorMax;

I don't understand why dividing amplitude_current by 1.414 we'll get effective_current.

And in the function getMaxValue(), I know what it does, but I don't understand why we just need maxvalue.

  • it is a degraded without understanding modified copy-pasted example. btw: the sensor measures to 10 A at 230 V
    – Juraj
    Feb 15, 2018 at 16:12
  • I don't understan what you mean?
    – m1sylla
    Feb 15, 2018 at 16:31

1 Answer 1


You are measuring a sinusoidal "signal" that is alternating in polarity. What the code notes as "effective" current the equivalent DC current for purposes of measuring power consumption. In EE, it's called "RMS" or Root Mean Square, and it's the mathematical derivation to calculate consumed power or current in a situation where the current flows symmetrically back and forth, and thus a time average would give zero.

It's dividing the peak current by the square-root of 2 (1.414).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.