frequency problem--Arduino

Hello all,

Currently, I am working on a project where I need to measure the AC current in my circuit sensed by a current sensor (ACS712).

I want to calculate the average value of this current and also its frequency but I still do not know how?

I researched a function "pulseIn" which calculates the period of the square wave but I do not know how to integrate it into my program, knowing that my signal is sinusoidal.

Here is the code I realized:

void setup() {
Serial.begin(9600);

}

void loop() {

int sensorValue = analogRead(A0);

Serial.println((510 - sensorValue) * 50.00/1023);
delay(250);

}

I am a beginner in programming, so I count on your help, thank you :slight_smile:

Serial.println((510 - sensorValue) * 50.00/1023);

What is this anonymous, magic number, supposed to represent?

I want to calculate the average value of this current and also its frequency but I still do not know how?

Voltage has frequency. Current does not.

PaulS:
Voltage has frequency. Current does not.

What? When I run AC voltage across a resistor does the current magically stay constant? Do you want to try that again?

Hi,

Voltage has frequency. Current does not.

Pardon!!!!

AC voltage across a resistor produces an AC current of the same frequency through the resistor.

Tom.. :slight_smile:

PaulS:

Serial.println((510 - sensorValue) * 50.00/1023);

What is this anonymous, magic number, supposed to represent?

it represents two conversions:

valeur digital---->analog value.

Voltage value---> current value.

The following video explains very well these two conversions, I think you will understand with a video.

In the video, he uses a ACS712 5A, but I use a ACS712 20A that's why the values are not the same.

If you have more ambiguity, please ask me.

Are either of you two going to use a current sensor to measure frequency? Or are you going to measure the frequency of the voltage?

Current has magnitude!

PaulS:
Are either of you two going to use a current sensor to measure frequency? Or are you going to measure the frequency of the voltage?

Current has magnitude!

AC Current has both magnitude AND frequency, exactly like voltage.

Regards,
Ray L.

I want to calculate the frequency of the current?

is it possible to calculate it using "pulsIn"? and if possible, how?

Pulse in would work best if you use a circuit to square up the input waveform.

PaulS:
Are either of you two going to use a current sensor to measure frequency? Or are you going to measure the frequency of the voltage?

Current has magnitude!

Depends on what I had available. Either voltage or current would work fine.