1
votes

I can't communicate to four Arduino's at the same time. I tried the code below with three serial ports and it worked fine. If I add a fourth Arduino, there is no communication with any Arduino.
Can somebody help me?

var SerialPort = require('serialport');
sport1 = new SerialPort('COM10', { autoOpen: true ,
  parser: SerialPort.parsers.readline('\n'), baudRate: 9600});
sport2 = new SerialPort('COM11', { autoOpen: true ,
  parser: SerialPort.parsers.readline('\n'), baudRate: 9600});
sport3 = new SerialPort('COM12', { autoOpen: true ,
  parser: SerialPort.parsers.readline('\n'), baudRate: 9600});
sport4 = new SerialPort('COM13', { autoOpen: true ,
  parser: SerialPort.parsers.readline('\n'), baudRate: 9600});

var u = 0;
  setInterval(function() {
    if(u==0) {
        sport1.write("a");
        sport2.write("b");
        sport3.write("a");
        sport4.write("b");
    }else {
        sport1.write("b");
        sport2.write("a");
        sport3.write("a");
        sport4.write("b");
    }
    u = !u;
  },500);
1
How the arduinos connected to your computer? do you use USB hub?idanp
Yes, i use a USB hub.Franz-Josef Neekamp

1 Answers

0
votes

Seems like an hardware issue - USB hub tend to cause issues. I suggest the following:

  • Don't use USB hub (extend USB from PCI)
  • Use reliable USB hub
  • Anyway, connect to your USB hub the 5V input it needs.
  • Extend the serial ports on your computer instead of using many USB to RS232
  • Maybe connect all your Arduinos to one RS485 bus instead