XOJO and Arduino Stops Communicating

I’ve search through the forum and google and I don’t see a solution for a similar problem.
I’m using MacOS and Arduino Uno.
I have a irrigation timer running in XOJO and the Arduino is controlling relays and reading sensors.
When I make the initial serial connection everything runs fine for a while, IDK sometimes maybe minutes or hours, I need to study that more closely. XOJO sends commands and Arduino activates relays and reports back status. After a while no data is received back to XOJO but the Arduino is still receiving and executing relay commands. I’m pretty sure the Arduino is still sending the status reports but they are getting hung up somewhere. If i reset the connection the last report sent from the Arduino is still in the buffer.
Anything there sound familiar to put me on the right track?

I will not answer your question because this need more informations like the code you use to connect xojo side and arduino side.
I would answer you that it is time to shift to phase 2 of the irrigation project…

use an esp8266 or esp32 instead of an arduino
connect it to the wifi home network
make it completely autonomous, no need for xojo to send command to it
the esp can get time and date from the internet, and display the needed data on an html page
xojo connect to the device with htmlviewer, or tcpsocket and it will be more reliable.
you won’t even need xojo the esp can do all the needed work, even send data to a network database…

If Me.Caption = "Disconnect" Then // Disconnect from the serial device
  Me.Caption = "Connect"
  DevicesPopupMenu.Enabled = True
  DeviceListUpdater.RunMode = Timer.RunModes.Multiple 'turn it on
Else // Connect to the serial device
  // Set the serial device to the index of the one chosen in the popup menu
  SerialConnection1.Device = SerialDevice.At(DevicesPopupMenu.SelectedRowIndex)
    DevicesPopupMenu.Enabled = False
    DeviceListUpdater.RunMode = Timer.RunModes.Off
    Me.Caption = "Disconnect"
  Catch error As IOException
    MessageBox("The selected serial device could not be opened.")
  End Try
End If
data = Me.LookAhead(Encodings.ASCII)
If data.IndexOf(EndOfLine.Windows) > -1 Then
  data = Me.ReadAll(Encodings.ASCII)
  ArduinoStatus.Value = data
End If

Arduino side is pretty simple, here is the relevant portion of that:

void setup() {


  pinMode(ledPin, OUTPUT);

  pinMode(relay9, OUTPUT);
  digitalWrite(relay9, HIGH);
  pinMode(relay10, OUTPUT);
  digitalWrite(relay10, HIGH);


void loop() {
  // see if there is incoming serial data:
  if (Serial.available() > 0) {
    incomingByte = Serial.read();

   if (incomingByte == '9') {
    lflash = 2;
    digitalWrite(relay9, LOW);
    Serial.println("Zone 9 Running");

You could try to use another serial app like coolterm on mac or putty on windows to send the commands to the arduino, and receive them. to find if it is the arduino that does not send after a while, or xojo that hang.

I agree with Jean-Yves_Pochez’s sentiment. The only difference I have it to use a maker 1010 wifi. I think the wifinina library is much easier to work with. Even if you have to operate it manually it just works much better over wifi. There are many samples on the arduino site for different communication protocols using wifi that should get you going fast.

What arduino board are you using?

It seems that there are some important parts of the arduino code missing. I assume you are sending a code to turn it on and off at a preset time or period of time? If you send me the code I can try it, assuming I have the same board. I have a PC only so it may not be a valid test. I have made a couple of simple loggers that sent data over serial. I think I have been able to receive days of data without any issues.

Lastly can you just create a routine in the arduino that either simulates the process or runs the process and test it in the ide’s serial monitor.

Thank you so much for help and suggestions. I think I was solely focused on the code but at this point because it’s pretty inconsistent when it stops communicating and it works fine when it works, I’m inclined to think that perhaps I’m getting interference somewhere in the line that’s making something go haywire. So far it seems to be working with the Arduino disconnected from the relay.

Yup all fixed. It wasn’t the code. I’m using a pretty good optocoupler isolated relay or so I thought.