Thank you guys, this is my simple setup.
The battery is 2x 18650 = 8,4V
I'm aware of the possibility of averaging the analogRead() results. But i want to clean the noise with hardware first as good as possible.
The components i used are these :
Step Down Converter
Voltage Divider 5x
Code:
void setup() {
Serial.begin(9600);
pinMode(A3, INPUT);
}
void loop() {
int V = analogRead(A3);
Serial.print(V);
Serial.print(",");
delay(500);
}
Results without anything plugged in A3 :
321, 213, 273, 215, 189, 275, 178, 207, 258, 247, 216, 209, 21 2, 247, 233, 150, 187, 250, 267, 226, 246, 184, 219, 173, 225, 184, 143, 142, 173, 218, 214, 109, 227, 170, 201, 201, 161, 119,
174, 170, 176, 174, 166, 152, 133, 113, 151, 147, 199, 177, 20 3, 158, 193, 120, 104, 196, 113, 192, 159, 229, 232, 209, 147, 202, 214, 209, 222, 218, 199, 167, 190, 268, 237, 286, 228, 219,
208, 259, 258, 248, 220, 246, 238, 248, 278, 247, 259, 251, 25 5, 233, 204, 242, 258, 299, 318, 249, 302, 238, 295, 249, 236, 284, 246, 250, 218, 267, 290, 228, 295, 183, 245, 269, 285, 296,
253, 279, 224, 277, 217, 247, 220, 282, 291, 265, 239, 271, 27 6, 267, 260, 259, 250, 240, 212, 281, 266, 240, 274, 230, 279, 264, 322, 236, 261, 272, 259, 290, 264, 303, 300, 283, 225, 257,
250, 272, 215, 289, 241, 254, 222, 229, 211, 259, 225, 258, 24 1, 265, 218, 222, 290, 199, 298, 288, 255, 282, 261, 224, 215, 221, 284, 292, 240
Results with Battery plugged in Divider and then in A3 :
497, 497, 493, 492, 493, 498, 493, 498, 495, 495, 493, 496, 49 7, 494, 497, 496, 496, 496, 493, 494, 497, 495, 496, 497, 497, 497, 494, 497, 495, 497, 494, 498, 492, 493, 492, 496, 497, 497,
492, 494, 496, 494, 498, 498, 494, 493, 493, 497, 493, 494, 49 7, 493, 497, 496, 493, 497, 494, 492, 496, 495, 496, 497, 495, 496, 495, 495, 496, 498, 492, 493, 497, 496, 496, 492, 491, 494,
496, 493, 495, 498, 496, 497, 496, 495, 496, 494, 497, 495, 49 7, 494, 495, 496, 496, 495, 496, 493, 494, 493, 498, 497, 496, 493, 492, 491, 493, 495, 495, 493, 492, 496, 496, 495, 491, 496,
495, 497, 496, 497, 496, 498, 496, 496, 498, 494, 497, 497, 49 5, 496, 496, 496, 492, 496, 492, 494, 496, 496, 497, 496, 493, 496, 494, 497, 497, 496, 497, 497, 498, 493, 495, 497, 492, 497,
496, 495, 495, 496, 498, 498, 492, 498, 491, 494, 497, 494, 49 2, 492, 494, 492, 492, 492, 497, 498, 496, 497, 496, 491, 494, 496, 496, 498, 494, 491, 496, 496, 494, 497, 496, 495, 492, 494
Code:
void setup() {
Serial.begin(9600);
pinMode(A3, INPUT);
delay(3000);
}
int maxi = 0;
int mini = 1023;
void loop() {
int V = analogRead(A3);
if (V > maxi) { maxi = V; SP(); }
if (V < mini) { mini = V; SP(); }
}
void SP() {
Serial.print(maxi);
Serial.print(",");
Serial.println(mini);
}
Min,Max-Results with Battery plugged in Divider and then in A3 (without delay after 10minutes):
493, 1023
493, 493
493, 490
493, 488
495, 488
498, 488
498, 487
498, 486
499, 486
499, 485
525, 485
526, 485
526, 484
Thanks!