Click here for a free subscription to "HDE" our site newsletter.

Serial Voltage Level Converter - Arduino

 
Serial Voltage Level Converter - Arduino


How to use a 5v FTDI adapter with a 3.3v microcontroller

5v to 3.3v serial voltage level converter

It had to happen sooner or later. I needed a low power microcontroller for a project so I headed over to Amazon to look for a 3.3v Arduino Pro Mini compatible board. It was pretty easy to find so popped one into my shopping cart together with an FTDI adapter so that I could talk to the serial port on the Pro Mini. The Pro Mini doesn't have one on board. Job done I thought... until they arrived.

Not wanting to blow up my Pro Mini I checked the FTDI board only to realize that I had bought a 5v unit and not a 3.3v version. I felt stupid for not checking the listing properly before ordering but I was stuck with it and no time to wait for an alternative to arrive. This project needed doing and it needed doing now!

So I decided to use a simple level converter using a few resistors. Thinking that this might not be the only time that such a little circuit might come in handy I thought that I would build it onto a little piece of copper stripboard to make it easier to use. The board couldn't be simpler. Three resistors and a couple of cuts in the copper traces.

Before we start soldering components indiscriminately onto the board it would be a good idea to first do a little design work. The problem splits into two parts. First there is the 5v Tx driving a 3.3v input and there is also the 3.3v Tx driving a 5v input in the opposite direction.

We will deal with the 5v TX from the FTDI adapter driving the 3.3v microcontroller input first. The microcontroller input will register a '0' if the voltage is below 0.5v and it will register a '1' if the input voltage is greater than 2.4v. The output from the FTDI adapter is 0v and 5v for '0' and '1' respectively. We don't have to worry about the '0' case because the Tx output is 0v-5v so a '0' is going to be 0v whatever happens.

When the FTDI adapter transmits a '1' it sends its output to 5v. What we need to do is reduce this voltage to somewhere between 2.4v and 3.3v. We can do this with a simple potential divider circuit consisting of two resistors connected in series.

In the circuit below this potential divider is made up of R1 and R2. The 5v signal is connected to the top of the first resistor R1 and the junction of the resistors is connected to the 3.3v Rx input. The output to the Rx pin can be calculated from:

(R2/(R1 + R2)) * 5v.
(1.8/2.8) * 5 = 3.2v

Perfect! Now for the microcontroller Tx to the FTDI Rx. The Tx signal this time is 0v-3.3v and everything between 2.7v and 5v will be seen as a logic '1'. So technically there is nothing that needs to be done here because the signal is compatible. I have elected to connect the pins with a 330Ω resistor to limit the current just in case I get the lines crossed. Hopefully the circuits will survive if I do this by mistake.

Level converter circuit diagram Serial voltage converter 5v-3.3v

So that's the circuit designed. Now to build it on a piece of copper stripboard. The layout of the board is shown below with the component side up and the copper strips on the underside of the board. I used 3 right-angle pins for the 5v side of the circuit and 3 pin sockets at the 3.3v end. This suited the microcontroller circuit that I was building but you can terminate the board to your own requirements.

Voltage converter stripoard layout Board layout for the voltage converter

Remember that the components are shown on the top side of the board with the copper strips underneath. The copper strips must be cut on the underside of the board underneath the 1kΩ and 330Ω resistors as shown by the circles. The 1.8kΩ resistor is mounted standing up because there wasn't roon to lie it down.

And that's all there is to it. In my tests the board worked like a dream at speeds all the way up to 115200 baud. It should go even faster but I haven't tried it.


 
Serial Voltage Level Converter - Arduino


Now subscribe to our newsletter and don't miss a thing
 



Comments

No comments yet.

Add Comment

* Required information
(will not be published)
 
Bold Italic Underline Strike Superscript Subscript Code PHP Code Quote Insert line Bullet list Numeric list Link Email Image Video
 
Smile Sad Huh Laugh Mad Tongue Crying Grin Wink Scared Cool Sleep Blush Unsure Shocked
Captcha
Refresh
 
Enter code:
 
Notify me of new comments via email.
 
Remember my form details on this computer.
 
I have read and understand the privacy policy. *
 
I have read and agree to the terms and conditions. *
 
Click here for a free subscription to "HDE" our site newsletter.