Hey there. I have a Vaisala Barometer here, connected with an RS232 Connector to a MAX3232 converter, which is then connected to RX 0 /TX1 on the Arduino Mega. There is also an Ethernet Shield with a micro sd card slot on top of it. Now, I have no idea on how to get and send Data from/to the Barometer... Does anyone have a tutorial or test code or anything?
Its something with Serial.write, Serial.read, but I'm not sure on how to specifically do it.
I just want the pressure values on my serial monitor for now.
After some search, i got a code which could work... but there's no response at all.
In the Manual for the Barometer, the following values are listed for serial communication and it also works with them with Hyperterminal.
Baud rate 9600
Parity even
Data bits 7
Stop bits 1
Duplex full duplex
Following Code was used, and i took SERIAL_7E1 for 7 data bits, even and 1 stop bit.
I opened the Serial Monitor with Baudrate 115200 and waited there, also set it to Carriage Return, wrote some "?" in the bar there which should trigger a command list from the barometer.
*/
void setup()
{
// Open serial communications and wait for port to open:
Serial1.begin(115200);
// while (!Serial1) {
// ; // wait for serial port to connect. Needed for Native USB only
// }
Serial1.println("Goodnight moon!");
// set the data rate for the SoftwareSerial port
Serial.begin(9600, SERIAL_7E1);
Serial.print("MF");
Serial.print(0x0D);
}
void loop() // run over and over
{
if (Serial.available()) {
Serial1.write(Serial.read());
}
if (Serial1.available()) {
Serial.write(Serial1.read());
}
}
I used a MAX3232 Module and connected it with 4 wires. It's an Ethernet Shield on top, but it doesnt have a RS232 port on it, so it had to use a module for it.
// Arduino Mega serial1 test
// mega pin 18 is Tx
// pin 19 is Rx
// for loopback test connect pin 18 to pin 19
// for RS232 shield connect pin 18 to Tx and pin 19 to Rx
// for loopback test connect 9 pin D connector pins 2 and 3
unsigned long time;
void setup() {
Serial.begin(115200); // initialise serial monitor port
Serial1.begin(115200); // initialise Serial1
Serial.write("Arduino Mega Serial1 test - for loopback test connect pin 18 to pin 19\n");
}
void loop() {
if (Serial1.available()) // read from Serial1 output to Serial
Serial.write(Serial1.read());
if (Serial.available()) { // read from Serial outut to Serial1
int inByte = Serial.read();
//Serial.write(inByte); // local echo if required
Serial1.write(inByte);
}
}
characters typeed into the Arduino Serial Monitor are transmitted over RS232 TX line and characters received from the RS232 Rx line are displayed on the monitor
e.g. connected RS232 shield to to a PC RS232 serial port the Serial Monitor displays
hello mega test1
test 2 from PC 1234567890
and a terminal emulator on the PC displays
hello PC test1
test2 from Mega 1234567890
you can test the RS232 shield by itself by running the above program and connecting pins 2 and 3 of the 9 pin D type connector together - characters entered on the Serial Monitor should be echoed back and displayed
Hey, first of all thank you very much for your time. I now tested it... There is no response, neither without pins 2+3 connected or with them connected...
a loopback test connects the Tx to Rx lines and is used to check if hardware/software is working.
On 9 pin D type RS232 connector pin 2 is Tx and pin 3 is Rx so connecting them together enables a loopback test
once happy the RS232 shield is OK you connect the target devcice
do you have a datasheet for the Vaisala Barometer ?
when you connected it what baudrate did you use 9600?
if Hyperterm worked when it was connected to a PC the Arduino/RS232 shield combination should work
a loopback test connects the Tx to Rx lines and is used to check if hardware/software is working.
On 9 pin D type RS232 connector pin 2 is Tx and pin 3 is Rx so connecting them together enables a loopback test
if there is no response to a loopback test there is something wrong with the hardware/software setup
what software were you running?
how was the RS232 shield connected?
in post #7 you indicated that the loopback test did not work ( On 9 pin D type RS232 connector pin 2 is Tx and pin 3 is Rx so connecting them together enables a loopback test)
try it again and if it does not work try swapping pins 18 and 19 on the Mega