Go Down

Topic: Arduino GPIO Output to Raspberry Pi Input (Read 132 times) previous topic - next topic

rferder

Hi all

I'm using a Wemos D1 mini and a HC-SR04 Ultrasonic sensor to detect object proximity.
The Wemos outputs HIGH or LOW to a digital pin if the object is within or out of range

I need to take this output (3.3v) from the Wemos and use it as an input on the Rasberry GPIO

I have found a 6N138 optocoupler that I believe is adequate
https://www.onsemi.com/pub/Collateral/HCPL2731-D.PDF


From my calculations, the emitter operates at 1.3v @ 1.6mA

3.3v-1.3v=2v

2/0.0016=1250 Ohm

I have used this to obtain a resistor value of 1.5K

I would also like the raspberry pi input to be pulled down to ground to avoid floating values.


Have I calculated correctly and is my schematic correct?



Many thanks

sterretje

If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

SteveMann

If you are only going FROM the Wemos TO the Raspberry, then you can connect the GPIO pins together. 3.3v is more than enough for the Raspberry to see as a high. Use external pullups on the Wemos end if you are using an active low.  If you are going from the Pi to the Wemos, then you would need a level shifter because the Wemos can't tolerate 5V on the GPIO pins.

I am usually so far out of the box that most people don't know what I am talking about.

Please do not ask for help by PM. I will not respond.
If you need help, post a question on the appropriate forum.

rferder

If you are only going FROM the Wemos TO the Raspberry, then you can connect the GPIO pins together. 3.3v is more than enough for the Raspberry to see as a high. Use external pullups on the Wemos end if you are using an active low.  If you are going from the Pi to the Wemos, then you would need a level shifter because the Wemos can't tolerate 5V on the GPIO pins.


That would be much easier. 
I'm going from the Wemos to the Pi

What sort of resistor value should I be using for the pullup? Am I understanding correctly that the wemos outputs are inverted?

Paul__B

A 10k series resistor between the two to protect from "phantom powering".

Why would you want a pull-up?

Why would WeMOS outputs be "inverted"?  They output whatever the code tells them to!  :smiley-eek:

If you are only going FROM the Wemos TO the Raspberry, then you can connect the GPIO pins together. 3.3v is more than enough for the Raspberry to see as a high.
...
If you are going from the Pi to the Wemos, then you would need a level shifter because the Wemos can't tolerate 5V on the GPIO pins.
Am I wrong?  I thought a Raspberry Pi was all 3.3 V logic.

SteveMann

A 10k series resistor between the two to protect from "phantom powering".

Why would you want a pull-up?

Why would WeMOS outputs be "inverted"?  They output whatever the code tells them to!  :smiley-eek:
Am I wrong?  I thought a Raspberry Pi was all 3.3 V logic.

You are right- I only use the RPi to run a Mosquitto broker and no I/O experience. So, then the OP can just connect the Pi GPIO pins directly to the Wemos pins through a 10K resistor as you suggest.  The pullup would be required if the data were active low, and my caution was that the pullup should be to 3.3V on the Wemos. Which is moot since the RPi GPIO is also 3V3.
I am usually so far out of the box that most people don't know what I am talking about.

Please do not ask for help by PM. I will not respond.
If you need help, post a question on the appropriate forum.

Paul__B

Why would a pullup be required if the data were active low?  What does that mean?  :smiley-roll-sweat:

Are you confusing yourself with open-collector logic?  :smiley-lol:  You have to code in a special way to generate that!

rferder

Yes ignore my confusion

10k resistor working great. Nice and simple. The is all for your inputs. Pun intended

Go Up