0

I'm trying to connect Raspberry pi and Arduino UNO with just a simple code.

For Arduino,


void setup(){
  Serial.begin(9600);
}

void loop(){
  Serial.println("Hello Pi");
  delay(1000);
}

For pi,


import serial

ser = serial.Serial('/dev/ttyACM0', 9600)

while 1:
    print ser.readline()

I installed libraries, maybe all I need,

sudo apt-get install python-pip 

sudo pip install pyserial

sudo pip install serial 

and more

Also my python file name isn't serial. It's tq.py

Is there any recommendation for this problem..?

dc37
  • 15,840
  • 4
  • 15
  • 32

1 Answers1

0

There's a namespace conflict between pyserial (the module you want to use) and serial (a module for serializing/deserializing).

Basically python is looking for the Serial object in the incorrect module and because it doesn't exist in that module you're getting an error.

Assuming you don't need both you can just do:

pip uninstall serial
bdoubleu
  • 5,568
  • 2
  • 20
  • 53