Questions tagged [analogreadresolution]

analogReadResolution() is an extension of the Analog API for the Arduino Due and Zero.

From Arduino - AnalogReadResolution:

Description

analogReadResolution() is an extension of the Analog API for the Arduino Due and Zero.

Sets the size (in bits) of the value returned by analogRead(). It defaults to 10 bits (returns values between 0-1023) for backward compatibility with AVR based boards.

The Due has 12-bit ADC capabilities that can be accessed by changing the resolution to 12. This will return values from analogRead() between 0 and 4095.

Syntax

analogReadResolution(bits)

Parameters

bits: determines the resolution (in bits) of the value returned by analogRead() function. You can set this 1 and 32. You can set resolutions higher than 12 but values returned by analogRead() will suffer approximation. See the note below for details.

Returns

None.

Note

If you set the analogReadResolution() value to a value higher than your board's capabilities, the Arduino will only report back at its highest resolution padding the extra bits with zeros.

For example: using the Due with analogReadResolution(16) will give you an approximated 16-bit number with the first 12 bits containing the real ADC reading and the last 4 bits padded with zeros.

If you set the analogReadResolution() value to a value lower than your board's capabilities, the extra least significant bits read from the ADC will be discarded.

Using a 16 bit resolution (or any resolution higher than actual hardware capabilities) allows you to write sketches that automatically handle devices with a higher resolution ADC when these become available on future boards without changing a line of code.

Example

void setup() {
  // open a serial connection
  Serial.begin(9600); 
}

void loop() { // read the input on A0 at default resolution (10 bits) // and send it out the serial connection analogReadResolution(10); Serial.print("ADC 10-bit (default) : "); Serial.print(analogRead(A0));

// change the resolution to 12 bits and read A0 analogReadResolution(12); Serial.print(", 12-bit : "); Serial.print(analogRead(A0));

// change the resolution to 16 bits and read A0 analogReadResolution(16); Serial.print(", 16-bit : "); Serial.print(analogRead(A0));

// change the resolution to 8 bits and read A0 analogReadResolution(8); Serial.print(", 8-bit : "); Serial.println(analogRead(A0));

// a little delay to not hog serial monitor delay(100); }

12 questions
3
votes
1 answer

micros() resolution for Portenta H7

Is there any way to know the resolution of micros() for the Arduino Portenta H7. I have checked for other boards e.g. Nano which is mentioned as 4 uS. However, I couldn't find one for Portenta H7. Is there any way to measure or look for that
2
votes
1 answer

The analog read is not giving the correct waveform as that of an oscilloscope

I have code that fetches analog input values from terminals A0, A1 and A2 of an Arduino Mega 2560. When I plot the data, it does not give the desired waveform. The desired waveform is also measured with a the digital storage oscilloscope. I was…
2
votes
1 answer

Reading 4-20ma signal on arduino

I want to read a 4-20 mA analog signal from a 24V flowmeter. I've read the simplest way is to convert it into 1-5V signal using a 250 ohm resistor. The thing is I want my reading to be precise so my question is; is there any resolution loss when…
2
votes
2 answers

Lowest voltage applicable on AREF pin on Uno and Mega

I need to measure an Analog signal in the range of 5-30 mV. Naturally, using the internal default 5V reference leads to very poor measurement resolution. I would like to use the capability to use an external reference voltage of 50mV on the AREF pin…
2
votes
2 answers

Can i supply the AREF pin with an Analog pin from the same board?

I guess its a dumb question but couldnt find anything about it online. I know its possible to supply the AREF pin with 3.3 V to increase the ADC resolution. For the project i am working on the analog voltage i will be reading will be between 0 and…
1
vote
0 answers

Connect k-type termocouple using o-amp

first of all I have to say that this is my first Arduino thing. I'm trying to connect a k-type termocouple to my Arduino using an LM2904 Oamp, Yes I know that this is not the best solution but is the only that I have right now due to the pandemic…
efirvida
  • 111
  • 2
1
vote
2 answers

How would I go about measuring an analog signal on my arduino mega that has both positive and negative voltages

I have a signal that fluctuates between -70mV and 50mV. How would I get the arduino to read this.. Ultimately I am trying to graph the data in real time so it looks like this. https://i.sstatic.net/a8zIE.jpg
0
votes
1 answer

Arduino vs 12bit ADC

12bit ADC will give us about 1.2mV per step: 5 / 4096 = 0.00122 But if we give Arduino a 1.2V voltage reference we get 1.1mV per step: 1.2 / 1024 = 0.00117 Does that means Arduino can be more accurate than a 12 bit ADC?
ElectronSurf
  • 814
  • 4
  • 17
  • 43
0
votes
4 answers

How can I seriously calibrate ADC voltage readings with Arduino Nano?

I have been using Arduino Nano Analog input to measure voltages, in the range between 22-30 Volts. I want to measure it down to a tenth of a volt. Following the instructions found here: Read Analog Voltage (www.arduino.cc) Which basically states…
SDsolar
  • 1,175
  • 3
  • 11
  • 35
0
votes
2 answers

Cheapest and easiest Arduino board for 12 bit ADC, thinking of M0

I need an Arduino board for simple ADC, but 10 bits of resolution is sadly not enough. I am going to buy a board with 12 bits of resolution, but really couldnt decide on the exact model. It needs to be easily accessable and wont be used for anything…
0
votes
1 answer

How to interpret analog values sent to Arduino from line scanner?

So I have a line scan camera attached to my Arduino Mega and I'm trying to send it a digital clock impulse and get an analog output back. The line scan camera is supposed to return 128 pixels. So far I've been able to send the impulses and get…
-1
votes
2 answers

Can I use analogReadResolution() on an Uno or Leonardo?

I am trying to get a spectrum analyser up and running. I found the following code on Galileo GEN2 Project - Real-Time Audio Spectrum Analyzer1: /* * * Galileo GEN2 Project - Real-Time Audio Spectrum Analyzer *…