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
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.