PySerial

Hi,

I’m trying to send some data over to MicroView from a python script using PySerial and have it displayed. But it does not work. Anything that I’m missing here?

Here’s my code:

import serial
ser = serial.Serial("/dev/tty.usbserial-DA00SQTP",9600)
ser.write(b'5')

Thanks

Hi Aravs7,

Since you did not include your sketch, I am unable to see what went wrong.

Below is a sketch to test your concept, it basically prints whatever send to MicroView’s serial port on the OLED.

#include <MicroView.h>

void setup() {
  uView.begin();
  uView.clear(PAGE);
  Serial.begin(9600);
}

void loop() {
  char c;
  if (Serial.available()) {
    c = Serial.read();
    uView.print(c);
    uView.display();
  }
}

Hi, There’s no problem with MicroView because my sketch works when I try to send data via the Arduino IDE’s serial monitor.

I’m trying to write a python script to send data to MicroView over the serial port. I use PySerial to send data to an actual Arduino microcontroller and it works but it does not work with MicroView. This may be because MicroView uses FTDI to send data over serial port. I’m trying to see if there are any available python libraries for ftdi.

Thanks,

Aravind

Hi Aravind,

Maybe I was not clear in my reply. I actually used your Python code in the first post and my sample Arduino sketch. I can see character being printed on MicroView.

The FTDI has nothing to do with Python, Python uses the system’s serial port. It does not know if it is a FTDI or ATMEGA serial port.

Please try your Python code in the first post together with my sample sketch.

The other thing that you need to watch out is please make sure that you are using the latest MicroView library.

If still not working, please post the following

  1. Your python code in full

  2. Your Arduino sketch in full

  3. OS type & OS version

  4. FTDI driver version

  5. Python version

  6. PySerial version

Cheers

JP

I forgot to mention that you might also want to have a delay after opening the serial port.

ser = serial.Serial(“/dev/tty.usbserial-DA00SQTP”,9600)

(add delay here, try with 1-2 seconds first)

ser.write(b’5’)

The reason is because each time the code opens the serial port, depending on your OS, the driver will pulse the DTR line thus resetting the MicroView (Arduino should have the same behaviour). Window’s system will pulse the DTR line a few times before it actually stopped. Linux OS from my system only one pulse.

So immediate sending of character will be lost because during the pulsing of DTR line the MicroView is being reset.

Cheers

JP