# Serial Communication RS232 with a Vaisala Barometer - need Help

**URL:** <https://forum.arduino.cc/t/serial-communication-rs232-with-a-vaisala-barometer-need-help/1051893>\
**Category:** Networking, Protocols, and Devices\
**Created:** [November 10, 2022, 10:26am UTC](https://forum.arduino.cc/t/serial-communication-rs232-with-a-vaisala-barometer-need-help/1051893 "2022-11-10T10:26:02Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![nightshade1](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/nightshade1/32/723638_2.png) [@nightshade1](https://forum.arduino.cc/u/nightshade1)\
**Post date:** [November 10, 2022, 10:26am UTC](https://forum.arduino.cc/t/serial-communication-rs232-with-a-vaisala-barometer-need-help/1051893/1 "2022-11-10T10:26:02Z")

</div>

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.

```cpp

*/
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());
  }

}
```

Any idea? I have no clue what the problem is...

---

<div class="post-metadata">

**Author:** ![horace](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/horace/32/1014299_2.png) [@horace](https://forum.arduino.cc/u/horace)\
**Post date:** [November 10, 2022, 10:40am UTC](https://forum.arduino.cc/t/serial-communication-rs232-with-a-vaisala-barometer-need-help/1051893/2 "2022-11-10T10:40:07Z")

</div>

did you build the MAX232 circuit or is it a RS232 shield  
if you have a Mega why not connect the MAX232/RS232 shield to a hardware port?

---

<div class="post-metadata">

**Author:** ![nightshade1](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/nightshade1/32/723638_2.png) [@nightshade1](https://forum.arduino.cc/u/nightshade1)\
**Post date:** [November 10, 2022, 11:17am UTC](https://forum.arduino.cc/t/serial-communication-rs232-with-a-vaisala-barometer-need-help/1051893/3 "2022-11-10T11:17:54Z")

</div>

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.

> **[RS232 / TTL Wandler MAX3232 Breakout Board - Bastelgarage Elektronik Online Shop](https://www.bastelgarage.ch/rs232-ttl-wandler-max3232-breakout-board)**
>
> Mit diesem RS232 TTL Konverter Modul kannst du mit Arduino oder Raspberry Pi ein Gerät mit einer seriellen

---

<div class="post-metadata">

**Author:** ![horace](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/horace/32/1014299_2.png) [@horace](https://forum.arduino.cc/u/horace)\
**Post date:** [November 10, 2022, 12:50pm UTC](https://forum.arduino.cc/t/serial-communication-rs232-with-a-vaisala-barometer-need-help/1051893/4 "2022-11-10T12:50:12Z")

</div>

this shows the connection of a similar RS232 shield to Mega hardware Serial1

 ![Mega_RS232_connections](https://europe1.discourse-cdn.com/arduino/original/4X/c/4/a/c4a8149378a5d54b2f18d4637cba9d3deeb3d3c0.jpeg)

tested with

```cpp
// 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

```cpp
hello mega test1
test 2 from PC 1234567890

```

and a terminal emulator on the PC displays

```cpp
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

---

<div class="post-metadata">

**Author:** ![nightshade1](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/nightshade1/32/723638_2.png) [@nightshade1](https://forum.arduino.cc/u/nightshade1)\
**Post date:** [November 10, 2022, 2:05pm UTC](https://forum.arduino.cc/t/serial-communication-rs232-with-a-vaisala-barometer-need-help/1051893/5 "2022-11-10T14:05:12Z")

</div>

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...

---

<div class="post-metadata">

**Author:** ![horace](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/horace/32/1014299_2.png) [@horace](https://forum.arduino.cc/u/horace)\
**Post date:** [November 10, 2022, 3:18pm UTC](https://forum.arduino.cc/t/serial-communication-rs232-with-a-vaisala-barometer-need-help/1051893/6 "2022-11-10T15:18:18Z")

</div>

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](https://components101.com/connectors/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

---

<div class="post-metadata">

**Author:** ![nightshade1](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/nightshade1/32/723638_2.png) [@nightshade1](https://forum.arduino.cc/u/nightshade1)\
**Post date:** [November 10, 2022, 3:25pm UTC](https://forum.arduino.cc/t/serial-communication-rs232-with-a-vaisala-barometer-need-help/1051893/7 "2022-11-10T15:25:30Z")

</div>

> 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](https://components101.com/connectors/rs232-connector) pin 2 is Tx and pin 3 is Rx so connecting them together enables a loopback test

Ya i got that, but there is no response..

---

<div class="post-metadata">

**Author:** ![horace](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/horace/32/1014299_2.png) [@horace](https://forum.arduino.cc/u/horace)\
**Post date:** [November 10, 2022, 3:36pm UTC](https://forum.arduino.cc/t/serial-communication-rs232-with-a-vaisala-barometer-need-help/1051893/8 "2022-11-10T15:36:39Z")

</div>

> [@nightshade1](#):
>
> Ya i got that, but there is no response..

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?

---

<div class="post-metadata">

**Author:** ![nightshade1](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/nightshade1/32/723638_2.png) [@nightshade1](https://forum.arduino.cc/u/nightshade1)\
**Post date:** [November 15, 2022, 10:00am UTC](https://forum.arduino.cc/t/serial-communication-rs232-with-a-vaisala-barometer-need-help/1051893/9 "2022-11-15T10:00:10Z")

</div>

I'm on Arduino IDE 1.8.13. RS232 is achieved with a MAX3232 Module:

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/e/f/7/ef7fa55c2c21238424ba1f954c44015c422f00a4.jpeg)

Module is connected:

- VCC -\> 5V Arduino
- RXD -\> TX1 (Pin 11 on Arduino Mega)
- TXD -\> RX1 (Pin10 on Arduino Mega)

It doesnt work either on TX/RX 0

---

<div class="post-metadata">

**Author:** ![horace](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/horace/32/1014299_2.png) [@horace](https://forum.arduino.cc/u/horace)\
**Post date:** [November 15, 2022, 10:16am UTC](https://forum.arduino.cc/t/serial-communication-rs232-with-a-vaisala-barometer-need-help/1051893/10 "2022-11-15T10:16:05Z")

</div>

> [@nightshade1](#):
>
> Module is connected:
> 
> - VCC -\> 5V Arduino
> - RXD -\> TX1 (Pin 11 on Arduino Mega)
> - TXD -\> RX1 (Pin10 on Arduino Mega)
> 
> It doesnt work either on TX/RX 0

your code of post #1 is using Serial1 which is TX1 pin 18 RX1 pin 19

---

<div class="post-metadata">

**Author:** ![nightshade1](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/nightshade1/32/723638_2.png) [@nightshade1](https://forum.arduino.cc/u/nightshade1)\
**Post date:** [November 15, 2022, 10:23am UTC](https://forum.arduino.cc/t/serial-communication-rs232-with-a-vaisala-barometer-need-help/1051893/11 "2022-11-15T10:23:03Z")

</div>

Oh yea true... its connected to TX and RX1, so Pin 18 + 19.  
I misswrote that here, sorry

---

<div class="post-metadata">

**Author:** ![horace](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/horace/32/1014299_2.png) [@horace](https://forum.arduino.cc/u/horace)\
**Post date:** [November 15, 2022, 10:41am UTC](https://forum.arduino.cc/t/serial-communication-rs232-with-a-vaisala-barometer-need-help/1051893/12 "2022-11-15T10:41:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 14, 2023, 10:41am UTC](https://forum.arduino.cc/t/serial-communication-rs232-with-a-vaisala-barometer-need-help/1051893/13 "2023-05-14T10:41:36Z")

</div>

Closed on May 14, 2023, 10:41am UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
