I installed pySerial:
Code: Select all
pi@xkontipi ~ $ sudo apt-get install python-serial
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
python-wxgtk2.8 python-wxgtk2.6 python-wxgtk
The following NEW packages will be installed:
python-serial
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/79.0 kB of archives.
After this operation, 483 kB of additional disk space will be used.
Selecting previously unselected package python-serial.
(Reading database ... 72308 files and directories currently installed.)
Unpacking python-serial (from .../python-serial_2.5-2.1_all.deb) ...
Setting up python-serial (2.5-2.1) ...
Code: Select all
import serial
port = serial.Serial("/dev/ttyAMA0", baudrate=9600, timeout=3.0)
while True:
port.write("\r\nSay something:")
rcv = port.read(10)
port.write("\r\nYou sent:" + repr(rcv))Code: Select all
pi@xkontipi ~ $ python serial.py
Traceback (most recent call last):
File "serial.py", line 1, in <module>
import serial
File "/home/pi/serial.py", line 3, in <module>
port = serial.Serial("/dev/ttyAMA0", baudrate=9600, timeout=3.0)
AttributeError: 'module' object has no attribute 'Serial'
Can you help me fix it?