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

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:
| Technology | Range | Needs WiFi? | Best For |
|---|---|---|---|
| Bluetooth | ~10m | No | Headphones, speakers |
| WiFi | ~30m | Yes (router) | Streaming, internet |
| LoRa | 1-5km+ | No | Sensors, 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:
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:
+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:
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.
Quick Buy Links
| Component | Where to Find |
|---|---|
| RYLR998 LoRa Module | Amazon |
| ESP32 Development Board | AliExpress |
| PIR Motion Sensor | AliExpress |
| 0.96″ OLED Display | AliExpress |
| Buzzer | 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:
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:
+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:
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.

The Code (Without Boring You)
I won’t paste all 500 lines here, but here’s the core logic:
Sender Code (Simplified):
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):
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:
| Command | What It Does |
|---|---|
AT+MODE=0 | Transparent transmission mode |
AT+BAND=915000000 | Set frequency to 915MHz |
AT+ADDRESS=1 | Give this module address 1 |
AT+NETWORKID=5 | Create private network 5 |
AT+SEND=2,1,1 | Send “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:
| Line | Information |
|---|---|
| Line 1 | “LoRa PIR Receiver” (title) |
| Line 2 | Status: “Ready” or “Beep 1/3” |
| Line 3 | Motion: “None” or “DETECTED” |
| Line 4 | Signal: “-45 dBm” (RSSI value) |
| Line 5 | SNR: “10 dB” (Signal-to-Noise Ratio) |
| Line 6 | “Btn: Capture” (button prompt) |
Plus a little signal bar that grows when the signal is stronger.

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:
| Location | Distance | Walls | Signal (RSSI) | Result |
|---|---|---|---|---|
| Same room | 3m | 0 | -35 dBm | ✅ Perfect |
| Adjacent room | 5m | 1 | -52 dBm | ✅ Great |
| Two rooms away | 10m | 2 | -68 dBm | ✅ Reliable |
| Outside, through exterior wall | 15m | 1 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
| Feature | My LoRa Module System | Cheap 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






