Contact sales

How to build a portable security system with the Particle Muon

Build a portable IoT security system with Particle Muon and Photon 2, featuring BLE, LTE, and GNSS integration.

Evan Rust article author avatarEvan RustJanuary 17, 2025
How to build a portable security system with the Particle Muon

The problem

Traditional home security systems rely on independent sensors connected to a central hub via Wi-Fi or Ethernet, which requires the hub to stay at a fixed location. This dependency makes the systems less portable and unsuitable for use in remote areas without stable internet connectivity. Additionally, the need to re-register location and Wi-Fi credentials when relocating the system adds complexity and limits flexibility.


The solution

This project leverages the Particle Muon with its LTE/LoRa connectivity and GNSS integration to create a portable security system. By utilizing Bluetooth Low Energy (BLE), the Muon communicates with multiple Particle Photon 2 devices serving as peripheral sensors. This design enables seamless operation in diverse environments without requiring reconfiguration, while providing real-time data to the Particle Cloud. The result is a highly adaptable and portable security solution suitable for various use cases beyond traditional setups.


Bill of materials

  • Particle Muon + Carrier Board Kit: 1x
  • Particle Photon 2: 3x
  • Magnetic reed switch: 1x to 3x
  • Passive Infrared (PIR) sensor: 1x to 3x
  • Analog microphone element: 1x to 3x
  • SSD1306-based OLED screens (optional)

Using BLE

To make this kind of setup work, the peripheral sensing units must be able to communicate back to the Cloud without the need for their own internet connection. And taking it a step further, I wanted the ability for units to be quickly added or removed from the system and avoid tedious provisioning steps.

The system is organized around two different types of devices: a single “central” device and several “peripheral” devices. Each peripheral device advertises a standardized Bluetooth Low-Energy payload which has details about the connected sensors and their states. The central device collects these advertisement payloads, decodes them, and then reports its findings back to the Cloud.

In the code, there exists the concept of a “DeviceReportType” which specifies what kind of sensor is being reported on, including the PIR, microphone element, reed switch, or the dust sensor. Up to 4 of these values can be sent at-a-time in the “DeviceReport” as well as the device’s ID and the number of values that are present. I was even able to leverage a bit packing technique in this struct since BLE advertising packets can only contain a limited number of bytes.

Using Particle’s DeviceOS, the code will begin each loop with a call to stop advertising. Next, data is read from any enabled sensors, placed into the “DeviceReport” object, and then appended to the advertising payload as custom, manufacturer-specific data. Each device is given the local name “SEC_MONITOR” so that the Muon can easily filter nearby BLE devices to only the relevant ones.


The Muon and Photon 2 circuits

In this case, I went with the Particle Muon as the central processor primarily because of its multi-radio connectivity. If it’s used in a residential or commercial environment, the board’s built-in WiFi can reliably communicate with the Particle Cloud and use its LTE radio as a backup. But when deploying it outside of a WiFi access point, either the LTE or LoRaWAN radios can be leveraged for a much greater range.

The peripheral devices are each composed of a single Particle Photon 2 and one or more of the following sensors: a microphone element for ambient sound levels, a passive infrared (PIR) sensor that provides motion detection, or a reed switch that can be used to determine when a door or window is open. I also added a dust sensor to each in order to function as a basic smoke detector. As mentioned before, the Photon 2s periodically transmit BLE advertising packets to the Muon containing the latest sensor readings and then update an OLED screen if one is connected.


The Particle Logic Function and Ledger

The Muon’s code checks for new advertising packets every three seconds by creating a new “BleScanFilter” with the target device name of “SEC_MONITOR” and then passing it to the DeviceOS BLE “scanWithFilter” function which returns a list of scan results. Upon receiving and parsing an advertising packet from a peripheral device, the Muon creates a JSON payload with data about its current GNSS-provided location and any new sensor readings.

For example, if the raw values from a Photon 2 peripheral device are ‘true’ for a PIR sensor and ‘3’ for the air quality sensor, then the Muon can set the current PIR value to “Detected” and the air quality to “High” in the JSON data. And because the Muon has an onboard GNSS receiver, it’s able to poll it for the current coordinates, and if found, place them into the response payload as well. With Ledger, the set values are merged into the current instance so that states from previous readings on other devices remain set.

Now that the Muon could collect all of this real-time data from nearby devices and save it in a Ledger instance, how could it be leveraged outside of the Muon while keeping the system flexible if more devices might need to be added later? For this task, I used a scheduled Particle Logic function which runs once every minute. In it, the function gets the current Ledger instance for the Muon and checks for the presence of data. Once found, it calls the “shouldReport” function that goes through the entries for the PIR, air quality, magnetic, and sound sensors and checks if any one of them necessitates an alert, such as when the state of the magnetic reed switch is “Open” or the dust sensor reads an unhealthy air quality level.

Whenever this function returns true, Logic can publish a Cloud Event to trigger additional actions like sending an SMS message or pushing data to Google Cloud via a webhook, as seen in the screenshot below:


Conclusion

The Particle Muon and its extensible architecture create a highly portable and versatile system, capable of addressing a wide range of use cases beyond security. With its multi-radio connectivity and BLE integration, the system is equally effective for monitoring garden beds, detecting equipment failures, or managing assets in remote areas without Wi-Fi access.

This project showcases the power of Particle technology to deliver scalable and flexible IoT solutions, combining portability, real-time data processing, and cloud integration.

All project code, including firmware for the Muon, Photon 2 devices, and the Logic function, is available in this GitHub repository. Use it as a foundation to build your own innovative IoT applications.

Comments are not currently available for this post.