Arduino + Raspberry Pi connection through 3.3 and relay?
Posted: Wed May 18, 2016 9:37 am
Hi
I asked a while ago on how to connect an arduino and a raspberry pi together, so that a button press on the Arduino would result in a file playback on the RPi.
The answers I got on this matter was that the Uno and the RPi could not directly be connected together because the HIGH signal on a RPi is just 3.3V and the HIGH on the Arduino is 5V.
So that would not work, and I've tried finding voltage levelers in Norway but I could not find any that would suit my purpose, so I am left ordering from China.
Thing is, I really need this to work before I receive this parcel. I tried connecting ARduino to RPi on USB and it worked to some extent, the problem is they are going to be a little farther away so I think wireing would be better.
Now here is my idea:
Could I wire the Uno and the RPi together on 5V supply(connect the Arduino to a regulated 5V supply through the UNO's 5v port. They would then also share ground on this 5V power supply.
THEN, how about I also add a relay which I have lying around (One channel 5V relay for Arduino) to the loop in this manner:
Vcc - To 5V regulated along with Uno and RPi
Gnd - Obviously to GND
Signal - to random Arduino digital pin.
And,
C(common) to Arduino 3.3V port
NO to RPi GPIO pin?
Would this then work the way I want it to?
If I code the RPi something like this?
The reason I can't just use the RPi as my main console is that there are numerous other things connected to the Arduino, like a LCD display etc. etc. etc.
What do you think? Is it possible?
I asked a while ago on how to connect an arduino and a raspberry pi together, so that a button press on the Arduino would result in a file playback on the RPi.
The answers I got on this matter was that the Uno and the RPi could not directly be connected together because the HIGH signal on a RPi is just 3.3V and the HIGH on the Arduino is 5V.
So that would not work, and I've tried finding voltage levelers in Norway but I could not find any that would suit my purpose, so I am left ordering from China.
Thing is, I really need this to work before I receive this parcel. I tried connecting ARduino to RPi on USB and it worked to some extent, the problem is they are going to be a little farther away so I think wireing would be better.
Now here is my idea:
Could I wire the Uno and the RPi together on 5V supply(connect the Arduino to a regulated 5V supply through the UNO's 5v port. They would then also share ground on this 5V power supply.
THEN, how about I also add a relay which I have lying around (One channel 5V relay for Arduino) to the loop in this manner:
Vcc - To 5V regulated along with Uno and RPi
Gnd - Obviously to GND
Signal - to random Arduino digital pin.
And,
C(common) to Arduino 3.3V port
NO to RPi GPIO pin?
Would this then work the way I want it to?
If I code the RPi something like this?
Code: Select all
import pygame.mixer
from time import sleep
import RPi.GPIO as GPIO
from sys import exit
GPIO.setmode(GPIO.BCM)
GPIO.setup(4, GPIO.IN)
pygame.mixer.init(48000, -16, 1, 1024)
snd = pygame.mixer.Sound("game.wav")
soundChannelA = pygame.mixer.Channel(1)
while True:
try:
if (GPIO.input(4) == True):
soundChannelA.play(sndA)
What do you think? Is it possible?