Connected using jumper wires:
• Sensor’s TX to PIN 10(UART) on the Pi
• Sensor’s GND to PIN 6(GND) on the Pi
• Sensor’s +5 to PIN 1(3.3V) on the Pi
I commented out the last line of the fle /etc/inittab as suggested in other forum posts
I also edited /boot/cmdline.txt as suggested in other forum posts removing the below line:#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
Then I installed PySerial and wrote this test.py scriptconsole=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1
Here’s what I get when I run the script.
Code: Select all
import serial serialPort=serial.Serial("/dev/ttyAMA0", 9600, timeout=2, stopbits=1, parity='N' ) x =0 while x != 10: print("start of attempt #"+ str(x)) x=x+1 if serialPort.isOpen()== False: serialPort.open() else: pass y= serialPort.read(8) print(y) print("end")
It looks like I am getting some kind of input, since I only see the gibberish at times when I wave my hand in front of the sensor. Otherwise I get nothing.Python 2.7.3rc2 (default, May 6 2012, 20:02:25)
[GCC 4.6.3] on linux2
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
start of attempt # 0
+ 6V +
start of attempt # 1
start of attempt # 2
6V + 6V
start of attempt # 3
+ V +
start of attempt # 4
start of attempt # 5
start of attempt # 6
V + V
start of attempt # 7
start of attempt # 8
start of attempt # 9
I’m not sure what to do to make this work. Initial thoughts are:
Do I really need 5V? (datasheet says 2.5V - 5.5V).
Do I need some kind of RS232 converter? (Not even sure what that is.)
Do I need to add some kind of sleep mode from Pyserial to let the sensor warm up?
Any help would be greatly appreciated.