0

The two FT232RL USB-serial converters I ordered from China arrived today, and I tried to find a way to test them. I wrote the following Arduino code:

const uint8_t ledPin = 3;
bool ledIsOn = false;

void setup() {
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
}

void loop() {
  if (Serial.available()) {
    char c = Serial.read();
    if (c == '1') {
      ledIsOn = !ledIsOn;
      digitalWrite(ledPin, ledIsOn ? HIGH : LOW);
    }
  }
}

I uploaded the code to my Nano and made the following connections:

  • Nano TX - USB-serial RX
  • Nano RX - USB-serial TX
  • Nano 5V - USB-serial VCC
  • Nano GND - USB-serial GND
  • Nano D3 - LED anode
  • LED cathode - 220 ohm resistor
  • 220 ohm resistor - USB-serial GND

Additional info:

  • The jumper on the USB-serial converter is set to 5V.
  • The converter appears as COM7 in Device Manager.

I plugged in the USB cable, started PuTTY and made a serial connection to port COM7. Pressing 1 repeatedly turned the LED on and off. Success!

I also observed that the converter doesn't turn the Nano on as soon as it plugged in, only when the serial connection is made.

Then I wanted to control the LED from a C# program:

using System.IO.Ports;
using System.Threading;

namespace SerialBlink
{
    class Program
    {
        static void Main(string[] args)
        {
            var port = new SerialPort("COM7", 9600);
            port.Open();
            for (var i = 0; i < 6; i++)
            {
                port.Write("1");
                Thread.Sleep(1000);
            }
            port.Close();
        }
    }
}

The program runs successfully, the RX LED on the converter blinks every time a "1" is sent, but the Nano doesn't turn on.

I guess this means that PuTTY must do something when it opens the connection that turns on the power output on the converter and makes it send the data on its output port. But what is that something?

EDIT: I've just tried connecting to the Nano board through its own USB and the C# program and it worked (though I had to wait 5 seconds at the start of my program for it to work reliably), so it is definitely some kind of initialization that is missing when I'm using the converter.

  • What USB adaptors do you have? – Majenko Jun 9 '17 at 20:50
  • Although you aren't showing a connection to the Arduino reset line, it sort of sounds like you might be sending your information while the bootloader rather than sketch is running. Try putting a 10-20 second delay in your program between opening the port and sending the data. – Chris Stratton Jun 9 '17 at 20:57
  • @ChrisStratton I have tried to wait for 10 seconds before sending the data. But the problem is that the Arduino didn't even power up because it seems that opening the port on the USB-serial converter isn't enough for that. – Botond Balázs Jun 9 '17 at 21:03
  • @Majenko I have this one: banggood.com/… – Botond Balázs Jun 9 '17 at 21:04
  • 1
    A voltmeter won't tell you the difference between a supply pin and a CMOS signal pin. Again, there are no power switching devices on the board you linked which are suitable for switching power to an Arduino. If that is what is happening, it is probably because you are misusing a signal pin for a supply. You need to trace where your alleged supply rail is coming from - it should be straight from the USB connector with nothing more than perhaps an overcurrent device in between. – Chris Stratton Jun 10 '17 at 7:27

Your Answer

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

Browse other questions tagged or ask your own question.