VB.net. NI VISA. RawIO.Write not working

I wonder if anyone can help me, please. I'm trying to do a simple read/write to the Arduino using VB.net and the NationalInstruments.Visa library. I can read OK, but the write operation doesn't work for me. There are so few examples for VB on the net. I've found some C# and tried to copy them, but I just can't make it work. I've stripped it right back to see what the issue is, and the Arduino UNO is just not seeing any bytes on the serial interface. I have tried using FormattedIO.Write as well, but with the same result.

My code:


void setup() {

void loop() {




Dim mynewsession As SerialSession = New NationalInstruments.Visa.SerialSession("ASRL3::INSTR")

mynewsession.BaudRate = 9600
mynewsession.DataBits = 8
mynewsession.Parity = Visa.SerialParity.None

Dim data As String = "1"



Dim x As String = mynewsession.RawIO.ReadString()
TextBox3.Text = TextBox3.Text + x


The error I get (in Visual Studio) is:

Ivi.Visa.IOTimeoutException: 'Exception of type 'Ivi.Visa.IOTimeoutException' was thrown.'
at the ReadString line

EDIT: Just added code tags and Arduino details. Sorry.

This seems to be the age-old problem that as soon as your PC programs opens the serial connection, the interface in the Arduino resets the Arduino program.

Your PC program needs to pause right after opening the serial connection so the Arduino can reload it's program and get running.

Fixed.....Thank you so much! I spent hours and hours at this, checking serial settings etc... I wasn't even close to solving it.

Glad to here that. Good luck with the rest.
You can mark the thread as "solved"

You should be able to suppress the reset. In below C# snippet, sp is a serial port object and cbXXX are two check boxes.

            sp.DtrEnable = cbDTR.Checked;
            sp.RtsEnable = cbRTS.Checked;

            sp.ReadTimeout = Constants.rxTimeout * 1000;

                btnConnect.Enabled = false;
            catch (Exception ex)
                MessageBox.Show(ex.Message, "Serial port error", MessageBoxButtons.OK, MessageBoxIcon.Error);

This should also work in VB.net; might need a small modification to adapt to the language.

Check the documentation of the NationalInstruments.Visa library to see if a similar feature is supported.


  1. You can also place your VB code in code tags :wink:
  2. You can let others know that your problem has a solution by clicking the solution checkbox of the most useful reply (post #2).
1 Like