ZXY007o0ePksrW7L
Posts: 10
Joined: Wed Jul 03, 2019 11:46 pm

[SOLVED] Can I connect an arduino directly to GPIO using a 10k ohm resistor?

Wed Jul 10, 2019 6:33 pm

I know this is going to be very hacky. I'll make a proper solution later.

I need to build something with my raspberry pi on short notice, and I determined that it would be less time consuming to interface my Arduino running some of my pre-existing code with my Pi than it would be to port the circuit and the code to use the pi instead. I also determined that it would be easier to use a single-wire GPIO connection to communicate than actually setting up serial, which turned out to be a huge hassle. The arduino outputs 5V, but the pi can only tolerate 3V3. Can I just put a 10k ohm resistor between the arduino and the pi, or do I absolutely have to set up a voltage divider using multiple resistors? If I have to make a voltage divider, what is the acceptable voltage range?
Last edited by ZXY007o0ePksrW7L on Tue Jul 16, 2019 1:51 am, edited 1 time in total.

User avatar
rpdom
Posts: 14757
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Can I connect an arduino directly to GPIO using a 10k ohm resistor?

Wed Jul 10, 2019 6:38 pm

You need a voltage divider. Just a 2k2 to the 5V input and a 3k3 resistor to ground should do.
[edit] Corrected order of resistors.
Last edited by rpdom on Wed Jul 10, 2019 7:20 pm, edited 1 time in total.

User avatar
neilgl
Posts: 648
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near Aston Martin factory

Re: Can I connect an arduino directly to GPIO using a 10k ohm resistor?

Wed Jul 10, 2019 6:49 pm

Yes - probably best to just use 2 resistors..
What Arduino is it? - some are 3V3.
Also what does the existing code do - you could put it on a (say) D1 mini then use mqtt to communicate with the pi / IOT...

ZXY007o0ePksrW7L
Posts: 10
Joined: Wed Jul 03, 2019 11:46 pm

Re: Can I connect an arduino directly to GPIO using a 10k ohm resistor?

Wed Jul 10, 2019 7:15 pm

It's an Uno, and I know for sure it is 5V. The existing code checks an ultrasonic sensor and turns on a pin based on the values.

I'm limited to the resistors I have under my bed. Can I use 4.7k (yellow-purple-red) + 1k (brown-black-red) for a total of 5.7k as my "first resistor" and 10k (brown-black-orange) as my "second resistor"? According to my calculations, that should output 3.2 volts.

drgeoff
Posts: 9615
Joined: Wed Jan 25, 2012 6:39 pm

Re: Can I connect an arduino directly to GPIO using a 10k ohm resistor?

Wed Jul 10, 2019 7:16 pm

rpdom wrote:
Wed Jul 10, 2019 6:38 pm
You need a voltage divider. Just a 3k3 to the 5V input and a 2k2 resistor to ground should do.
It is more usual to have the 2:3 ratio with the '2' to the Arduino output (not the 5 volt rail) and the '3' to ground.

drgeoff
Posts: 9615
Joined: Wed Jan 25, 2012 6:39 pm

Re: Can I connect an arduino directly to GPIO using a 10k ohm resistor?

Wed Jul 10, 2019 7:20 pm

ZXY007o0ePksrW7L wrote:
Wed Jul 10, 2019 7:15 pm
It's an Uno, and I know for sure it is 5V. The existing code checks an ultrasonic sensor and turns on a pin based on the values.

I'm limited to the resistors I have under my bed. Can I use 4.7k (yellow-purple-red) + 1k (brown-black-red) for a total of 5.7k as my "first resistor" and 10k (brown-black-orange) as my "second resistor"? According to my calculations, that should output 3.2 volts.
Yes those resistors will be fine. But you don't really need the 1K. 4.7K and 10K will be OK.

User avatar
rpdom
Posts: 14757
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Can I connect an arduino directly to GPIO using a 10k ohm resistor?

Wed Jul 10, 2019 7:21 pm

drgeoff wrote:
Wed Jul 10, 2019 7:16 pm
rpdom wrote:
Wed Jul 10, 2019 6:38 pm
You need a voltage divider. Just a 3k3 to the 5V input and a 2k2 resistor to ground should do.
It is more usual to have the 2:3 ratio with the '2' to the Arduino output (not the 5 volt rail) and the '3' to ground.
Yes, you are correct. I have corrected my post. Thank you.

User avatar
neilgl
Posts: 648
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near Aston Martin factory

Re: Can I connect an arduino directly to GPIO using a 10k ohm resistor?

Wed Jul 10, 2019 7:39 pm

Depending which ultrasonic sensor it is, you could connect it to the pi e.g. HC-SR04 works fine (with resistors).

ZXY007o0ePksrW7L
Posts: 10
Joined: Wed Jul 03, 2019 11:46 pm

Re: Can I connect an arduino directly to GPIO using a 10k ohm resistor?

Wed Jul 10, 2019 9:15 pm

I'm going to keep the 1k ohm because with just the 4.7k, it will be 3.4V. I read somewhere that the GPIOs can tolerate 4V, but I'm not going to take the chance. The Pi is cheap, but not cheap enough that I would consider it expendable. I read that the activation threshold is 1.8V, so I'd rather have 3.2V and be safe.

My ultrasonic sensor is a Parallax Ping))). Those seem to require very precise timing to get accurate measurements. Is the pi precise enough? Because it is 5V, I would still need the divider for it.

If this forum supports it and I can figure out how, I'm going to mark this as solved.

User avatar
Burngate
Posts: 5936
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: How to change a title

Thu Jul 11, 2019 9:28 am

ZXY007o0ePksrW7L wrote:
Wed Jul 10, 2019 9:15 pm
If this forum supports it and I can figure out how, I'm going to mark this as solved.
Just go to your first post, edit it and change the title - just like I've just done for this post!

Return to “Beginners”