Moving to Due from Leonardo, anxious newbie, 3.3v advice?

I understand the basic issue: the CPU on the Due is different from the Uno and Leonardo family and takes 3.3v, not 5v. Exposing its pins to 5v can damage the chip.

I understand that when I attach any sensors or devices to the Due, if they are 5v I will have to convert to 3.3v using "level shifters". Or I could power the sensors with 3.3v if they will accept it, and then I wouldn't need to convert/shift.

I understand (vaguely) that level shifters come in three flavours:
(1) plain vanilla, which are good enough to light 5v LEDs and receive signals from 5v sensors;
(2) bidirectional logic level converters, which are capable of protecting the Due when it's connected to 5v serial devices (SPI? RS232?); and
(3) i2c-ready logic level converters which are ... well, I'm not clear on exactly how they are special, something to do with pullups on the i2c bus, but they are what you have to use to connect a Due to a 5v i2c bus and they are bidirectional as well.

If I've got any of this basic info wrong, please correct me!

So, I've got my first Due lit up and running Blinky, and I have a couple of level shifters on the bench ready to go. And I have unanswered questions still.

  1. can I run conventional 5v LEDs off the Due's 3.3v? will they light up, just a little dimmer than they would on 5v? will they present a current draw greater than the Due should try to support? in other words, if I want the Due to drive a bunch of LEDs, must I use a level shifter for all those pins? do I have to use smaller resistor values?

  2. if I have several "i2c rated" level shifter breakouts, is there any reason not to use them generally for any lines that need level shifting, including RS232 or analog signals or even LEDs? in other words, stock just one part?

  3. I'm still not sure about the wiring of these level shifters. Some are labelled with High and Low voltage pinouts and others just say VCC A and VCC B. I worry about connecting one backwards. Should I worry, or do the A/B ones auto-sense voltage and do the right thing?

I ask these fairly stupid questions because this is my first 3.3v gizmo, I don't always understand what data sheets are trying to tell me, and I really don't want to fry a brand new Due; it is the most expensive Arduino in my fleet. I have spares of my other models (Unos and Leos) but Dues are spendy.

I did look for a shield for the Due that would have level shifting built in for all pins (so I could easily use it with all my existing 5v stuff) but could only find one mfr and it was a partial shield, not all the pins. I might still invest in one just to reduce the count of individual shifter breakouts in the project.

Download the datasheet for the processor. I'm not familiar with the Due and did not dig deep into the datasheet.

Q1
You don't need to use level shifters to drive something like a LED. There is also not something like a 5V LED; LEDs have a forward voltage but that is it.

The important parameter to drive something is Ioh (drive e.g. a LED connected between pin and GND, souce) and Iol (drive a LED connected between Vcc and pin, sink). And AVR based processor can sink or source safely 20 mA on a pin (with some other limitations).
1a)
The processor on the Due is less capable from this perspective; I would always use a transistor (or fet) to drive leds on the Due.
1b)
Same applies to the level shifter; they probably also can't handle the current.

Q2 and Q3
I'll leave the real answers for the other question to others as I'm not sure.

Extract from This

Voltage regulator used for 3.3v rail limits the current and allows the maximum of 800ma if external power source is being used. If you draw more current the voltage regulators get heated and temporarily switch off the supply until cooled. However if you power due using USB the USB interface limits the current and allows the maximum of 500ma. If you try to draw more current you might damage the USB port or make it temporarily unavailable. In case of digital out pins you are not supposed to draw more than 130ma, I recommend 100ma.

Extract from This

DC Jack is connected, through a diode, to Vin.
Vin is stepped down to 5V on-board.
5V is stepped down to 3V3 on board.
Thus you can do any one of the following numbered items.
1. Connect a 7-12V supply to the DC Jack; thus:
• use Vin as a supply @ DC - 0.7V for off-board peripherals, and
• use 5V as a supply for off-board peripherals, and
• use 3V3 as a supply for off-board peripherals.
2. Connect a 6-12V supply to Vin; thus:
• use 5V as a supply for off-board peripherals, and
• use 3V3 as a supply for off-board peripherals.
3. Connect 5V supply to the 5V; thus:
• use 3V3 as a supply for off-board peripherals.
The above is only guaranteed for boards that follow the reference schematic, as plenty of clone/compatible boards do. If you buy a cheap Chinarduino and something doesn't work, or the thing breaks, after following anything above then that's your tough luck.

To light up a few LEDs, there is no need for extra hardware (providing LEDs are connected with a resistor ...).

For I2C wiring, if you power an I2C slave with 5V, you can "theoretically" connect SDA/SCL without logic level shifters if pull ups are properly connected to 3.3V, BUT it is safer to add level shifters in case you have a wrong connection somewhere. Bidirectionnal logic level shifters are easy to use are very cheap. Power them with 3.3V on one side and 5V on the other side plus Gnd and you are done:

The board has 2 I2C buses, SDA/SCL with 1K pull ups (to 3.3V) and SDA1/SCL1 without pull-ups.

IMO you won't be able to leverage this board without a carefull reading of the datasheet.

For example sketches, search in the DUE sub forum (PIO, ADC, DAC, PWM, ...)

ard_newbie:
To light up a few LEDs, there is no need for extra hardware (providing LEDs are connected with a resistor ...).

Maybe I did read the datasheet wrong, but with an Ioh of 2 mA I wonder. Does the digitalWrite for a Due allow for the 7 mA by setting PORT.PINCFG.DRVSTR to 1 ?

From table 36-14 (Normal I/O Pins Characteristics)

VDD=1.62V-3V,
PORT.PINCFG.DRVSTR=0 - - 0.70
VDD=3V-3.63V,
PORT.PINCFG.DRVSTR=0 - - 2
VDD=1.62V-3V,
PORT.PINCFG.DRVSTR=1 - - 2
VDD=3V-3.63V,
PORT.PINCFG.DRVSTR=1 - - 7

Electrical characteristics can be found page 1380, Sam3x datasheet, Table 45-2

Yes, of course there is a lot to learn from the datasheet but you can bore yourself to tears and go cross-eyed attempting to decode things, especially as it relates to a specific Arduino pin. Use the better tool for the job, which is the pinout diagram which clearly shows the output capacity of each pin. Study the key in the upper left side for the pin functions and output capabilities.

Thanks all, I'm now even more intimidated by this board! :slight_smile:

I didn't realise it would be this much of a challenge just to figure out the basic connections.

I'm not an EE (as I'm sure you can tell) and find it hard to reach practical conclusions about benchtop do's and don'ts based on reading datasheets (which definitely make me go cross-eyed). I guess I need to keep googling for some tutorials on how to use a Due safely.

I did find that wonderful pinout diagram by Rob Gray and have a paper copy on my bench. It is helpful, but to tell the truth the Uno/Leonardo world has been so easy and forgiving (the gateway drug, as it were) that it is a big new step for me, to start pre-calculating actual current draw and so on before connecting breakouts. Never had to do any real math to build projects with Uno and Leo :slight_smile: you just plug stuff in and it works :slight_smile: [Mostly. I did have to get educated about pull-ups on the i2c bus, but that is about as far as I've been into circuit calculations.]

What I'm hearing is that the Due is "not a toy" and does require some EE skills, so... guess I'd better grit my teeth and face that learning curve.

Welcome on board :slight_smile:

This tutorial might be a starting point:

Thank you everyone! As of this evening, I have my Due hooked up to my Nextion touch screen and am receiving button presses at 9600 baud on Serial1! And no blue smoke!

I read somewhere (Sparkfun probably) that bidirectional logic level shifters can happily serve as unidirectional, so I put an i2c-ready logic level shifter between the Nextion data lines and the Due Serial1 ports 18/19; and everything is working very nicely so far.

The Due is running on a 9v wall wart. It is powering the Nextion off its 5v pin (found next to 3.3v, above the Analog headers).

When I re-consulted the spiffy colour-coded pinout diagram by "Gray Nomad," I had a moment of utter terror. He shows the 5v header pin as a regular "low current" pin rated for only 6mA sink. I hit the off switch for the Nextion instantly :slight_smile:

The Nextion pulls 250 mA! How can this have worked? I then went to the horse's mouth:

https://store.arduino.cc/usa/arduino-due

and read the reassuring table of tech specs, which told me that the max current draw on both 3.3v and 5v pins is actually, whew, 800mA. Does that mean I can pull 1.6a total off the Due's dc converter?

Anyway, here I am with my Nextion talking to a Due, ready to write some more code. Electronics, you see, is just the annoying detail you have to deal with in order to write more code :slight_smile:

Tazling:
Does that mean I can pull 1.6a total off the Due's dc converter?

No

You can draw 800 mA from the 5V pin. The 5V pin also feeds the voltage regulator that produces the 3.3V. So if you draw e.g. 200 mA (this includes the power used by the board itself) from the 3.3V, you will have to deduct that from the 800 mA.

You can look at the schematic.
1)
At the right bottom is the barrel jack (marked X2, power supply) and at the far right of that you see a wire labeled VIN.
2)
Above that is IC5; you will see a wire going to the VIN pin of IC5 and at the left end of that wire you will see a label VIN; this means that the VIN from (1) is connected to the VIN pin of IC5.
3)
At the right hand side of IC5 you will find a wire that is connected to the OUT of IC5; it ends with a little up-arrow with the label +5V.
4)
Above IC5, you will find IC4. A little at the left you will see again a little up arrow labeled +5V and when you follow that wire to the right you will see that it ends in pin 3 (IN) if IC4. Hence IC4 is powered from IC5.

Wires in the schematic are green. IC5 converts the voltage on the barrel jack to 5V and and IC4 converts the 5V voltage to 3.3V.

Admirably clear, thank you for your patience with the under-clued.

Oi! The DUE is great.

Wait till you find you do not even need to use the void loop with freeRTOS or uMT. I use, for the DUE uMT and for the ESP32 freeRTOS.

For figuring out resistances use a site that does ohms law for you.

Pay attention to your sensors, many take 5V but put out or accept 3.3 volts. As an example, I run my metal geared servors with 8V but send the DUE output directly to the servo input. My air pressure sensor takes a 5V input but outputs 3.3 volts.