Raspberry Pi UART

Jon_

Member
Ok, so i have spent an afternoon trying to work this out and I am sure I have overlooked something really obvious....but can't see it.

So I have set up tx and rx as said in the Pi wiki.

Then I wrote this python script:

Code:
import serial
import time

port = serial.Serial("/dev/ttyAMA0", baudrate=9600, bytesize=8, parity='N', stopbits=1, timeout=3.0)

while True:
   port.write('9')
   time.sleep(3)
   port.write('5')
   time.sleep(3)
and picaxe has :

Code:
#Picaxe 08M2

Do
  SerIn c.2, T9600_8, b0
  SerTxd( #b0, " " )
Loop
the hardware is a straight connection with the pi with series resistor and everything running on the pi 3.3v supply.

In the terminal window in the picaxe basic program, accessing straight from the picaxe download cable, all i get is 250 printed every 3 seconds....

As i said, I am missing something really obvious as I was expecting to have 9 and 5 printed alternately.
 

srnet

Senior Member
I now get 57 and 53 alternately....which is a step foward
Sounds like its working then.

You should check in a Pi forum, but I suspect that;

port.write('9')

Writes the ASCII character '9' to the terminal which is decimal 57.
 

Jon_

Member
You are quite correct....I have looked at this way to long!

Thank you to you both, you have saved me from myself ;)
 
Top