pyserial

download latest from https://pypi.python.org/pypi/pyserial

pyserial-2.7.tar.gz

tar xfz pyserial-2.7.tar.gz

sudo python setup.py install

 

sudo vi/boot/cmdline.txt

change

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

into

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

sudo vi /etc/inittab

uncomment line with

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

#Spawn a getty on Raspberry Pi serial line
#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

save and reboot

 

weather.py:

import serial
ser=serial.Serial(“/dev/tty1,9600,timeout=0.5”)
print ser.name
ser.close

sudo  python weather.py

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: