Go Down

Topic: Serial over USB? (Read 732 times) previous topic - next topic

tempalte

I just got an Arduino USB Board.  Since the board has a built in usb to serial converter, is it possible to interface with the board over the USB connection?  Or do I need to build my own RS232 circuit and hook into the ATmegas TX/RX pins?

I am trying to get the arduino to talk to a perl program on a linux box.

thanks
chad

jims

The USB on the Arduino is connected to an FTDI USB to serial bridge chip which is in turn connected to the RX and TX pins of the ATmega8. You will need the FTDI driver as well as the general USB drivers on your linux box. It will depend on your distribution, but you probably need to insmod the usbserial and ftdi_sio kernel modules. These will create new serial devices in your /dev directory.

If you do decide to connect RS232 to the tx and rx pins, then you will need a level shifting circuit to handle the relatively high voltages of rs232.

(Caveat: I haven't actually attached an Arduino to any of my linux machines.)

mellis

On many distributions, the needed drivers/kernel modules are installed and loaded, so you just need to plug the Arduino board in and you'll get a serial device in /dev (usually ttyUSB0, I think).  Can you program the board from Linux?  

tempalte

I can program it from linux.  No problem.  I am using the code from:
http://www.arduino.cc/en/Tutorial/SoftwareSerial

I fired up minicom.  When I type in minicom, the RX led on the arduino lights up, but the TX led never lights up.  I am using pin 7 for TX.  does that sound correct?

thanks
chad

tempalte

Got it to work with this:
#include <stdio.h>
#include <string.h>

char incomingByte;              // for incoming serial data
char str1[50];
int count = 0;

void
setup ()
{
 beginSerial (19200);
 digitalWrite (13, HIGH);      //turn on debugging LED
}


//  MAIN CODE
void
loop ()
{
 // send data only when you receive data:
 if (Serial.available () > 0)
   {
     // read the incoming byte:
     incomingByte = Serial.read ();
     str1[count] = incomingByte;
     count++;
     if (count > 49 || incomingByte == 10 || incomingByte == 13)
       {
         Serial.print ("\nmy string is ");
         Serial.print (str1);
         count = 0;
       }
   }
}

Go Up