hi there
I want to control a UPS device using its Rs232 port via Arduino. I am doing this using MAX3232.
When I connect the UPS directly with my PC and send serial commands using a terminal software, the UPS responds very well. One of the basic command is just a 0x0d character. However, when I send the same command using arduino, the UPS fails to respond. I tested the output of arduino by connecting its DB9 connector to the PC, and found that it sends all commands correctly without any illegal character. The settings on the PC terminal are 2400 baud with data size 8, parity none, handshake off. With these settings, the PC communicates with PC and when connects to the arduino, does the same. However, arduino when connected directly to the UPS, fails.
What could be the other reason that is not coming to my mind here?
Here is the software code programmed in the arduino:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(6, 7); // RX, TX
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
Serial.println("Starting!");
mySerial.begin(2400);
mySerial.write(0x0d);
delay(1000);
if (mySerial.isListening()) {
Serial.println("Port One is listening!");
}
}
void loop() // run over and over
{
while (mySerial.available() <= 0) {
mySerial.write(0x0d);
Serial.println("Sent");
delay(5000);
}
if (mySerial.available())
{
Serial.write(mySerial.read());
}
if (Serial.available())
mySerial.write(Serial.read());
if (mySerial.overflow()) {
Serial.println("Overflow ...");
}
}
Please help .. thanks
Moderator edit:
</mark> <mark>[code]</mark> <mark>
</mark> <mark>[/code]</mark> <mark>
tags added.