I Built an amazing Wireless Motion Alarm with LoRa Module and ESP32 That Works Through Walls

Title Prototyping a LoRa-Based Wireless Security and Surveillance System Alt Text A high-angle, top-down photograph of an electronics project assembled on three white breadboards over a green cutting mat. The circuit features two ESP32 microcontrollers, one of which is an ESP32-CAM module, and two LoRa modules with gold coil antennas. A PIR motion sensor is connected to the left side, and a small OLED display shows technical data such as "Motion: None" and "Signal: -24 dBm." The system is powered by a battery holder containing two purple 18650 Li-ion batteries connected to a blue buck converter module. Jumper wires in various colors (orange, yellow, red, black) connect the components.

The “Wait, It Works in the Other Room? LoRa Module?” Moment

Picture this.

I’m in my room. My ESP32 receiver is on my desk, OLED screen glowing.

My ESP32 sender with the PIR sensor is in the kitchen. Two walls away.

I walk into the kitchen.

Buzz. Buzz. Buzz.

The buzzer on my desk goes off. The OLED screen flashes: “Motion: DETECTED”

I didn’t use WiFi. I didn’t use Bluetooth. I didn’t even use the internet.

The two ESP32s talked to each other through solid concrete walls using nothing but radio waves.

This is LoRa Module. And it’s magical.

What is LoRa Module and Why Should You Care?

LoRa stands for Long Range.

Think of it like this:

 
 
TechnologyRangeNeeds WiFi?Best For
Bluetooth~10mNoHeadphones, speakers
WiFi~30mYes (router)Streaming, internet
LoRa1-5km+NoSensors, alarms, remote monitoring

LoRa is perfect for:

  • ✅ Backyard chicken coop temperature monitor

  • ✅ Shed security alarm (no power near the shed? Battery + LoRa)

  • ✅ Garden soil moisture sensor

  • ✅ Your motion security system

The best part? The modules cost about $10-15 each on AliExpress.

How It Works (Step by Step)

Step 1: Motion Detection

The PIR sensor on the sender ESP32 constantly watches for movement. It detects changes in infrared radiation – basically, heat moving around. When a warm body (me, my cat, a very suspicious houseplant) moves in front of it, the sensor output goes HIGH.

Step 2: LoRa Transmission

The ESP32 reads the sensor and sends a command to the RYLR998 LoRa module over UART:

text
AT+SEND=2,1,1

This means: “Send the number 1 to device address 2.” That’s it. One byte of data.

The LoRa module takes this tiny message, modulates it into radio waves, and blasts it out into the world at 915MHz.

Step 3: Long-Range Reception

The receiver’s LoRa module is in receive mode (AT+RCV=1). It’s constantly listening for any messages on the same frequency and network ID.

When it catches the transmission from address 1, it outputs:

text
+RCV=1,1,1,-45,10

This tells me:

  • Sender address: 1

  • Message length: 1 byte

  • Actual data: 1 (motion detected!)

  • RSSI (signal strength): -45 dBm (excellent)

  • SNR (signal-to-noise ratio): 10 dB (very clean signal)

Step 4: Alert!

The receiver ESP32 reads this line from the LoRa module and:

  • Updates the OLED screen to show “Motion: DETECTED” in big red letters

  • Beeps the buzzer three times

  • Turns on an LED (optional)

  • Logs the event to the Serial Monitor

Step 5: Photo Capture (Optional)

If the ESP32-CAM is set up, the receiver sends an HTTP request to its IP address:

text
GET http://192.168.0.221/capture

The ESP32-CAM takes a photo, saves it temporarily, and uploads it to my computer via FTP. The whole process takes about 2-3 seconds.

 
 
ComponentWhere to Find
RYLR998 LoRa ModuleAmazon
ESP32 Development BoardAliExpress
PIR Motion SensorAliExpress
0.96″ OLED DisplayAliExpress
BuzzerAliExpress

How It Works (Step by Step)

Step 1: Motion Detection

The PIR sensor on the sender ESP32 constantly watches for movement. It detects changes in infrared radiation – basically, heat moving around. When a warm body (me, my cat, a very suspicious houseplant) moves in front of it, the sensor output goes HIGH.

Step 2: LoRa Transmission

The ESP32 reads the sensor and sends a command to the RYLR998 LoRa module over UART:

text
AT+SEND=2,1,1

This means: “Send the number 1 to device address 2.” That’s it. One byte of data.

The LoRa module takes this tiny message, modulates it into radio waves, and blasts it out into the world at 915MHz.

Step 3: Long-Range Reception

The receiver’s LoRa module is in receive mode (AT+RCV=1). It’s constantly listening for any messages on the same frequency and network ID.

When it catches the transmission from address 1, it outputs:

text
+RCV=1,1,1,-45,10

This tells me:

  • Sender address: 1

  • Message length: 1 byte

  • Actual data: 1 (motion detected!)

  • RSSI (signal strength): -45 dBm (excellent)

  • SNR (signal-to-noise ratio): 10 dB (very clean signal)

Step 4: Alert!

The receiver ESP32 reads this line from the LoRa module and:

  • Updates the OLED screen to show “Motion: DETECTED” in big red letters

  • Beeps the buzzer three times

  • Turns on an LED (optional)

  • Logs the event to the Serial Monitor

Step 5: Photo Capture (Optional)

If the ESP32-CAM is set up, the receiver sends an HTTP request to its IP address:

text
GET http://192.168.0.221/capture

The ESP32-CAM takes a photo, saves it temporarily, and uploads it to my computer via FTP. The whole process takes about 2-3 seconds.

A three-part technical infographic illustrating a wireless security workflow. Panel 1 shows a receiver node with an ESP32, a Reyax LoRa module, a buzzer, and an OLED display reading "Motion: DETECTED." Panel 2 shows a transmitter node with an ESP32, a LoRa module, and a PIR motion sensor. Arrows labeled "Motion → Alert" and "Wireless LoRa (RYLR998)" connect the hardware. Panel 3 depicts a computer monitor showing a Windows file explorer window titled "CAMotionPics," containing saved JPEG images of a hallway, labeled "Photo Saved." The entire diagram is framed in a futuristic blue digital interface style.

The Code (Without Boring You)

I won’t paste all 500 lines here, but here’s the core logic:

Sender Code (Simplified):

➕➕
filename.cpp
int motion = digitalRead(PIR_PIN);
if (motion == HIGH) {
  loraSerial.print("AT+SEND=2,1,1\r\n");  // Send "1" to receiver address 2
}

Receiver Code (Simplified):

➕➕
filename.cpp
if (loraSerial.available()) {
  String data = loraSerial.readStringUntil('\n');
  if (data.indexOf("+RCV=1,1,1") >= 0) {
    digitalWrite(BUZZER_PIN, HIGH);
    display.println("Motion: DETECTED");
    delay(300);
    digitalWrite(BUZZER_PIN, LOW);
  }
}

The magic happens in the AT commands that configure the LoRa modules:

 
 
CommandWhat It Does
AT+MODE=0Transparent transmission mode
AT+BAND=915000000Set frequency to 915MHz
AT+ADDRESS=1Give this module address 1
AT+NETWORKID=5Create private network 5
AT+SEND=2,1,1Send “1” to address 2

📦 Complete Project on GitHub

All the code, wiring diagrams, and documentation are available on GitHub:

🔗 https://github.com/roborear/esp32-lora-security-system

The repository includes:

  • ✅ Complete Arduino code for Sender, Receiver, and ESP32-CAM

  • ✅ Python FTP server script

  • ✅ Wiring diagrams (Fritzing files)

  • ✅ Detailed README with setup instructions

  • ✅ Bill of materials with links

Star the repo if you find it useful!

What The OLED Display Shows

My receiver screen shows:

 
 
LineInformation
Line 1“LoRa PIR Receiver” (title)
Line 2Status: “Ready” or “Beep 1/3”
Line 3Motion: “None” or “DETECTED”
Line 4Signal: “-45 dBm” (RSSI value)
Line 5SNR: “10 dB” (Signal-to-Noise Ratio)
Line 6“Btn: Capture” (button prompt)

Plus a little signal bar that grows when the signal is stronger.

IMG 20260411 192329893 HDR scaled e1775914100438

The Button Trick

I added a push button on the receiver. When I press it, the receiver sends an HTTP request to the ESP32-CAM (over WiFi) to take a photo. This means I can manually capture an image even if no motion is detected.

The button used to give me phantom presses (it triggered randomly). That’s because I was using GPIO 34, which has no internal pull-up. I switched to GPIO 32 and the problem disappeared.

Lesson learned: Always check if your GPIO pin has a pull-up resistor before using it for buttons.

Testing: Does It Actually Work Through Walls?

I tested the range in my apartment:

 
 
LocationDistanceWallsSignal (RSSI)Result
Same room3m0-35 dBm✅ Perfect
Adjacent room5m1-52 dBm✅ Great
Two rooms away10m2-68 dBm✅ Reliable
Outside, through exterior wall15m1 brick-82 dBm✅ Works

The maximum reliable range inside a house is about 15-20 meters through walls. Outside, with line of sight, it can go 500m+.

Why This is Better Than a $20 WiFi Security Camera

 
 
FeatureMy LoRa Module SystemCheap WiFi Camera
Works without internet✅ Yes❌ No (needs cloud)
Range through walls✅ Excellent❌ Poor (WiFi drops)
Battery possible✅ Yes (LoRa is low power)❌ No (WiFi drains battery)
Customizable✅ Unlimited❌ None
Privacy✅ 100% (no cloud)❌ Footage goes to server
Price~$30-40~$20-30

The cheap camera stops working the moment your internet goes down. My system keeps working even if the whole neighborhood loses connection.

What I Learned

1. LoRa Module is NOT instant

There’s a small delay (about 0.5-1 second) between motion detection and the buzzer. For a security alarm, that’s fine. For a real-time RC car, it would be annoying.

2. Antenna matters

The little spring antennas that come with the modules work fine indoors. But if you want maximum range, solder on a proper quarter-wave wire antenna (about 8.2cm for 915MHz).

3. GPIO pins have personalities

GPIO 34-39 are input-only and have no pull-ups. Use them for sensors (like PIR), not for buttons. GPIO 32-33 have pull-ups and work great for buttons.

4. LoRa errors are normal

When the sender is off, the receiver logs +ERR=4 constantly. That’s just the module saying “I’m listening but nothing is there.” It’s not a problem.

Upgrades I’m Planning

  • Add a second PIR sensor for full room coverage

  • Add an SD card to the receiver to log motion events

  • Replace the buzzer with a voice module (“Intruder detected!”)

  • Make the sender battery-powered (ESP32 deep sleep + LoRa Module sleep mode)

  • Add a temperature/humidity sensor to the sender (why not?)

Your Turn

LoRa modules are cheap, easy to use, and open up a whole world of long-range, battery-friendly projects.

If you build this system (or something similar), tag me. I want to see what you come up with.

And if you get stuck, drop a comment. I was exactly where you are a few months ago.

 

Visit https://roborear.com/blogs/ to read all the blogs

FAQs

Subscribe to The Newsletter

Join robotics enthusiasts getting weekly project ideas:

• 🔧 Under $50 projects

• ⚙️ Under $100 projects

• 🎥 New video tutorials

• 📝 Blog updates

We don’t spam! Read our privacy policy for more info.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *