Measure AC Current

Hello everyone, I am trying to measure ac current provided an AC voltage of 400mV at 100hz with an offset of 600 mV to make sure the signal never goes below ground. this is the circuit I am implementing. I can measure Vh clearly with arduino but Vl is only 50 Hz noise.


thank you in advance

int signalPin1 = A0; // Pin where the first signal is connected
int signalPin2 = A1; // Pin where the second signal is connected

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

void loop() {
  int readValue1 = analogRead(signalPin1);
  int readValue2 = analogRead(signalPin2);

  float voltage1 = readValue1 * (5.0 / 1023.0) * 1000; // Convert ADC value to mV
  float voltage2 = readValue2 * (5.0 / 1023.0) * 1000; // Convert ADC value to mV
  float drop = voltage1 - voltage2; // Voltage drop in mV

  // Calculate current assuming the shunt resistor is 10 ohms
  float current = drop / 10.0; // Current in mA

  // Print current value for Serial Plotter
  Serial.println(voltage2);

  delay(10); // Sampling interval, adjust as needed (100 samples per second)
}

Sorry, I don't understand your schematic.

Could you please upload a photograph of the circuit you've built? Maybe that helps to figure out what you're doing.

What is the frequency of the AC you're trying to measure? What's the value of R in your diagram?

@bene64, you did forget to mention that you did lift the signal. It's important for those that try to help else the first reply will be that you can not measure AC as you do.

You should have added that in your schematic ! As well as other details that became clear in your other topic. It would have saved @rsmls the time to ask the questions.

i lifted the signal just adding a dc offset, I thought this was an option
Signal: Aplitude 1V, frequency 100Hz, offset 600 mV.
R = 10 Ohm


here is shown the sense of the current where the cirlce is the resistance

here the componetns
orange resistance, red voltage supply, black voltage negative pin, yellow A1 in the code, blue A0 in the code

What were you expecting it to be?

Maybe you could look into how to properly draw a schematic, e.g. here: https://www.youtube.com/watch?app=desktop&v=pMIEZwaybWI&ab_channel=learnelectronics
In the process, you will likely run into a number of gaps in your understanding of electronics, which I'd recommend you study one by one.

I'm asking because the photos don't clarify all that much, I'ma fraid. I do recognize that you're the same person struggling with the soldering and the probably destroyed sensor in another thread.

Do you have the GND connection of the coil circuit connected to the Arduino GND in any place?

I wan expecting a reduction in aplidude since is after a resistance but the same characteristics in frequeancy as the powering voltage (100hz)

That would depend on the DC resistance of the coil

Whatever appears on Vl will also appear on Vh plus the I x R voltage

no the ground connection of the two is separate, i was actually thinking if I should link them or it would alter the measurment

exactly, so knowing R, I was hoping to measure I, but on Vl I just sense noise looking through an oscilloscope

Vl is the voltage across the coil, it may well be 50Hz noise but as I said it will also appear on Vh. So the voltage across the resistor will be Vh-Vl and the noise will cancel out.

Thanks; much better schematic.

You should if you intend to do the measurement as you indicated in the revised schematic. The Arduino needs to have the same ground reference as the measured circuit. You may in fact damage the Arduino if you fail to connect the GNDs together.

Thank you!
this is my updated schematics


I am providing the following voltage +-400mV with an offset of 500mV to have all the range positive

with the probe in the location showed by the schematics i read this signal
+-100mV with an offset of 280mV.
there is a huge difference even if i should be measuring the imput signal

And with aduino i am reading a singal +- 90 with an offset of 230mV


i am so confused

image

Looks fairly close. I agree it's off a bit, but your dodgy wiring/soldering probably accounts for part of that.

The main thing you're probably running into now is that you're likely feeding the signal generator into an impedance that's lower than what it's designed for, resulting in a lower output than anticipated. If you disconnect the signal generator from your circuit and measure it directly with your scope, is the output correct?


the offset is off but the aplitude is almost correct
then i proceded to measure the output of the A1 pin and this is the result

up to 3 V ...

If you're measuring a 100Hz signal, you'll have to sample at at least twice that frequency. I'd sample much more often in fact because you likely have all manner of noise that will throw you a curve ball.

Having said that, the problem with your A1 pin is likely that it's not really connected to anything. The oscillating readings suggest a floating input. Could be one of the dodgy connections in your circuit.

PS: why did you delete the waveform generator settings from the thread as well as the earlier scope photograph? It doesn't really help if you start removing critical information left and right. I was about to look into the waveform as sampled on your scope, but you removed it. Could you please put it back in?

1 Like