How to properly plot an analog signal


Hello everyone, I record a signal from an oscilloscope and from arduino with the following code but they are two completely different graph, any suggestions?

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

void setup() {
  Serial.begin(2000000); // Increased baud rate for faster data transmission
}

void loop() {
  float readValue1 = analogRead(signalPin1);

  float voltage1 = (readValue1 * (5.0 / 1023.0))* 1000; // Convert ADC value to mV


  // Print voltage1 for Serial Plotter
  Serial.println(voltage1);
}

You seem to be missing all negative halves; I guess that you did not lift the signal so it's around the 2.5V. You will also need to limit the result in hardware between 0V and Vcc.

Note:
Arduinos don't like negative voltages on their inputs.

The signal provided is 100Hz and pp 200mV so very small. I am trying to do this to calculate the current provided to a coil following this schematic. I have seen a lot of tutorial on youtube but they cover high AC current amplitude

6de26f35053bd0c02f3619c317391fc3909b9e8c_2_500x298

i am sorry to bother but this is very hard for me to understand, what should i do in practice

buy current measurement clamp like this:
Unbenannt
and connect like this:
Unbenannt

Right, AC is different from DC in many aspects :frowning:

what about simply capacitor coupled to a DC bias. middle one below. may need a resistor divider on left side of cap to limit voltage

cap

And is likely AC, so half above zero and half below. The Arduino clamps the negative side, converts the positive. If you're not careful, the Arduino input will be damaged by the negative portion of that signal, so as others have suggested, you have to add a DC bias to the signal. There are several ways, as they've shown.

thank you I added a dc bias and now is all positive, do i still need to buy this or there is an other way to measure the current?

did you solved your problem?

i still do not have the current measurment, is there an other way to calculate ac current other than with a current measurment clamp?

you wanted similar graph on osci and serial plotter, didn't you?
you say nothing to measurements.

then yes but it was the first step of a bigger problem, should i ask here or open an other post?

change first post, so will new reader not misleaded.

i am not sure if it secure, some one can use voltage divider for AC measurement.

Please don't butcher your opening post; it makes follow up replies useless.

Rather start a new topic as it's actually a very different problem. Provide the schematic as well as the latest version of the code.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.