Sniffing for IR Interference

Sniffing for IR Interference

You might have found that your BOE Shield-Bot said it detected something even though nothing was in range.  That may mean a nearby light is generating some IR light at a frequency close to 38.5 kHz.  It might also mean that direct sunlight streaming through a window is causing false detections.  If you try to have a BOE Shield-Bot contest or demonstration near one of these light sources, your infrared systems could end up performing very poorly!  So, before any public demo, make sure to check the prospective navigation area with this IR interference “sniffer” sketch ahead of time.

The concept behind this sketch is simple: don’t transmit any IR through the IR LEDs, just monitor to see if any IR is detected.  If IR is detected, sound the alarm using the piezospeaker.

You can use a handheld remote for just about any piece of equipment to generate IR interference. 
TVs, VCRs, CD/DVD players, and projectors all use the same type of IR detectors you have on your BOE Shield-Bot right now.  So, the remotes you use to control these devices all use the same kind of IR LED that’s on your BOE Shield-Bot to transmit messages to your TV, VCR, CD/DVD player, etc. All you’ll have to do to generate IR interference is point the remote at your BOE Shield-Bot and repeatedly press/release one of the remote’s buttons.

Example Sketch – IrInterferenceSniffer

With this sketch, your BOE Shield-Bot should play a tone, turn on its indicator LEDs, and display a warning in the Serial Monitor any time it detects infrared.  Again, since it’s not transmitting any IR, it means the 38 kHz infrared has to be coming from an outside source.

  • Enter, save, and upload IrInterferenceSniffer to your Arduino.
  • Test to make sure the BOE Shield-Bot sounds the alarm when it detects IR interference.  If you are in a classroom, you can do this with a separate BOE Shield-Bot that’s running TestBothIrAndIndicators.  Just point its IR LEDs into the IrInterferenceSniffer bot’s IR receivers.  If you don’t have a second BOE Shield-Bot, just use a handheld remote for a TV, VCR, CD/DVD player, or projector.  Simply point the remote at the BOE Shield-Bot and repeatedly press and release one of its buttons.  If the BOE Shield-Bot responds by sounding the alarm, you know your IR interference sniffer is working.
/*
 * Robotics with the BOE Shield - IrInterferenceSniffer
 * Test for external sources of infrared interference.  If IR interference is
 * detected: Serial Monitor displays warning, piezospeaker plays alarm, and
 * indicator lights flash.
 */

void setup()                                 // Built-in initialization block
{
  tone(4, 3000, 1000);                       // Play tone for 1 second
  delay(1000);                               // Delay to finish tone

  pinMode(10, INPUT);                        // Left IR Receiver
  pinMode(3, INPUT);                         // Right IR Receiver
  pinMode(8, OUTPUT);                        // Left indicator LED
  pinMode(7, OUTPUT);                        // Right indicator LED

  Serial.begin(9600);                        // Set data rate to 9600 bps
}  
 
void loop()                                  // Main loop auto-repeats
{
  int irLeft = digitalRead(10);              // Check for IR on left
  int irRight = digitalRead(3);              // Check for IR on right
 
  if((irLeft == 0) || (irRight == 0))        // If left OR right detects
  {                                         
    Serial.println("IR interference!!!");    // Display warning
    for(int i = 0; i < 5; i++)               // Repeat 5 times
    {
      digitalWrite(7, HIGH);                 // Turn indicator LEDs on
      digitalWrite(8, HIGH);
      tone(4, 4000, 10);                     // Sound alarm tone
      delay(20);                             // 10 ms tone, 10 between tones
      digitalWrite(7, LOW);                  // Turn indicator LEDs off
      digitalWrite(8, LOW);
    }
  }  
}

Your Turn – Testing for Fluorescent Lights that Interfere

  • Disconnect your BOE Shield-Bot from its programming cable, and point it at any fluorescent light near where you plan to operate it. 
  • Especially if you get frequent alarms, turn off that fluorescent light before trying to use IR object detection under it.
  • If the source turns out to be sunlight streaming in through a window, close the blinds and retest, or move your obstacle course to a location that’s well away from the window.

Close blinds, and test overhead flourescent lights for IR interference

Always use this IrInterferenceSniffer to make sure that any area where you are using the BOE Shield-Bot is free of infrared interference.