Arduino Mega Ethernet Affecting Other Network Devices Causing Problems

Hello all,

Making progress with my code. Through the help on the forums got it to a stage of all working as intended now. Well with a slight caveat, it seems, and I don’t know how, but the Arduino is causing problems to other network devices.

So we have the ground end, which is a Arduino Mega, Ethernet module, and a HDMI ethernet/IP Receiver plus a gigabit switch with fibre port. Plus joystics etc.

Fibre link from ground to air.

The air end, another ethernet/fibre switch, Arduino mega, HDMI ethernet/IP sender, plus PPM output to control gimbal and camera.

The Arduino code is working great to control the camera and gimbal!!

However, plug in the HDMI sender/receiver (IP variant so can go via switches etc) and the gimbal no stutters and has massive delay to it, and the video clickers on/off every other second.
Unplug Arduiono and the video signal rmeains good and on, just cant use both together.

Is there anything wrong with my code that could cause this? There is no DHCP as no Router, but the video gets a lock even with arduinos connected, and there is clear communication between arduinos, however much much slower and laggy, and the video cutting out, however both work by themselves on the network.

So it seems like one or the other is causing network traffic issues?!
Ground Code

#include <UIPEthernet.h>

uint8_t mac[6] = {0x00,0x01,0x02,0x03,0x06,0x05};
EthernetClient client;

signed long next;
int flag=0 , flag1=0;

int Arry_to_send[11]={0};

      int focusPin = A4;    
      int zoomPin = A3;    
      int tiltPin = A2;    
      int panPin = A1;    
      int focusspeedPin = A6;    
      int zoomspeedPin = A7;    
      int tiltspeedPin = A8;    
      int panspeedPin = A5;    

 // Digital Pins, more will be added

  int modeLockPin = 21;
  int modeTrackPin = 22; 
  int modeCutPin = 23;   
  int linkledPin = 24;   
  int contledPin = 25;
  int gimledPin = 26;

  int focusVal = 0;    
  int zoomVal = 0;    
  int tiltVal = 0;    
  int panVal = 0;    
  int focusspeedVal = 0;    
  int zoomspeedVal = 0;    
  int tiltspeedVal = 0;    
  int panspeedVal = 0;    
  int modeLockVal = 0;
  int modeTrackVal = 0; 
  int modeCutVal = 0;  

  String  focusVal_s ="";

void setup() {


  pinMode(modeLockPin, INPUT);  
  pinMode(modeTrackPin, INPUT);  
  pinMode(modeCutPin, INPUT);  

    IPAddress myIP(192,168,1,12); //Use any IP address not already in use, and is on the subnet

void loop() 
  if (((signed long)(millis() - next)) > 0)
      next = millis() + 5000;
      Serial.println("Client Try connect");
     if (client.connect(IPAddress(192,168,1,6),1000))
          Serial.println("Client connected ");
            if (client.connect(IPAddress(192,168,1,6),1000))

         focusVal = analogRead(focusPin);    
          zoomVal = analogRead(zoomPin);    
          tiltVal = analogRead(tiltPin);    
           panVal = analogRead(panPin);    
    focusspeedVal = analogRead(focusspeedPin);    
     zoomspeedVal = analogRead(zoomspeedPin);    
     tiltspeedVal = analogRead(tiltspeedPin);    
      panspeedVal = analogRead(panspeedPin);  

          modeLockVal = digitalRead(modeLockPin); //need these values in the air end
          modeTrackVal = digitalRead(modeTrackPin);
          modeCutVal = digitalRead(modeCutPin);


for( int x=0 ; x<8 ;x++)


Air Code to follow in 5 minutes when i can add a second post.

Just tried a router, no luck.

But also, unplug the ground Arduino/ethernet module, and the video feed comes back.

Just unplug the air Arduino/ethernet and it still goes on and off. So it definitely seems to be to do with the data stream coming out of the ground Arduino interfereing….

Air Code

#include <UIPEthernet.h>
EthernetServer server = EthernetServer(1000);
uint8_t mac[6] = {0x00,0x01,0x02,0x03,0x04,0x05};
int array_index=0;

//------------------- used to catch values -------------------
int flag=0;
byte intBuffer[12];
String intData = "";
int delimiter = (int) '\n';
int old=1;
int i=0;

#define CHANNEL_NUMBER 12  //set the number of chanels
#define CHANNEL_DEFAULT_VALUE 1500  //set the default servo value
#define FRAME_LENGTH 22500  //set the PPM frame length in microseconds (1ms = 1000µs)
#define PULSE_LENGTH 300  //set the pulse length
#define onState 1  //set polarity of the pulses: 1 is positive, 0 is negative
#define sigPin 10  //set PPM signal output pin on the arduino

int received_Array[10]={0};

//Visca camera commands, will add more but nothing needs to be done here

  byte address_set[4]= {0x88, 0x30, 0x01, 0xFF};
  byte if_clear[5]= {0x88, 0x01, 0x00, 0x01, 0xFF};
  byte command_cancel[3]= {0x81,0x21,0xFF};
  byte zoom_teleVar[6]= {0x81, 0x01, 0x04, 0x07, 0x23, 0xFF}; //zoom in 81 01 04 07 2p FF - p=0 (low) to 7 (high)
  byte zoom_wideVar[6]= {0x81, 0x01, 0x04, 0x07, 0x33, 0xFF}; //zoom out 81 01 04 07 3p FF - p=0 (low) to 7 (high)
  byte zoom_stop[6]= {0x81, 0x01, 0x04, 0x07, 0x00, 0xFF}; //stop zoom
  byte auto_focus[6]= {0x81, 0x01, 0x04, 0x38, 0x02, 0xFF}; //auto focus
  const int thisdelay= 250; //time between sets

  int focusVal = 0; 
  int focusValT = 0;   
  int zoomVal = 0;
  int zoomValT = 0;     
  int tiltVal = 0;
  int tiltValT = 0;     
  int panVal = 0;  
  int panValT = 0;   
  int focusspeedVal = 0;    
  int zoomspeedVal = 0;    
  int tiltspeedVal = 0;    
  int panspeedVal = 0;   
  int tiltspeedValT = 0;    
  int panspeedValT = 0;   
  int modeLockVal = 0;
  int modeTrackVal = 0; 
  int modeCutVal = 0;

void setup() {

  //initiallize default ppm values

  for(int i=0; i<CHANNEL_NUMBER; i++){



  pinMode(sigPin, OUTPUT);
  digitalWrite(sigPin, !onState);  //set the PPM signal pin to the default state (off)


  TCCR1A = 0; // set entire TCCR1 register to 0
  TCCR1B = 0;
  OCR1A = 100;  // compare match register, change this
  TCCR1B |= (1 << WGM12);  // turn on CTC mode
  TCCR1B |= (1 << CS11);  // 8 prescaler: 0,5 microseconds at 16mhz
  TIMSK1 |= (1 << OCIE1A); // enable timer compare interrupt


    IPAddress myIP(192,168,1,6);


void loop()


 if (EthernetClient client = server.available())
      while((client.available()) > 0)
          char ch=;
           if (ch == -1) 
          else if (ch == delimiter) 
               intData += (char) ch;
    int intLength = intData.length() + 1;
    intData.toCharArray(intBuffer, intLength);
    intData = "";
    int i = atoi(intBuffer);
    if(array_index >=8)
         focusVal = received_Array[0];
          zoomVal = received_Array[1];
          tiltVal = received_Array[2];
           panVal = received_Array[3];  
    focusspeedVal = received_Array[4];   
     zoomspeedVal = received_Array[5];  
     tiltspeedVal = received_Array[6];    
      panspeedVal = received_Array[7]; 

     if (panVal < 600 && panVal > 400 )
           ppm[1]= 1485; 

          panValT = map(panVal, 0, 1023, 1100, 1900);
          ppm[1]= panValT;

      if (tiltVal < 600 && tiltVal > 400 )
           ppm[2]= 1485;

          tiltValT = map(tiltVal, 0, 1023, 1100, 1900);
         ppm[2] = tiltValT;

  ppm[0]= 1485;
  ppm[3]= 1460;
  ppm[4]= 1460;
  ppm[5]= 1460;
  ppm[6]= 1460;



ISR(TIMER1_COMPA_vect){  //leave this alone

  static boolean state = true;

  TCNT1 = 0;

  if (state) {  //start pulse

    digitalWrite(sigPin, onState);


    state = false;

  } else{  //end pulse and calculate when to start the next pulse

    static byte cur_chan_numb;

    static unsigned int calc_rest;

    digitalWrite(sigPin, !onState);

    state = true;

    if(cur_chan_numb >= CHANNEL_NUMBER){

      cur_chan_numb = 0;

      calc_rest = calc_rest + PULSE_LENGTH;// 

      OCR1A = (FRAME_LENGTH - calc_rest) * 2;

      calc_rest = 0;



      OCR1A = (ppm[cur_chan_numb] - PULSE_LENGTH) * 2;

      calc_rest = calc_rest + ppm[cur_chan_numb];





As another piece of trouble shooting. If I plug both hdmi routers into either just the air or ground switch, the video and gimbal is fine. SO then I wondered if it is to do with the fibre link, so replaced the sfp fibre link between the two switches with ethernet cable, and went back to one hdmi link in ground and one in air and the problem is still there.

So it leads me to the only conclusion that the Arduino code, Is somehow interfering with the video transmission when both the Arduino messages and the hdmi router messages have to traverse that single link between the two switches.

I didn't code the original ethernet client/server part of the code, is there a possibility its repeatedly opening and closing and causing blips on the network?

is the IP address unique?

Juraj: is the IP address unique?

Thanks for the reply. As there isnt any DHCP, have assumed the two HDMI routers set there own IP addresses. I did think about maybe a conflict, but have tried several combinations of IP addresses on the Arduino client/servers and still the same issue.

It just seemes like every second the ground arduino is sending out its packets it is briefly interupting the video. But that doesnt happen if everything is on one switch, only when bridged accross two switches and the informaion has to go accross the single ethernet/fibre cable between the two.


does it happen with empty sketch? or sketch with UIPEthernet only initialized?

Juraj: does it happen with empty sketch? or sketch with UIPEthernet only initialized?

Oh, wow, ok, so it still has the problems if it is a blank sketch on the ground end! I first used the same sketch minus ethernet parts, and still had the problem, then just loaded a blank sketch and it is still doing it.

Also to note, I changed out the ground end ethernet module and mega recently, the previous set had the same issue as well. As I thought maybe hardware fault related.

So does that mean we are still in the hardware fault realm? But then why does it work on on a single switch?

Some crazy ground issue, as the air end and ground end each have their own power supply? That for some reason doesn't effect it when both megas are on the same switch? Confused!

a long shot: try to add UIPEthernet.maintain(); to loop() (to a sketch with initialized UIPEthernet)

the ENC28j60 has only physical layer, everything else is done by the library

Thanks for the suggestion but still no joy. Tried adding that into the ground end code.

Im assuming the fact it is only effected by the ground end ENC28j60 module being plugged in is the video feed is from air to ground, and data feed of arduinos ground to air. As the ethernet module being plugged in the air side makes no difference.

Second you disconnect the ethernet cable on the ground ENC28j60 module video comes back without issue.

Does anyone think there is any merit in trying another version ethernet module? Or is it going to be the same software routing issues?

Had a look at the switches, its all auto routing, auto switching, with no manual intervention ability to set traffic priorities etc.

I did order in some serial to ethernet converter modules as a back up was to send the serial Rx/Tx over ethernet, but assuming if the Arduino ethernet module is causing issues, the Arduino to serial to ethernet module may well do the same, as believe its similar ethernet module on it anyway...

you should not call the ENC28j60 Arduino Ethernet. Arduino Etherhet uses Wiznet chips

Juraj: you should not call the ENC28j60 Arduino Ethernet. Arduino Etherhet uses Wiznet chips

Sorry, getting used to the nomenclature!

So, made some progress, and it may be able to help someone diagnose....

Adding a router into the equation on the ground end gets me stable video now, but very slow/sluggish ppm controls at the air end. So it seems like the video feed is saturating the line? These are 10gps links though....

So as before without the router, and both video and arduinos in the mix, intermittent video, sluggish controls

No video in the mix, super crisp controls in the air over the links between the arduinos and outputting ppm.

Add a router and im halfway between the two, stable video but the arduinos are talking to each other very slowly....

this is more for a network specialist, but it could do have something with QoS priorities