Arduino GPIO Output to Raspberry Pi Input

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

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

OP's image

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.

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.

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?

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! :astonished:

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.
...
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.

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! :astonished:
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.

Why would a pullup be required if the data were active low? What does that mean? :cold_sweat:

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

Yes ignore my confusion

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