PIR Motion Sensor Radar with OLED SSD1306 using Arduino Nano 33 IoT

Motion detection is a popular application in home automation and security systems. In this project, we’ll use an AM312 PIR motion sensor with an SSD1306 OLED display and an Arduino Nano 33 IoT.

When no motion is detected, the OLED shows a radar-like sweeping animation. When motion is detected, the display alerts with the message “Motion!”

With just a web browser, you’ll be able to change the LED color in real-time using a color picker interface — no need for extra apps!

PCBWay offers high-quality PCB prototyping and assembly at an affordable price, starting at just $5 for 5 PCBs. With fast turnaround, great customer support, and easy online ordering, it’s a top choice for hobbyists and professionals alike.

Components Required

QuantityComponentDescription
1Arduino Nano 33 IoTMicrocontroller with built-in WiFi & I2C support
1AM312 PIR Motion SensorDetects motion using infrared radiation
1SSD1306 128×64 OLED Display (I2C)Displays radar animation and alerts
1BreadboardFor easy wiring and prototyping
1Micro-USB CableTo power and program the Arduino
FewJumper WiresFor connections

Wiring Connections

Arduino Nano 33 IoT PinPIR Sensor PinOLED PinDescription
D2OUTPIR output signal to Arduino
3.3VVCCVCCPower supply (both PIR & OLED use 3.3V)
GNDGNDGNDCommon ground
SDA (A4)I2C data line for OLED
SCL (A5)I2C clock line for OLED

⚡ Note: The Arduino Nano 33 IoT operates at 3.3V logic, making it compatible with both AM312 PIR and SSD1306 OLED.

How the Project Works

  • The AM312 PIR sensor detects motion by sensing infrared radiation changes.
  • When no motion is detected, the OLED shows a radar sweep animation made using circles and a rotating line.
  • If motion is detected, the OLED clears the animation and shows a bold “Motion!” alert.

This makes the system visually interactive — like a mini radar scanner.

Arduino Code

Here’s the tested code for the project:

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <math.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

const int pirPin = 2;

float angle = 0;          // radar sweep angle
const int radarRadius = 30;
const int centerX = SCREEN_WIDTH/2;
const int centerY = SCREEN_HEIGHT/2;

void setup() {
  Serial.begin(9600);
  pinMode(pirPin, INPUT);

  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)){
    Serial.println("SSD1306 allocation failed");
    for(;;);
  }
  display.clearDisplay();
  display.display();
}

void loop() {
  bool motionDetected = digitalRead(pirPin);

  display.clearDisplay();

  if(!motionDetected){
    // --- Radar animation ---
    // Draw radar circle
    display.drawCircle(centerX, centerY, radarRadius, SSD1306_WHITE);
    display.drawCircle(centerX, centerY, radarRadius-5, SSD1306_WHITE);

    // Draw sweeping line
    int x = centerX + radarRadius * cos(angle);
    int y = centerY + radarRadius * sin(angle);
    display.drawLine(centerX, centerY, x, y, SSD1306_WHITE);

    // Increment sweep angle
    angle += 0.1; // speed of sweep
    if(angle > 2*3.14159) angle = 0;

    // Draw radar center
    display.fillCircle(centerX, centerY, 2, SSD1306_WHITE);
  } else {
    // --- Motion detected ---
    display.setTextSize(2);
    display.setTextColor(SSD1306_WHITE);
    display.setCursor(5, SCREEN_HEIGHT/2 - 10);
    display.println("Motion!");
  }

  display.display();
  delay(30); // controls smoothness
}

Uploading & Testing

  1. Install the following Arduino libraries (via Library Manager):
    • Adafruit GFX
    • Adafruit SSD1306
  2. Connect your Arduino Nano 33 IoT, PIR sensor, and OLED as per the wiring table.
  3. Upload the code to the board.
  4. Open the Serial Monitor (optional) for debugging.
  5. Observe the OLED:
    • Without motion → radar sweep animation.
    • With motion → bold “Motion!” alert.

Demo Output

  • Idle Mode (No Motion): OLED shows a radar-style sweeping line with concentric circles.
  • Motion Detected: OLED clears and displays “Motion!” text in large font.

Conclusion

In this project, we combined a PIR motion sensor with an OLED display to create an interactive radar-style motion detection system.

This setup can be extended by:

  • Adding buzzer/LED alerts when motion is detected.
  • Logging events to a server or SD card.
  • Integrating with WiFi (Nano 33 IoT) for real-time IoT monitoring.

This project is a fun and practical example of using sensors and displays in Arduino-based security systems.