Page 1 of 1

How to install pySerial ?

Posted: Thu Dec 22, 2016 3:38 pm
by Adream
I installed pySerial as they say on their site. http://pyserial.readthedocs.io/en/lates ... stallation
But when i import serial in freepie it says No module named serial
How do i install it so it works with freepie ?

Re: How to install pySerial ?

Posted: Fri Dec 23, 2016 6:07 am
by Adream
I found that i don't have to use pySerial and that SerialPort from .net Framework https://msdn.microsoft.com/en-us/librar ... -snippet-2 work flawlesly.
If anyone has same problem here is my code for reading data from potenciometer on arduino and sending it to freePIE:
Arduino:

Code: Select all

int val = 0;

void setup() {
  // put your setup code here, to run once:

Serial.begin(115200);
}

void loop() {
  // put your main code here, to run repeatedly:
    int val= analogRead(A1);//read value from A1
    Serial.println(val);//send value to serial port
    delay(30);
}



freePIE :

Code: Select all

from System.IO.Ports import SerialPort 

_serial = SerialPort("COM5",115200) //define what port to use
_serial.Open()	//open port
val = _serial.ReadLine()  //read one line and assign it to val
_serial.Close()           //close the port after you are done. If you don't do this you won't be able to access it
valInt = int(val)
vJoy[0].z = valInt