SeeedStudio Grove TA12-200 Manual page 10

Electricity sensor
Table of Contents

Advertisement

int sensor_max;
sensor_max = getMaxValue();
Serial.print("sensor_max = ");
Serial.println(sensor_max);
//the VCC on the Grove interface of the sensor is 5v
amplitude_current=(float)sensor_max/1024*5/800*2000000;
effective_value=amplitude_current/1.414;//minimum_current=1/1024*5/800*2000000/1.414=8.6(mA)
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)");
Serial.println(effective_value,1);
}
void pins_init()
{
pinMode(ELECTRICITY_SENSOR, INPUT);
}
/*Function: Sample for 1000ms and get the maximum value from the SIG pin*/
int getMaxValue()
{
int sensorValue;
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;
}
Upload the code, please click
Note: The minimum effective current that can be sensed by the code can be calculated using the
equation below. minimum_current=1/1024*5/800*2000000/1.414=8.6(mA).
Open the serial monitor, The results is as follows:
//Only for sinusoidal alternating current
//value read from the sensor
here
if you do not know how to upload.
7

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the Grove TA12-200 and is the answer not in the manual?

Table of Contents