Tag Archives: raspberry pi

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