ARDUINO onboard 3.3V to 5V biderctional

Hello Folks

I have been working for developing my kind of advanced Arduino board for my school.

As new technology sensors are coming 3.3V compatible, to interface such sensors or actuator I want easy onboard hardware using BSS138 or 2N7000 mosfets.

I want to have some types of suitable switch to just switch between 3.3v or 5V logic lavels of 8 Digital pins of my Atmega328 arduino.

Kindly suggest suitable single chip or switching mechanism or suitable switch.

Thanks & Regards
Deepak
UG Student

I want to have some types of suitable switch to just switch between 3.3v or 5V logic lavels of 8 Digital pins of my Atmega328 arduino.

This is usually handled by running the ATmega328p on either 5V or 3.3V (p.e. Seeedstudio has such boards). Modern boards have an extra logic level pin for the interfacing shields.

I'm not aware of any chips, but there are lots of ready-made 2- and 4-channel level shifter boards out there that use the BSS138 as bidirectional level shifter. Mind that while it's bidirectional, it's not suitable for fast signals. 100 kHz works fine; 400 kHz I2C may still work, but not much more than that.

So you don't want such things integrated on your board. They will seriously hinder SPI for example, that's asking for a different approach. 3.3V on an input is sufficient for a reliable HIGH reading, no need to shift that up. Outputs can be level shifted with a simple voltage divider as well, commonly done with Serial signals.

If all your sensors are 3.3V, consider getting a 3.3V board. Such as the 3.3V Pro Mini, or the ESP8266 or ESP32 based boards. Most 3.3V sensors have breakout boards available that let them interface with a 5V controller as well, shop around.

Put 2 Arduinos on your board, running at 5V and 3.3V and communicating e.g. by SPI.

pylon:
This is usually handled by running the ATmega328p on either 5V or 3.3V (p.e. Seeedstudio has such boards). Modern boards have an extra logic level pin for the interfacing shields.

You are right in one way. buy you may also be aware of decreased frequency of board with decrease in operation voltage of chip.

I want to have conversion facility of some pins of boards rest will be working as earlier.
sometimes we need to work with sensors and actuators from both 3.3v and 5v logic level.
in that case my board will be much helpful for developer.

atmega328p-maximum-frequency-vs-vcc.png

wvmarle:
I'm not aware of any chips, but there are lots of ready-made 2- and 4-channel level shifter boards out there that use the BSS138 as bidirectional level shifter. Mind that while it's bidirectional, it's not suitable for fast signals. 100 kHz works fine; 400 kHz I2C may still work, but not much more than that.

Thanks wvmarle for your useful suggestion.

I am aware of ready made 2-4 channel level shifter available in market. Nowadays I need to use them very frequent while working with 3.3v sensors and bluetooth or serial communication with my rasPi. This increases the burden of additional connections for breakout board.

So I decided to give this inbuilt level shifting option on some of the pins so as to make the testing task easier.

Your kind suggestions how to switch between the levels when required???

Thanks

You apparently miss the point of #2.

How to shift levels, and whether you even need to switch levels in the first place (a 3.3V signal is read just fine by most 5V MCUs), depends on the signal in question. There is no one all end all solution to level shifting. At least not before you can come up with a bidirectional level shifter that costs as much as a BSS138 and two resistors, and which can handle signals at 10 MHz.

The easiest is of course to switch to 3.3V Arduinos, and run everything at 3.3V. But then you may run into issues with certain sensors that need 5V...

engineerdk:
You are right in one way. buy you may also be aware of decreased frequency of board with decrease in operation voltage of chip.

8 MHz is for the vast majority of projects still more than enough. The only project I intentionally run at the maximum allowed 20 MHz (it's an ATtiny84a, by the way) is because of timing, for which I'm counting clock cycles. For precision I like to have at least 100 clock cycles for a measurement, so at 20 MHz you can get a lot higher counts.

wvmarle:
How to shift levels, and whether you even need to switch levels in the first place (a 3.3V signal is read just fine by most 5V MCUs), depends on the signal in question. There is no one all end all solution to level shifting.

I mainly need this shifter while communicating Arduino Due or cortex based board serially, to that I have to connect external level shifter breakout board.

this inbuilt level shifting will be useful while using arduino with Raspberry pi and Controlling Bluetooth and esp with arduino.

Are you looking for something like this:
https://www.ti.com/product/TXB0108?utm_source=google&utm_medium=cpc&utm_campaign=hval-null-null-gpn_en-cpc-pf-google-wwe&utm_content=txb0108&ds_k=TXB0108&dcm=yes&gclid=EAIaIQobChMIsYXXxpnC5gIVx0XVCh3M2gMlEAAYASAAEgKUbfD_BwE&gclsrc=aw.ds

This and other similar chips like them are also available in breakout boards.
For example:
https://www.amazon.com/s?k=8+channel+logic+level+converter&gclid=EAIaIQobChMI8J6RqJrC5gIVB9bACh2KFAB-EAAYAiAAEgIEf_D_BwE&hvadid=338572226836&hvdev=c&hvlocphy=9026791&hvnetw=g&hvpos=1t2&hvqmt=b&hvrand=47093176663938801&hvtargid=aud-837686656069%3Akwd-389853172720&hydadcr=19163_9664563&tag=googhydr-20&ref=pd_sl_7uvo1k46mz_b

I have used this type of device to interface a 3v processor to a 5v LCD.
The 8 channel level shifter was for the 8 bi-directional data lines.
The LCD control line signals from the processor to the LCD didn't need this since they were one way from the 3v processor to the 5v LCD and the 5v LCD could be controlled using 3v logic level signals.

If the LCD was used in output only mode (only receiving data), then level shifting would not need to be done since the 5v LCD could read the 3v processor signals. It is the other way around that is the issue.
Since the LCD data lines were bi-directional, it has to shifted down from 5v to 3v signals when the 3v processor reads from the 5v LCD since the 5v LCD drives the data lines with 5v signals.

--- bill

Another alternative is to use a 3v processor but make sure that the pins are 5v input tolerant.
Some 3v Arduino modules do this, and some processors like the pic32 have this built into the processor.

--- bill

bperrybap:
Are you looking for something like this:
TXB0108 data sheet, product information and support | TI.com

--- bill

Many thanks bperrybap

Yeah I was looking for this exactly. But the thing I am taking time is how much frequency this shifter IC supports, will SPI at 10MHz work with this perfectly?

I my board I want to give user the facility to select whether to select between 3.3v or 5v logic for respective pins out of 8 in which this functionality available. please give your suggestion, what will be most suitable switch type for users?

Thanks & Regards
Deepak

Use analog switches (4053...) to select 5V or 3.3V pins.

engineerdk:
I my board I want to give user the facility to select whether to select between 3.3v or 5v logic for respective pins out of 8 in which this functionality available. please give your suggestion, what will be most suitable switch type for users?

I think you need to figure out what you really NEED vs what might be nice to have.
Things like whether the pins are bi-directional or if each individual pin is configurable (vs all 8 being the same) to connect a 5v MCU to either 3v or 5v logic and whether that is done in s/w or in h/w (automatically, or possibly even using jumpers).
These kinds of things can make a big difference in the final solution.

You need to define your requirements and then look at solutions for those requirements.
Just keep in mind that some of possibilities are more complex and costly than others to implement, and that is why you may need to try to limit your requirements to what is really needed vs what might be nice to have.

Another alternative is to simply switch to using 3v processors like espxxx modules and not use 5v AVRs.
They are cheap with gobs of resources and are much faster than the AVRs, they can control most 5v devices that are input only with no additional logic, and can use WiFi for additional communication for things like IoT applications or Home automation.
In terms of i/o pins, esp8266 modules don't have quite as many pins as say an AVR m328 but the esp32 does.

I guess my feeling is that if you are looking at using some kind of level shifting logic, why use 5v AVRs?
Do you really need 5v outputs and the drive capability provided by the AVR?
Why not jump to a 3v processor that offers more horsepower and resources and then do level shifting only if the i/o device needs to drive a signal back to the MCU.

These days, for all my personal projects, I'm using ESP based modules.
Not only do the ESP parts have lots more flash, RAM , and processing horsepower than the AVR but they also can have an on board filesystem for file storage, and don't require using the goofy proprietary AVR PROGMEM stuff for const data which makes tables and doing things like web services much simpler.
For my personal projects, I find that there are many things that are easy to do with ESP parts that are simply not possible with an AVR, particularly for the price point if doing network connectivity.

--- bill

Our dear TO wants pins that can be programmed for 3.3V or 5V levels. No Arduino has such pins, so he continues to ask the same question over and over again, because he is in the wrong forum.

If the answers in this forum are not pleasing you, find a forum for chips made of unobtainium improved by snake oil.

bperrybap:
I think you need to figure out what you really NEED vs what might be nice to have.
Things like whether the pins are bi-directional or if each individual pin is configurable (vs all 8 being the same) to connect a 5v MCU to either 3v or 5v logic and whether that is done in s/w or in h/w (automatically, or possibly even using jumpers).
These kinds of things can make a big difference in the final solution.

Many thanks bperrybap

I will surely improve my skill of putting up things more clearly.
Kindly bear with me, If I have went too wrong.

Currently I have selected TXB0108 for logic shifting and looking for better ways to switch by h/w between the 2 logic level available my board.

I do noticed your advice on esp boards. But for once I want to complete my ongoing project then I will look for ESPs more deeply.

Thanks for your Inputs.

engineerdk:
Currently I have selected TXB0108 for logic shifting and looking for better ways to switch by h/w between the 2 logic level available my board.

What you have described above is a solution not a requirement.
I would encourage you to think more in terms of problem solving.
To solve a problem or set of problems, after you define the problem(s) that needs to be solved,
you can define a set of requirements.
To come up with the requirements, you can break things down into what is needed vs what is desired or nice to have.

This methodology is useful for guiding solution selection as selecting the solution becomes picking from the available options that meets all the needs, with as many of the wants that still meets all the requirements like budget, physical size, and time to market/completion etc...

--- bill