Serial port problems with Arduino

I am trying to read some data from an Arduino serial port. The Arduino simply transmits a bunch of ASCII characters. On the XOJO side, I used a slightly modified version of the BarCode Reader example code. Here is what happens.

I can see and connect to the Arduino serial port just fine from XOJO, but…

When using an Arduino Uno board all the characters are read and displayed just fine
when using an Arduino M0 or M4 express board no characters are read by the XOJO program.


  1. the M0 and M4 boards will write to the Arduino IDE Serial Monitor just fine, as does the Arduino Uno board
  2. The M0 and M4 boards use a different micro (SAMD51 v.s. AMD)
  3. I tried adding a button to Xojo code that sets SerialConnect.CTS=true and SerialConnect.reset, but that made no difference
  4. if I disconnect the serial port from XoJo and switch to the IDE Serial monitor, the Arduino serial buffer is dumped to the Serial monitor and I can see all the characters

This is driving me crazy. can you help???

Thanks in advance.

Are you using Serial or SerialUSB ?

Read this:

Hope helps

Perhaps the on the M0/M4 the ports on the device are not being interpreted as a “Serial” device. Maybe create a listbox and populate with the COM serial ports which each device plugged in (separately).

In a button:
Dim count As Integer
count = System.SerialPortCount

For i As Integer = 0 To count - 1
lbxSerialPorts.RowTag(lbxSerialPorts.LastIndex) = Str(i)

Thank you Jose.

I am using Serial, but using the suggested block of code at the beginning to define Serial as SerialUSB, so I don’t think that’s it.


The name that shows up in the list of available serial ports is the same name that shows up in the Arduino IDE list of ports.

More clues:

There is a TX and RX light on the Metro M0 Express. When I send data to the serial port from Xojo the RX lights up. When the Arduino is supposed to send data to Xojo, the TX does not light up. Do I have some kind of handshaking problem here?

TX lights up when connected to the Arduino IDE serial monitor and sending…

Arduino UNO works at 5V, the M0 works at 3.3V. Oh I see that you are talking about the Metro M0 Express - it’s not the same board - this one works at 3.3 V.

On which computer are you running the Xojo application ?

run-in xojo app on same computer the board is plugged into- my mac.

ANOTHER BIG CLUE: using terminal and running “screen” I was able to connect to the arduino serial port and read/write to it. both the TX and RX lights were responding, and I had the Arduino echoing characters back to the terminal.

So there is something about the Xojo connection that is wonky.

You need to set all the serialConnection properties correct 8bits-no parity-1stopbit
And rts, dtr etc need tonbe turned off (false).

Maken sure you do this before connecting/opening the connection.

Also don’t forget the baud rate!

thanks for the suggestions. I confirmed all the settings: 115200, 8, none, 1 and still no joy

I experimented with a serial monitor program on the mac and found the following:

  1. The UNO communicates fine at 115200, 8, none, 1 without RTS or DTR
  2. The M0 express requires RTS or DTR, or both to be checked to transmit. I can see both TX andRX lights on the board
  3. the M4 express requires RTS or DTR, or both to be checked to transmit, but TX and RX lights never blink, even though the data is passing
  4. Even when I enable CTS and DTR in Xojo, the M0/Mr boards never txmit back. the “DatAvailable” event never triggers.

So I am beginning to suspect a bug in the xojo serial implementation… thoughts?

Are calling Reset after you modify those two?

1 Like

Those settings are set in the instance of the SerialConnection by way of the Inspector, not by code. So I assume reset is not required?

You can modify those properties in code as well as with the inspector, but if you do you need to either call Reset or close and open the port.

Seems like maybe some confusion as to which device is DTE and which is DCE - they might both be trying to be DTE. Can you tell the Arduino that it’s a peripheral, i.e. DCE? Also, enabling DTR in Xojo maybe doesn’t necessarily set the DataTerminalReady line to a receptive state (although you’d think it would) - you could try manually setting DataTerminalReady property, although the Xojo docs don’t tell you whether the boolean means the output is high or low (low generally being “active” in RS-232).

I would first try this, set all the connection parameters in code.

If that doesn’t work, I would check the feedback system for known bugs in the Serial and SerialConnection classes (Serial was tha API1 name, right?).

Also, you could create a SerialConnection testing app that allows you to try different connection parameters quicker, something like this but adapted to your needs (this is an old project, API1, no way to change RTS/DTR/CTS while running): Dropbox - COMCheck.rbp - Simplify your life

NOTE: at least part of the code in that project is not mine, I probably got it from the example files or forum posts (I can’t remember anymore).