I'm having a problem with the readings I'm getting from a 10K sensor, or rather the processing of it.
When everything is wired up to a Mega2560 the output is fine. Using the Steinhart-Hart conversion to calculate. When I connect everything to the Giga R1 the end result seems to be double the temperature.
I've been trying to read up on analogReadResolution but the link to the page (found here) no longer works. I've tried various things like putting analogReadResolution(10); in the setup or loop after reading this and this.
From this page I gather the resolution for the Giga can be different, but after adding the line to set it to 10 it shouldn't be.
So either I'm doing it wrong, something else wrong, or trying to fix something that isn't broken.
" **The default analogRead() resolution for these boards is 10 bits, for compatibility. You need to use analogReadResolution() to change it to a higher resolution."
I've written a simple sketch to run on the mega and the giga.
When connected to the mega I'm printing to serial temp values from 2 sensors, but also the value of Vo = analogRead(ThermistorPin);
On the mega this prints:
but with this data I'm no closer to understanding the problem. Does the giga have an offset compared to the mega when both are running analogReadResolution(10);?
The mega should run at 10 but the analogReadResolution(); command is not supported so I could not test this with that line in the code for it.
To use this library for ADC applications, you must have a supported Arduino board and include the AdvancedAnalog library in your Arduino sketch. Here is a minimal example:
#include <Arduino_AdvancedAnalog.h>
AdvancedADC adc1(A0);
void setup() {
Serial.begin(9600);
// Initialize ADC with: resolution, sample rate, number of samples per channel, queue depth
if (!adc1.begin(AN_RESOLUTION_16, 16000, 32, 64)) {
Serial.println("Failed to start ADC!");
while (1);
}
}
void loop() {
// Check if an ADC measurement is ready
if (adc1.available()) {
// Get read buffer
SampleBuffer buf = adc1.read();
// Print sample from read buffer
Serial.println(buf[0]);
// Release read buffer
buf.release();
}
}
On the Mega, if you connect a pot from Vcc to GND and set it about halfway you see an ADC reading around 512. If you do the same on the Giga, what do you read?
I am not expecting to see anything. When I found the giga and mega use the same default resolution I was looking for something that would tell me if the giga processes the input differently.
When I run the advanced ADC sketch with AN_RESOLUTION_16, AN_RESOLUTION_12 or AN_RESOLUTION_10 I'm getting the exact same readings as when I use analogReadResolution(x); respectively. The only difference is AN_RESOLUTION_9 does not compile where analogReadResolution(9) does.
The sample_rate, n_samples and n_buffers are variables I don't understand well enough to determine if they are relevant or not. After testing sketch alteration with changed values for these it does not affect the outcome at all.
Let's see, if resolution were 1024 and you read 720, that would be 720 / 1024 * 3.26 = 2.29V, just about 1/2 the 4.56V your program said...?
What was the voltage across the pot?
about 60 seconds after I laid down in bed I think I had an eureka moment. If there is a relation between 1450 and 1024 I'll change the code for the calculation: Change 1023 in R2 = R1 * (1023.0 / (float)Vo - 1.0); to 1444...
Hi, I have a similar problem with reading the values from an accelerometer. All readings are shifted by 1.3V and I do not know why. I tried the same setup with an Arduino Uno R4 and the readings were ok. Maybe there is a reference inside the board which is not well done?
EDIT: I have find this on the cheatsheet of Arduino GIGA