Hello
I have looked at both topics and yes it seems that there is some kind of problem with the internal 3v3 regulator, anyway according to the nordic datasheet what the nrf52840 shield has is not exactly an adc but a saadc (successive approximation adc).
The saadc driver from nordic is very complex but I think that avoiding the oversampling and the burst mode in a nutshell it stores values in a buffer to sample them. So I show every second the average of a set of values read in the adc port with a simple code, apparently in the arduino core mbed library dont do this. I am testing an O2 KE-25 sensor that is quite sensitive and accurate with a range of 0 to just under 80mV for the full range 0 - 100%
It's true that comparing to the no sampled results is much more stable but still the results they gave were still a bit unstable so as they said about the problem with the internal regulator I put an external one and connect via lipo, althought in the arduino's pinout says that 3v3 is an output pin connecting the lipo to this pin through a 3v3 regulator turns it on, so it looks like it can be power like this, after that I connected it with the usb to see the data in the serial, the values came out much better, I had made tests with a 3uF capacitor that offered a little more stable results but with the sampling and the external regulator they come out much better without the need of a capacitor.
Here are the code and the results
simple sampling
/*
Analog Input
*/
#define SAMPLES 500
int sensorPin = A7; // select the input pin for the o2 sensor
int saadcBuffer[SAMPLES]; // variable to store the value coming from the sensor
float voltage = 0;
float average = 0;
int i = 0;
unsigned long int timer = millis();
void setup() {
// Set the analog reference to 3.3V (default)
// analogReference(AR_VDD);
// Set the resolution to 12-bit (0..4095)
analogReadResolution(12); // Can be 8, 10, 12 or 14
Serial.println("Reading O2");
}
void loop() {
// store the read value from the sensor
if (i<SAMPLES)
saadcBuffer[i] = analogRead(sensorPin);
i=i+1;
if (millis() - timer > 1000) {
for (i=0; i<SAMPLES; i++)
average = average + saadcBuffer[i];
average = average / SAMPLES;
voltage = (average * 3300.0F ) / (4096.0F);
Serial.println();
Serial.println("O2 mV: ");
Serial.print(voltage);
Serial.println();
i = 0;
timer = millis();
}
}
Power through usb no sampling and capacitator
O2 mV:
129.71
O2 mV:
125.68
O2 mV:
123.27
O2 mV:
110.38
O2 mV:
114.40
O2 mV:
117.63
O2 mV:
119.24
O2 mV:
93.46
O2 mV:
121.66
O2 mV:
108.76
O2 mV:
111.99
O2 mV:
124.07
O2 mV:
116.82
O2 mV:
121.66
O2 mV:
123.27
O2 mV:
116.02
O2 mV:
107.15
O2 mV:
123.27
O2 mV:
112.79
O2 mV:
93.46
O2 mV:
123.27
O2 mV:
125.68
O2 mV:
122.46
O2 mV:
120.04
Power through usb sampling
O2 mV:
112.34
O2 mV:
112.75
O2 mV:
111.90
O2 mV:
112.50
O2 mV:
111.43
O2 mV:
113.77
O2 mV:
115.36
O2 mV:
114.50
O2 mV:
112.05
O2 mV:
113.71
O2 mV:
113.44
O2 mV:
112.55
O2 mV:
113.25
O2 mV:
112.77
O2 mV:
112.77
O2 mV:
112.74
O2 mV:
113.37
O2 mV:
112.42
Power through lipo no sampling and capacitator
Reading O2
O2 mV:
107.96
O2 mV:
107.96
O2 mV:
110.38
O2 mV:
107.96
O2 mV:
111.18
O2 mV:
110.38
O2 mV:
107.15
O2 mV:
106.35
O2 mV:
105.54
O2 mV:
110.38
O2 mV:
108.76
O2 mV:
106.35
O2 mV:
105.54
O2 mV:
107.15
O2 mV:
109.57
O2 mV:
108.76
O2 mV:
109.57
O2 mV:
111.18
O2 mV:
109.57
O2 mV:
107.15
O2 mV:
110.38
O2 mV:
110.38
O2 mV:
107.15
O2 mV:
107.96
Power through lipo sampling
O2 mV:
109.25
O2 mV:
108.92
O2 mV:
109.07
O2 mV:
108.59
O2 mV:
108.65
O2 mV:
108.57
O2 mV:
108.77
O2 mV:
108.65
O2 mV:
108.79
O2 mV:
108.69
O2 mV:
108.91
O2 mV:
108.58
O2 mV:
108.63
O2 mV:
108.63
O2 mV:
108.42
O2 mV:
108.49
O2 mV:
108.60
O2 mV:
108.58
O2 mV:
108.60
O2 mV:
108.81
O2 mV:
108.82
O2 mV:
108.67
O2 mV:
108.44