0

Goal:

I am trying to send some characters to Arduino through serial from PC via a Prolific PL2303 USB to TTL converter(Chinese clone).

I have wrote a simple sketch(attached bellow) which should light up the LED if 'n' is found or should switch the LED off if 'f' is found from serial.

What's Happening:

I opened up the serial monitor. Send a character(say 'n' which should light up the LED). But nothing happened though the RX/TX LEDs flashed. Then I re opened the serial monitor. And just after re opening the serial monitor LED light up! Every time when I issue a character from serial monitor nothing happens. But just after re opening the monitor character is sent.

H/W Connection:

  • Arduino Vin -> LiPo positive rail(+11V)
  • Arduino GND -> LiPo negative rail(GND)
  • Prolific GND -> Arduino GND
  • Prolific RX -> Arduino TX
  • Prolific TX -> Arduino RX

Arduino Sketch:

int led = 13;

void setup() {
  // put your setup code here, to run once:
  pinMode(led, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  if(Serial.available() > 0){
    char bytesReceived = Serial.read();
    Serial.println(bytesReceived);

    if(bytesReceived == 'n'){
      digitalWrite(led, HIGH);  
    }
    else if(bytesReceived == 'f'){
      digitalWrite(led, LOW);  
    }
  }
}

Additional Notes:

  • Platform Windows 10
  • Installed Prolific PL2303 driver from here
  • This code is working using USB cable provided with Arduino.(I need longer cable)

Can't understand why this strange thing is happening. Any kind of help will be appreciated.

Thanks!

  • When I run the script first time .... what does that mean? .... please describe in detail the steps that you follow to run the script "the first time" – jsotola Sep 22 '18 at 0:21
  • why are you using a python script during testing? .... open a serial monitor window and press keys on a keyboard – jsotola Sep 22 '18 at 0:23
  • That means I have to run the script twice to make the serial transmit to happen: $ python testscript.py $ python testscript.py – Ashfaqur Rahman Sep 22 '18 at 0:26
  • Also tested with arduino serial monitor. Showing same behavior. If I open serial monitor and send 'n' nothing happens(LED should light up). But after re opening the serial monitor LED lights up(Character is sent). Actually I am doing a pyqt project with this hence testing with python script. @jsotola – Ashfaqur Rahman Sep 22 '18 at 0:31
  • This sounds like a problem with the Prolific clone. I know Prolific have been fighting clones of their chips with tweaks to their drivers, so it may be that your Prolific chip is not a real one and won't work right. Try a different adaptor, like an FT232 one, or bend an Arduino without the main MCU (or the main MCU held in RESET) to the use for testing. – Majenko Sep 22 '18 at 16:07
1

I have experienced similar behavior with clone chips. What worked for me is using ferrite choked USB cables similar to these; as you referenced as well, I observed that the problem occurs with either longer cable, or with cables without ferrite chokes on them. This might have to do with the PCB or the cheap chips being prone to electromagnetic interference.

  • I have purchased a 5m USB extension cable. It's working fine. – Ashfaqur Rahman Sep 26 '18 at 17:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.