Newbie needs assistance with Due ADC offset

Hi there

Im using my Arduino DUE analog to digital converter to "Analogread" a voltage out of a seonsr

I modified my Analogrefrence source from 3.3 volt to 2.2

this is my code :

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  
  
  analogReadResolution(10);// Max. 12 Bit for Arduino DUE
  float sensorValue = analogRead(A0);

float voltage = (sensorValue  * (2.5 / 1023.0));//Analogrefrence 2.5  volt

  Serial.println (voltage);
  delay(200) ;


}

the code works correctly !

I figured out that my sensor have about 100 mV Voltageoffset when I try to substrace the offest from my variable "sensorValue" I recive strange values e.g. 980 esc. Can anyone tell me where is my failure ? Thanks in advance !

Maybe you should change the title: ADC .... doesn't work correctly is a poor title choice. Maybe, "Newbie needs assistance with Due ADC offset" or something similarly descriptive of what you really need. Titles that are posted by newbies that imply a fault in the hardware are often overlooked.

Ray

It is the code that does not work that we need to see.

 float voltageOffset= 0.106 ;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  
  
  analogReadResolution(10);// Max. 12 Bit for Arduino DUE
  float sensorValue = analogRead(A0);

float voltage = (sensorValue-voltageOffset  * (2.5 / 1023.0));//Analogrefrence 2.5  volt

  Serial.println (voltage);

980 esc

What does "980 esc" mean?

Post an small table Voltage Read value of what you get. It would help.

Regards.

You are not considering the order of operations. Use brackets to make sure that formular is evaluated in the order you mean it to.

You must subtract your offset after you have converted your reading into a voltage, not before.