How to install pySerial ?

Official forum for open source FreePIE discussion and development.
Post Reply
Adream
One Eyed Hopeful
Posts: 3
Joined: Thu Dec 22, 2016 3:30 pm

How to install pySerial ?

Post 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 ?
Adream
One Eyed Hopeful
Posts: 3
Joined: Thu Dec 22, 2016 3:30 pm

Re: How to install pySerial ?

Post 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
Post Reply

Return to “FreePIE”