38400Bps/8bits/no parity/1stop byte / no control f

Hie,

I have a Duemilanove board.
I try to communicate with a RS232 device through pin 1&2.
config :
38400Bps/8bits/no parity/1stop byte / no control flow

I am using the NewSoftSerial library from arduiniana

I try to send AT command to my device thanks to this program:

#include <NewSoftSerial.h>

NewSoftSerial mySerial(2, 3);

void setup()  
{
  Serial.begin(9600);
  Serial.println("Goodnight moon!");
  mySerial.begin(38400);
}

void loop()                     // run over and over again
{

  if (mySerial.available()) {
      Serial.print((char)mySerial.read());
  }
  if (Serial.available()) {
      mySerial.print((char)Serial.read());
  }
  delay(100);
}

But it is not working.
When I send "AT" thanks to the terminal on my conputeur, the device shoud reply "OK" but nothing happen.

Do you know why ?

Thans for reading and your help, advices.
PT

pin 1&2

Normal communications use pins 0 & 1.This is connected to the USB / serial chip.

What hardware are you using to interface the arduino to the serial input. If you are not going through the USB port you need an RS232 to TTL voltage converter to enable it to work

If my arduino board is connected to my computor thanks the USB, I can't, on the same time, use the pin 0&1, can I?

I juste want use the Arduino board as a usb<->RS232 converter.

You told "If you are not going through the USB port you need an RS232 to TTL voltage converter to enable it to work "
In fact, i am sure that I don't need a max232 or similar RS232 interface adaptor.

Thanks a lot
PT

In fact, i am sure that I don't need a max232 or similar RS232 interface adaptor.

So HOW are you connecting the Arduino to the PC?

Hey Grumpy_Mike - I think he made a mistake in the posting - if you look at his code, he's using pins 2 and 3. (It looks like he's trying to use the Arduino board as a serial passthrough board).

OP:
The question is, are you sure you have physically connected the "RS232" device to pins 2 and 3, and not pins 1 and 2?

b

Hie,
I am working right now in my office. At midday, I ll see if my device is connected to the pin 2&3 .

Thanks a lot.
PT

I try to send AT command to my device thanks to this program:

What is "my device"? and what specification does it have regarding the serial input?

Also have you got pins 2 & 3 round the right way?

My device est connected with pin 2&3
It is a zigbit device (if u know). It 's need this config :
38400Bps/8bits/no parity/1stop byte / no control flow

I made a serial.println("AT"), and I don't have "ok" back
I made a serial.print("AT\0"), and I don't have "ok" back

thanks a lot for your help

The zigbit device has a maximum working voltage of 3.6V are you supplying it with this? Is your arduino a 5V system? If so you will need some voltage translation between the serial connections of both devices.

you're right. Thanks a lot Grumpy_Mike.

so i have to find an easy way to convert an hight speed (38400bd) 5v signal to a 3.6v signal
In fact, its a kind of max232 (15v<->5v) but working with 5v<->3,6v
If you know the solution ... :slight_smile:

Thanks

Lots of solutions see:-
http://forums.adafruit.com/viewtopic.php?f=8&t=8645&start=0

http://forum.sparkfun.com/viewtopic.php?p=80819&sid=e2335633efae075d8fc2f91525bebd1a

And a very nifty circuit in this (don't be put off by the application it's the same)

thanks a lot
I found this : http://www.sparkfun.com/commerce/product_info.php?products_id=8745
let's try :slight_smile:

i've got it. It works

but :-/
here is my prog :

#include <NewSoftSerial.h>

NewSoftSerial mySerial(2, 3);

int numChar = 0;
int numCharb = 0;
int aa = 0;

void setup()  
{
  Serial.begin(9600);
  Serial.println("let's go !");
  mySerial.begin(38400);
 Serial.flush();
 mySerial.flush();
}

void loop()                     // run over and over again
{

  if (mySerial.available()) {
    readRadio();
  }
  if (Serial.available()) {
    readinterface();
  }
  delay(100);
}

void readinterface(){
  int index = 0;
  delay(100); // let the buffer fill up
  int numChar = Serial.available();
  Serial.println(numChar);
  char buffer[numChar];
  int numCharB = numChar+1;
  for (index = 0; index < numChar; index++) {
    buffer[index] = Serial.read();
  }
  //buffer[index+1]='\r';
  //buffer[index+2] = '\0';
  mySerial.println(buffer);
  Serial.println("Data_sent :  ");
  Serial.println(buffer);
  // Clear the text and serial buffers
  for (int x=0; x<numCharb; x++) {
    buffer[x]='\0';
  }
 Serial.flush();
}

void readRadio(){
  int index = 0;
  delay(100); // let the buffer fill up
  int numChar = mySerial.available();
  if (numChar>2){
    char buffera[numChar+2];
    int numCharB = numChar+2;
    for (index = 0; index < numChar; index++) {
      buffera[index] = mySerial.read();
    }
    buffera[index+1]='\r';
    buffera[index+2] = '\0';
    Serial.print ("Data_read:  ");
    Serial.println (aa);
    Serial.println(buffera);
    // Clear the text and serial buffers
    for (int x=0; x<numCharb; x++) {
      buffera[x]='\0';
    }
  }  Serial.flush();
  aa = aa+1;
}

and here is what i can read :

let's go !
2
Data_sent :  
atR


BA[ch149]



æ

Data_read:  0
ûÿ
@
ªüQ
ö

¨H¨JJêJÕ¤¤ü
 2
Data_sent :  
at
Data_read:  1
ì OK


 3
Data_sent :  
atx
Data_read:  2
ûá5ÿ
OK

quite hard to write on the forum, anyway, as u can see, when I sent AT, I didn't received only"ok"
When I sent "at" I received "(strange things) (carriage return) OK"

where is my mistake ??

:wink: have a good evening