ChaseCrom
Posts: 3
Joined: Tue Mar 31, 2020 10:17 pm
Location: SouthEast Colorado

Arduino Serial Connection via GPIO and Level Shifter

Tue Mar 31, 2020 10:24 pm

How can I connect a Pi Zero W to an Arduino (Nano in my case) for serial communication using the GPIO pins? I know I need a level shifter, and I have a 74AHCT125 - Quad Level-Shifter (3V to 5V) but I don't understand what connections need to be made through the shifter and what config changes I need to make on the Pi. Googling and looking around hasn't revealed anything useful. I know USB can be used, and I currently do that for development but I don't have room in the enclosure for a big USB cable and OTG adapter.

User avatar
DougieLawson
Posts: 38883
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Arduino Serial Connection via GPIO and Level Shifter

Wed Apr 01, 2020 9:26 am

What's stopping you from connecting the Arduino's USB to the Raspberry's USB? No level shifting needed for that.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

scotty101
Posts: 3958
Joined: Fri Jun 08, 2012 6:03 pm

Re: Arduino Serial Connection via GPIO and Level Shifter

Wed Apr 01, 2020 10:32 am

DougieLawson wrote:
Wed Apr 01, 2020 9:26 am
What's stopping you from connecting the Arduino's USB to the Raspberry's USB? No level shifting needed for that.
ChaseCrom wrote:
Tue Mar 31, 2020 10:24 pm
I know USB can be used, and I currently do that for development but I don't have room in the enclosure for a big USB cable and OTG adapter.
Seems clear. :D
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

User avatar
DougieLawson
Posts: 38883
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Arduino Serial Connection via GPIO and Level Shifter

Wed Apr 01, 2020 12:39 pm

scotty101 wrote:
Wed Apr 01, 2020 10:32 am
DougieLawson wrote:
Wed Apr 01, 2020 9:26 am
What's stopping you from connecting the Arduino's USB to the Raspberry's USB? No level shifting needed for that.
ChaseCrom wrote:
Tue Mar 31, 2020 10:24 pm
I know USB can be used, and I currently do that for development but I don't have room in the enclosure for a big USB cable and OTG adapter.
Seems clear. :D
Get a craft knife and trim the USB plugs to fit. Get a dremel and trim the case to fit. That's going to be easier than trying to reliably connect more than one GPIO with a voltage shifter.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

User avatar
penguintutor
Posts: 386
Joined: Tue May 08, 2012 9:11 am
Location: UK
Contact: Website

Re: Arduino Serial Connection via GPIO and Level Shifter

Thu Apr 02, 2020 6:40 pm

I believe that chip only works one-way, but for serial you will need a bidirectional level-shifter

The following from Adafruit sounds like it should work

https://www.adafruit.com/product/757

Here's a guide to configuring serial on the Raspberry Pi.

https://elinux.org/RPi_Serial_Connection

ChaseCrom
Posts: 3
Joined: Tue Mar 31, 2020 10:17 pm
Location: SouthEast Colorado

Re: Arduino Serial Connection via GPIO and Level Shifter

Fri Apr 03, 2020 10:00 pm

DougieLawson wrote:
Wed Apr 01, 2020 12:39 pm
scotty101 wrote:
Wed Apr 01, 2020 10:32 am
DougieLawson wrote:
Wed Apr 01, 2020 9:26 am
What's stopping you from connecting the Arduino's USB to the Raspberry's USB? No level shifting needed for that.
ChaseCrom wrote:
Tue Mar 31, 2020 10:24 pm
I know USB can be used, and I currently do that for development but I don't have room in the enclosure for a big USB cable and OTG adapter.
Seems clear. :D
Get a craft knife and trim the USB plugs to fit. Get a dremel and trim the case to fit. That's going to be easier than trying to reliably connect more than one GPIO with a voltage shifter.
It's not that simple. Part of the appeal of the Zero W is that it's small. A USB OTG adapter, even one of the tiny ones, plus even a small USB cable takes up a lot of room in any kind of an enclosure. I'm 3D Printing a custom enclosure, so modifying the enclosure isn't the primary issue; the physical form factor I need is the issue.

ChaseCrom
Posts: 3
Joined: Tue Mar 31, 2020 10:17 pm
Location: SouthEast Colorado

Re: Arduino Serial Connection via GPIO and Level Shifter

Fri Apr 03, 2020 10:03 pm

penguintutor wrote:
Thu Apr 02, 2020 6:40 pm
I believe that chip only works one-way, but for serial you will need a bidirectional level-shifter

The following from Adafruit sounds like it should work

https://www.adafruit.com/product/757

Here's a guide to configuring serial on the Raspberry Pi.

https://elinux.org/RPi_Serial_Connection
I experimented around a little and you're correct. I wound up getting the Sparkfun Bi-Directional Level Shifter - same board as you linked, just with a red PCB from Sparkfun. Adafruit isn't currently shipping orders because they've shifted to helping COVID mitigation efforts. The beauty of living in Colorado is that Sparkfun orders are always basically overnight.
https://www.sparkfun.com/products/12009

Return to “Interfacing (DSI, CSI, I2C, etc.)”