Quick Serial Test from Raspberry Pi to Bejouled Ruby

I wanted to do a quick test to see if I could connect a Bejouled Ruby up to the Raspberry Pi and send a serial string.

First, I had to turn the default serial console on the RPi:
1) Edit /etc/inittab and comment out this line:

T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

2) Edit /boot/cmdline.txt and remove the following from the entry:

console=ttyAMA0,115200 kgdboc=ttyAMA0,115200

A quick reboot and now to write a quick python script to receive. First, installed pyserial (sudo apt-get install python-serial), then typed in:

import serial

ser = serial.Serial('/dev/ttyAMA0', 115200, timeout=1)
while 1:
 line = ser.readline()
 if (line != ""):
 print line
ser.close()

and saved it as receive.py

On the Arduino I, I put in a quick sketch like so:

void setup() {
 Serial.begin(115200);
 pinMode(9, OUTPUT);
}

void loop() {
 digitalWrite(9, HIGH);   // set the LED on
 Serial.println("Hello");
 delay(1000);
 digitalWrite(9, LOW);    // set the LED off
 delay(1000);
}

Note, that on the Bejouled Ruby, pin 9 is a LED. That way I have a visual when the string is sent.

I wired the Ruby’s 3.3V pin to the RPi 3.3V pin. Connected GND to GND. Then connected the RPi RX to the Ruby’s TX.

Run the receive.py script and get:

Hello

Hello

Hello

Hello

Sweet!

Also nice to see that the RPi can power a Ruby! (Of course, I’m not using the RF12B module at the moment. That may pull more power than the RPi would like).