ADC on the Arduino Due

Hey everyone!

I recently bought an Arduino Due, thinking it has 16 analog inputs (that's what the official Arduino page says, at least), and when I tried to compile a project that uses A15, it failed. What am I doing wrong here? The site clearly says 16 inputs...!

It seems like the last 4 ADC pins aren't labeled as A12-A15, instead, they are the DAC0/1 and CAN RX/TX pins:


Pieter

Should I try to analogRead() from the DAC? Sounds a little stupid... lol

Looking at the datasheet, it looks like the official pinout is wrong.
The other ADC inputs are pins 20, 21 and 52. The 16th ADC channel is connected to an internal temperature sensor, not an actual pin, so the "16 analog input pins" on the product page is incorrect as well.

From what I can gather the official Due's, both v1 and v2 pin out only 12 ADC lines.

The chips for both have 16 channels, and some 3rd-party boards like the Seeed one
bring them all out.

The silk-screening on the boards is definitive. That pinout diagram is bogus.

MarkT:
From what I can gather the official Due's, both v1 and v2 pin out only 12 ADC lines.

If the schematic is to be believed, it brings out all 15 ADC lines, AD8/AD9 are connected to pins 20/21 (PB12/PB13, SDA0-3/SCL0-3) and A14 is connected to pin 52 (PB21, RXD3).

From the SAM3X datasheet §43.4, p.1319:

Note 1. AD15 is not an actual pin but is connected to a temperature sensor.

Either way, both the pinout diagram and the technical specs on the product page are wrong. Any idea where to report this?

The DUE Core (arduino DUE 100% compatible board) has all Sam3x pins broken out:

DUE CORE

Note that since ADC channel 15 is the internal temperature sensor, it remains 15 ADC channels (ADC ch0 to ADC ch 14) for your own inputs.

The most relevant pinout diagram is the one provided by Graynomad. You will find this pinout in the DUE sub forum.

PieterP:
Looking at the datasheet, it looks like the official pinout is wrong.
The other ADC inputs are pins 20, 21 and 52. The 16th ADC channel is connected to an internal temperature sensor, not an actual pin, so the "16 analog input pins" on the product page is incorrect as well.

So how do I analogRead() from them? This very moment I tried to write analogRead(20) and it didn't do anything....

(deleted)

Of course, I did something with it. I used the reading as a parameter for another function to display it on a SPI display using Ucglib made by olikraus.

(deleted)

I have a huge project with multiple files, it's gonna be pretty hard to follow everything... but I worked really hard on this and I think I can count on myself to do SOMETHING with the reading, unless I'm just extremely dumb...

Also,I tried to just print it to the serial monitor and it says "0" all the time. Something is wrong here.

(deleted)

Is there anything I can do to make it work?

Maybe the analogRead() arduino function has not been designed to read pin 20 of the DUE.

There are lots of example sketches to read ADC conversions with registers in the DUE sub section of this forum. Moreover, you will find several hints to improve ADC conversions accuracy.

ard_newbie:
There are lots of example sketches to read ADC conversions with registers in the DUE sub section of this forum.

Interesting, I will try to find what the hell is going on there. I gotta say, Arduino screwed up big time when they didn't document the ADC correctly...

You'll have to edit the analogRead source code to enable these pins in software:
Add more switch cases here:

Add the ADC channels AD8,AD9 and AD14 for the correct pins (see my previous reply), add them to the second NO_ADC column.

The meaning of the different fields in that array is here: