I apologize for the double post, but I asked this question earlier and somehow it does not appear under my user and I can't make any edit or comments to it: Trouble with UART Serial Communication with Raspberry Pi and Arduino Mega
I'm trying to get the Raspberry Pi to communicate with the arduino and have been following this guide : https://oscarliang.com/raspberry-pi-and-arduino-connected-serial-gpio/
I've followed the instructions for the disabling of getty and using minicom. I've also followed the code in the guide as follows:
void setup() {
Serial.begin(9600);
}
void loop() {
if (Serial.available() > 0) {
int incoming = Serial.read();
Serial.print("character recieved: ");
Serial.println(incoming, DEC);
}
}
From what I understand, when I type a character into the Pi, it will be received by the Arduino and send the ASCII code back. When I uploaded it into the Arduino and booted up minicom without typing anything, there is already output being shown continuously every 1 second or so. When I type into the console it does work and show the corresponding ASCII code, but the arduino seems to be always receiving data. Is this supposed to be the case?
character recieved: 1
character recieved: 1
character recieved: 0
character recieved: 0
character recieved: 0
character recieved: 0
character recieved: 0
character recieved: 2
character recieved: 3
character recieved: 81
character recieved: 3
character recieved: 3
character recieved: 46
character recieved: 32
character recieved: 65 << when I typed a
Using Raspbian GNU/Linux 7 (wheezy) Version 7
uname -a : Linux raspberry pi 3.18.11+ #781 PREEMPT .. armv61 GNU/Linux
Edit: I have checked /boot/cmdline and have commented out as per the guide
dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
Also, sudo grep -R serial /etc/systemd/system does not show anything.
Lastly, I've used a voltage level-shifter as the tutorial suggested, but still the garbage values persist.
Edit 2: I'm starting to think maybe the connections are not correct. Here is a picture of my level-shifter( oops realised I can't post more than 2 links)
Top to Rasp pi (right to left):
Green: Connected to Pin 1
Yellow: Connected to pin 8
Purple: Connected to pin 10
Blue: Connected to Pin 6
Bottom to Arduino(right to left):
Red: Connected to 5V
Yellow: to RX2 pin 17
White: to TX2 pin 16
Black: To GND
/etc/inittab
will be there, systemd was incorporated in Raspbian 8 (jessie).raspi-config
should know the difference and disable the console correctly though.