Serial decription failure[SOLVED]

Hello everyone please help :frowning:
I have been working on a serial issue over 2 weeks with no sucsses
Im trying to communicate with a device via RS232
The device is geting 6v supply
When i use a com port terminal software (Tera term)and i define a bound rate ,startbit ,stop bit etc.. everything works great i sending "help" via the terminal and im getting back a string menu from the device
When im connecting arduino mega and send "help" via the serial1 port i recived only some digits in serial monitor at first i thout it maybe an ascii code but its not.... ehy im not getting the same data
Can some one tell me please what i have been missing? What dose the teraterm dose to the data that the arduino cant do?
I tried spesial serial lib and all diffrent codes in the net and im getting the same numbers that most of them are 3 digits each numbers.... someone can explain?

Please read and follow the directions in the "How to use this forum" post.

void setup() {
Serial.begin(38400);
Serial1.begin(38400);
Delay(1000);
Serial1.print("help");
}

void loop() {
if(Serial1.available()) {
Serial.write(Serial1.read());
}
}

You had better be working with a Mega because the Uno doesn't have a Serial1.

Yes its a Mega as i was writing above

MosheAsh:
Yes its a Mega as i was writing above

Are you certain that Serial1 is set the same way as on Teraterm?

https://www.arduino.cc/en/serial/begin

If you are using a device that works at RS232 voltage levels it will not be compatible with an Arduino which uses TTL voltage levels for serial communication and you will need something like a MAX232 to convert between RS232 and TTL voltage levels.

RS232 voltage levels can damage an Arduino.

...R
Serial Input Basics - simple reliable ways to receive data.

I am guessing though I can be wrong that the Tera Term program is also using the same USB-serial adapter as the Arduino. However, if it isn't then that would not be a very smart move on his part!

.

ello everyone please help :frowning:
I have been working on a serial issue over 2 weeks with no sucsses
Im trying to communicate with a device via RS232
The device is geting 6v supply
When i use a com port terminal software (Tera term)and i define a bound rate ,startbit ,stop bit etc.. everything works great i sending "help" via the terminal and im getting back a string menu from the device
When im connecting arduino mega and send "help" via the serial1 port i recived only some digits in serial monitor at first i thout it maybe an ascii code but its not.... ehy im not getting the same data
Can some one tell me please what i have been missing? What dose the teraterm dose to the data that the arduino cant do?
I tried spesial serial lib and all diffrent codes in the net and im getting the same numbers that most of them are 3 digits each numbers.... someone can explain?

void setup() {
Serial.begin(38400);
Serial1.begin(38400);
Delay(1000);
Serial1.print("help");
}

void loop() {
if(Serial1.available()) {
Serial.write(Serial1.read());
}
}/code]

check you have pins 18 and 19 connected to the correct signals
pin 18 is the serial transmit from the arduino, i.e. Serial1.print()
pin 19 is the serial receive, i.e. Serial1.read()

Yes the pins connected correct otherwize there is no numbers at all…

sometimes you can pick up noise on the Rx which appears as spurious characters
have you got a common ground between the device and the mega?
are you sure the device is TTL serial ? if it is RS232 you could damage the mega
I set up a UNO to transmit charactersat 38400baud and ran your code on a mega and it receives and displays OK

(deleted)

Hi guys and thanks for the help
im gessing the RS232 levels are ok after all the devise supply voltage is 6v
i dont know what the teraterm does to the data decription
i try more codes

int myByte;
void setup() {
  // initialize both serial ports:
  Serial.begin(38400); 
  Serial1.begin(38400);
}

void loop() {
if (Serial.available()) {
    char c = Serial.read();
    switch (c)
    {
    
     case '0':
     {

      Serial.println("Done");
      Serial1.print("help");
      break;
     }
    
     case '1':
      {
      Serial1.write("read-floats .s");
      Serial.println("float sent");
      break;
      }
    }
     
  }  
     
   if (Serial1.available()>0) { 

         myByte = Serial1.read(); 
         Serial.print (myByte);
         Serial.println(); 
         
        }
    
   }

all i was geting in the serial monitor is
78
72
164
209
20
58
250
203
122
234
218
61
57
23
53
27
191
159
15
159
159
229
235
185
145
131
191
0
in the Teratem port i recived :

[ Temperature | Level | Conductivity | Density ] read-sensor-raw
P<3 | 5 | 8> - read data register
>P<3 | 5 | 8> - write data register
increment-dp - increment digi-potentiometer
decrement-dp - decrement digi-potentiometer
store-dp - store digi-potentiometer setting
reset-dp - reset digi-potentiometer setting
set-dp - set digi-potentiometer
read-temp - read ink temperature
read-dens - read ink density
read-cond - read ink conductivity
read-floats - read ink level floats
read-laser - read ink densiometer laser conditioning
<on | off> calibrate-cond - enable conductivity sensor calibration
<thermistor #> enable-thermistor - enable specified level thermistor

anyway i orderd an rs232 Shiled and hop it will solved the issue

Yes ground is connected the problem is in the terpetation of the data
if i connect RX and TX together i get the data that i was sending
i dont know if the arduino is even supposed to connect directly to RS232 is it?
maybe i need some converter in the way?

if your device is RS252 your require a RS232 shield or similar device to convert from the +-12volt RS232 signals to 0-5V TTL
when you connected to your PC what did you use? e.g. into COM1 port or a USB serial converter?

i used rs232 To swerial converter

if you used a rs232 to serial converter to communicate with the PC you will require a RS232 shield for the mega
just hope that you have not damaged the mega !

What the rs232 to usb convertes does to the oc are not implemented in the arduino by defult?

MosheAsh:
im gessing the RS232 levels are ok

That is nonsense. If they are RS232 voltage levels then they are not OK for an Arduino.

If they are OK for an Arduino then they are not RS232 voltage levels, they are TTL voltage levels - in which case an RS232 shield will be no use.

Post a link to the datasheet for the device you are trying to communicate with.

...R