PIR Sensor Interfacing with MSP-EXP430G2 TI Launchpad

Overview of Motion Sensor

PIR Sensor

 

PIR sensor is used for detecting infrared heat radiations. This makes them useful in applications involving the detection of moving living objects that emit infrared heat radiations.

The output (in terms of voltage) of the PIR sensor is high when it senses motion; whereas it is low when there is no motion (stationary object or no object).

For more information on the PIR sensor and how to use it, refer to the topic PIR sensor in the sensors and modules section.

 

Connection Diagram of PIR Sensor with MSP-EXP430G2 TI Launchpad

Interfacing PIR Sensor with MSP-EXP430G2 TI Launchpad
Interfacing PIR Sensor with MSP-EXP430G2 TI Launchpad

 

Note:

  • PIR sensor: Never keep PIR Sensor close to the Wi-Fi antenna, ESP32, or NodeMCU.
  • PIR (Passive Infrared) sensor close to a WiFi antenna impacts the sensor's performance.
  • PIR sensors detect changes in infrared radiation for motion detection.
  • WiFi signals emit electromagnetic radiation that can interfere with the PIR sensor. Which causes false detection.
  • So always keep the PIR sensor and WiFi antenna as far apart as possible.
  • Also, you can try to shield the PIR sensor from the WiFi signal. This can be done by using metal shields or Faraday cages around the PIR sensor.

 

Detect Motion using PIR Sensor and ATmega16/32 Microcontroller

Motion detection of living objects using the PIR sensor using MSP-EXP430G2 TI Launchpad.

 

Upon detection of motion, the object detected is printed on the serial monitor of Energia. When there is no motion, no object detected is printed on the serial monitor of Energia.

 

Tread Carefully: MSP-EXP430G2 TI Launchpad board has a RAM of 512 bytes which is easily filled, especially while using different libraries. There are times when you need the Serial buffer to be large enough to contain the data you want and you will have to modify the buffer size for the Serial library. While doing such things, we must ensure that the code does not utilize more than 70% RAM. This could lead to the code working in an erratic manner, working well at times, and failing miserably at others. 

There are times when the RAM usage may exceed 70% and the codes will work absolutely fine, and times when the code will not work even when the RAM usage is 65%. 

In such cases, a bit of trial and error with the buffer size and/or variables may be necessary.

 

PIR Motion Detection Code for ATmega16/32

const int PIR_SENSOR_OUTPUT_PIN = 8;	/* PIR sensor O/P pin */
int warm_up;

void setup() {
  pinMode(PIR_SENSOR_OUTPUT_PIN, INPUT);
  Serial.begin(9600);	/* Define baud rate for serial communication */
  delay(20000);	/* Power On Warm Up Delay */
}

void loop() {
  int sensor_output;
  sensor_output = digitalRead(PIR_SENSOR_OUTPUT_PIN);
  if( sensor_output == LOW )
  {
    if( warm_up == 1 )
     {
      Serial.print("Warming Up\n\n");
      warm_up = 0;
      delay(2000);
    }
    Serial.print("No object in sight\n\n");
    delay(1000);
  }
  else
  {
    Serial.print("Object detected\n\n");    
    warm_up = 1;
    delay(1000);
  }  
}

 

Video of Motion Detection using ATmega16/32


Components Used

TI Launchpad MSP-EXP430G2
TI Launchpad MSP-EXP430G2
1
PIR Sensor
PIR motion sensors sense the Infrared signal radiated from moving objects including human or animal body. It is generally used to detect the presence of human or animal motions.
1

Downloads

PIR_Sensor_Interfacing_With_TI_Launchpad_INO Download
Ad