Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
64b8c2e
iniital port/move to sparkfun_toolkit v1.0 done - basic readings comp…
gigapod Feb 14, 2025
04f749e
fix issue in example 1 - mm to cm conversion bug
gigapod Feb 14, 2025
5fda0b2
cleanup and big mask fun
gigapod Feb 15, 2025
2590389
code cleanup, file header comments; logic clean-up and error checking…
gigapod Feb 15, 2025
af769f4
fix or - need boolean op, not bit op
gigapod Feb 15, 2025
4a5cb52
remove template leftover
gigapod Feb 15, 2025
6c7b0d7
add contextual naming to the *html* sub-dir
gigapod Feb 15, 2025
fdb1ab2
moved documents folder to docs, the correct and common name used
gigapod Feb 15, 2025
9c3ca10
fixed license to something that is an actual software license
gigapod Feb 15, 2025
4c3030b
update to readme -- in progress
gigapod Feb 15, 2025
6cbbb98
new banner for a new year
gigapod Feb 15, 2025
1bfddbb
most updates completed
gigapod Feb 15, 2025
8a88fd7
added examples
gigapod Feb 15, 2025
14f6a2a
tweaks for ghpages link
gigapod Feb 15, 2025
2331f77
Merge pull request #7 from sparkfun/main
gigapod Feb 15, 2025
e741557
Merge branch 'develop' into feature/sf-toolkit-v1
gigapod Feb 15, 2025
f859b40
Merge pull request #8 from sparkfun/feature/sf-toolkit-v1
gigapod Feb 15, 2025
eed0618
fix issue #5 relating to strength measurements; fix bool bus reads/wr…
gigapod Feb 15, 2025
14e5b0b
broke up the impl file - was freeking massive - now two files
gigapod Feb 15, 2025
b2b59ec
moved the big mask check macro to header for both impl files to use
gigapod Feb 15, 2025
4d59101
BIG refactor of class structure - broke the main class into two class…
gigapod Feb 15, 2025
577cf09
added note about class changes and how to port code forward to v2 of …
gigapod Feb 15, 2025
afdfb1f
use header, not note tag
gigapod Feb 15, 2025
07b9926
use header, not note tag
gigapod Feb 15, 2025
66d41da
Merge pull request #9 from sparkfun/feature/class-refactor
gigapod Feb 15, 2025
8cfa78f
added endian support; move readReg/writeReg to new methods that manag…
gigapod Feb 19, 2025
461a7ea
changes made to use the new toolkit api ; more work for simplificatio…
gigapod Feb 21, 2025
4a95723
cleanup the getDisatnceValue method logic - to match vendors example.…
gigapod Mar 13, 2025
cbdc7c2
added a start and end value to the detectorStart() method, with defau…
gigapod Mar 13, 2025
cbbab48
cleanup on distance method logic
gigapod Mar 14, 2025
1f56fec
fix consant name typo, remove ununsed var
gigapod Mar 14, 2025
e7de189
cleanup demo - formatting and logic
gigapod Mar 14, 2025
d54fde2
better comment
gigapod Mar 14, 2025
dde1786
added start and end range to begin method; added generic distance and…
gigapod Mar 14, 2025
7909e5a
cleanup; make use of new methods ; simplify and improve output
gigapod Mar 14, 2025
c53f413
cleanup; make use of new methods ; simplify and improve output
gigapod Mar 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
MIT License

Copyright (c) 2025 SparkFun Electronics

Copyright (c) 2024-2025 SparkFun Electronics


Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -19,3 +21,4 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

94 changes: 65 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,85 @@
SparkFun XM125 A121 Arduino Library
========================================

[![SparkFun Pulsed Coherent Radar Sensor – Acconeer XM125 (Qwiic)](https://cdn.sparkfun.com/r/600-600/assets/parts/2/4/8/6/5/SEN-24540-Pulsed-Coherent-Radar-Sensor-Feature.jpg)](https://www.sparkfun.com/products/24540)
![SparkFun Pulsed Coherent Radar Sensor – Acconeer XM125 (Qwiic)](docs/images/gh-banner-2025-xm125.png "SparkFun Pulsed Coherent Radar Sensor")

[*SparkFun Pulsed Coherent Radar Sensor – Acconeer XM125 (Qwiic) (SEN-24540)*](https://www.sparkfun.com/products/24540)
# SparkFun Pulsed Coherent Radar Sensor – Acconeer XM125

This is the SparkFun library for the Acconeer Entry+ Module XM125 with the A121 60GHz Pulsed Coherent Radar sensor and I<sup>2</sup>C interface.
Arduino Library for the SparkFun Pulsed Coherent Radar Sensor

![License](https://img.shields.io/github/license/sparkfun/SparkFun_Qwiic_XM125_Arduino_Library)
![Release](https://img.shields.io/github/v/release/sparkfun/SparkFun_Qwiic_XM125_Arduino_Library)
![Release Date](https://img.shields.io/github/release-date/sparkfun/SparkFun_Qwiic_XM125_Arduino_Library)
![Documentation - build](https://img.shields.io/github/actions/workflow/status/sparkfun/SparkFun_Qwiic_XM125_Arduino_Library/build-deploy-ghpages.yml?label=doc%20build)
![Compile - Test](https://img.shields.io/github/actions/workflow/status/sparkfun/SparkFun_Qwiic_XM125_Arduino_Library/test-compile-sketch.yml?label=compile%20test)
![GitHub issues](https://img.shields.io/github/issues/sparkfun/SparkFun_Qwiic_XM125_Arduino_Library)

Repository Contents
-------------------

* **/examples** - Example sketches for the library (.ino). Run these from the Arduino IDE.
* **/src** - Source files for the library (.cpp, .h).
* **/docs** - Datasheet and application note for the XM125 and A121.
* **keywords.txt** - Keywords from this library that will be highlighted in the Arduino IDE.
* **library.properties** - General library properties for the Arduino package manager.
* **[CONTRIBUTING.md](./CONTRIBUTING.md)** - guidance on how to contribute to this library.
The [SparkFun Pulsed Coherent Radar Sensor - Acconeer XM125 (SEN-24540)](https://www.sparkfun.com/sparkfun-pulsed-coherent-radar-sensor-acconeer-xm125-qwiic.html) brings powerful 60 GHz radar technology to your projects. This sensor isn't limited to surface detection; it can see through walls, cabinets, and even pockets (depending on the material), making it perfect for unique applications. Measure distances with millimeter precision, detect motion, the speed of an object, or even gestures!

The XM125 boasts an impressive range of up to 20 meters, allowing you to create long-range sensing projects. The actual measurable distance is dependent on the object size, shape, dielectric properties, and lens (e.g. water level measurements up to 20 meters with lens utilization, human presence detection up to 7 meters with lens-free utilization). Despite its power, the sensor has remarkably low in power consumption, which is ideal for battery-powered applications. The real magic lies in the sensor's ability to do more than measure distance; the XM125 can differentiate between stationary objects and moving targets using pulsed coherent radar. This means you can sense an object's presence and how fast something is moving!

Documentation
--------------
Looking for the board that matches this library - pick up a [SparkFun Pulsed Coherent Radar Sensor - Acconeer XM125 (Qwiic)](https://www.sparkfun.com/sparkfun-pulsed-coherent-radar-sensor-acconeer-xm125-qwiic.html) at www.sparkfun.com.

* **[Installing an Arduino Library Guide](https://learn.sparkfun.com/tutorials/installing-an-arduino-library)** - Basic information on how to install an Arduino library.
* **[Hookup Guide](https://docs.sparkfun.com/SparkFun_Qwiic_Pulsed_Radar_Sensor_XM125)** - Basic hookup guide for the SparkFUn Qwiic Pulsed Coherent Radar Sensor - XM125.
* **[Product Repository](https://github.com/sparkfun/SparkFun_Qwiic_Pulsed_Radar_Sensor_XM125)** - Main repository for the SparkFun Qwiic XM125 (including hardware files)
### *Upgrading to Version 2.\* from Version 1.\**

Version 2.0+ of this library is not compatible with Version 1.* implementations/use. For Version 2.0, the single class defined by the library, `SparkFunXM125`, was divided into two distinct classes:

Products that use this Library
---------------------------------
* SparkFunXM125Distance - Used when the XM125 is running the ***Distance*** application
* SparkFunXM125Presence - Used when the XM125 is running the ***Presence*** application

* [*SEN-24540*](https://www.sparkfun.com/products/24540)
Moving to use Version 2.0 of the library just requires changing the class name used in your sketch - from `SparkFunXM125` to either `SparkFunXM125Distance` or `SparkFunXM125Presence`

## Functionality

License Information
-------------------
The SparkFun Pulsed Coherent Radar sensor can run as an I2C client device, or as a standalone development board. This library is used when the sensor is operating as a standalone I2C device.

This product is _**open source**_!
When running as a I2C client device, the Acconeer XM125 is loaded with a specific firmware application from Acconeer.

Please review the LICENSE.md file for license information.
The *SparkFun Pulsed Coherent Radar Sensor - Acconeer XM125* comes with the ***Presence Detector*** firmware loaded, which is accessible using the ***Presence*** focused methods in this library.

If you have any questions or concerns on licensing, please contact technical support on our [SparkFun forums](https://forum.sparkfun.com/viewforum.php?f=152).
This library also supports the ***Distance Detection*** application firmware from Acconeer. To enable this functionally, the ***Distance Detection*** firmware must be loaded onto the *SparkFun Pulsed Coherent Radar Sensor - Acconeer XM125* board. The firmware is available from [Acconeer](https://developer.acconeer.com/home/a121-docs-software/xm125-xe125/) as part of the XM125/A121 SDK. The files are located in the `out/` folder - with naming patter of `i2c_*_detector.bin`. Install instructions are noted in our [Hook Up Guide](https://docs.sparkfun.com/SparkFun_Qwiic_Pulsed_Radar_Sensor_XM125/introduction/) for the product.

Distributed as-is; no warranty is given.

- Your friends at SparkFun.
This library provides a extensive interface that enables the following functionality/interaction with the SparkFun Pulsed Coherent Radar Sensor when the sensor is operating as an I2C sensor device:

|Function|Firmware|
|---|---|
|Distance Detection | `i2c_distance_detector` |
|Presence Detection | `i2c_presence_detector` |

## General Use

### TO DO


## Examples

The following examples are provided with the library

| Example | Description |
|---|---|
|[Presence Basic Readings](examples/Example01_PresenceBasicReadings/Example01_PresenceBasicReadings.ino)| The sensor is initialized, then the presence distance values will print out to the terminal.|
| [Presence GPIO 0 Usage](examples/Example02_PresenceGPIO0Usage/Example02_PresenceGPIO0Usage.ino)|The sensor is initialized, then the presence values will print out to the terminal and trigger the GPIO0 pin high when there is a presence detected. |
|[Presence Serial Plotter](examples/Example03_PresenceSerialPlotter/Example03_PresenceSerialPlotter.ino)|The sensor is initialized, then the presence values will print out to the terminal and the serial monitor.|
|[Presence Advanced Readings](examples/Example04_PresenceAdvancedReadings/Example04_PresenceAdvancedReadings.ino)|The sensor is initialized, then the presence distance, intra-presence, and inter-presence values will be printed to the terminal.|
|[Presence Advanced Settings](examples/Example05_PresenceAdvancedSettings/Example05_PresenceAdvancedSettings.ino)|The sensor is initialized, then the presence distance values will print out to the terminal just as they do in example one. If you wish to change the settings of the device, do so before applying the configuration.|
|[Distance Basic Readings](examples/Example06_DistanceBasicReadings/Example06_DistanceBasicReadings.ino)|The sensor is initialized, then the distance values will print out to the terminal in mm. |
|[Distance Threshold Settings](examples/Example07_DistanceThresholdSettings/Example07_DistanceThresholdSettings.ino)|The sensor is initialized, then the distance amplitude, and strength , fixed amplitude, and sensitivity thresholds are set. |
|[Distance Serial Plotter](examples/Example08_DistanceSerialPlotter/Example08_DistanceSerialPlotter.ino)|This example prints out the distance values of the 0 distance channels to the serial plotter tool in Arduino.|
|[Distance Advanced Settings](examples/Example09_DistanceAdvancedSettings/Example09_DistanceAdvancedSettings.ino)|The sensor is initialized, then the distance (mm) and advanced values are output to the terminal. |


## Documentation

The full API and use documentation for this library is provided [here](https://docs.sparkfun.com/SparkFun_Qwiic_XM125_Arduino_Library/). For a quick reference, the main methods available in the library are listed [here](https://docs.sparkfun.com/SparkFun_Qwiic_XM125_Arduino_Library/class_qw_dev_x_m125.html).

Curious about the hardware this board works with - visit the SparkFun Pulsed Coherent Radar Sensor [hardware repository](https://github.com/sparkfun/SparkFun_Qwiic_Pulsed_Radar_Sensor_XM125).

The Hookup Guide for the SparkFun Qwiic Soil Moisture Sensor is available [here](https://docs.sparkfun.com/SparkFun_Qwiic_Pulsed_Radar_Sensor_XM125/introduction/).

## License Information

This product is ***open source***!

This product is licensed using the [MIT Open Source License](https://opensource.org/license/mit).


_<COLLABORATION CREDIT>_
Binary file added docs/images/gh-banner-2025-xm125.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
Using the Acconeer XM125 A121 60GHz Pulsed Coherent Radar Sensor.

This example shows how operate the XM125 when the device is in Presence Reading Mode.
The sensor is initialized, then the presence distance values will print out
The sensor is initialized, then the presence distance values will print out
to the terminal.

By: Madison Chodikov
SparkFun Electronics
Date: 2024/1/22
SparkFun code, firmware, and software is released under the MIT License.
Please see LICENSE.md for further details.
Please see LICENSE.md for further details.

Hardware Connections:
QWIIC --> QWIIC
Expand All @@ -21,15 +21,15 @@
Feel like supporting our work? Buy a board from SparkFun!
https://www.sparkfun.com/products/ - Qwiic XM125 Breakout
*/
#include <Arduino.h>
#include "SparkFun_Qwiic_XM125_Arduino_Library.h"
#include <Arduino.h>

SfeXM125 radarSensor;
SparkFunXM125Presence radarSensor;

// I2C default address
uint8_t i2cAddress = SFE_XM125_I2C_ADDRESS;

// Presence distance values
// Presence distance values
uint32_t distance = 0;

// Error statuses
Expand All @@ -39,39 +39,45 @@ int32_t setupError = 0;
int32_t presValError = 0;
int32_t detectorError = 0;

// Presence range in mm used
#define MY_XM125_RANGE_START 200
#define MY_XM125_RANGE_END 1000
void setup()
{
// Start serial
Serial.begin(115200);

Serial.println("");
Serial.println("-------------------------------------------------------");
Serial.println("XM125 Example 1: Basic Presence Readings");
Serial.println("-------------------------------------------------------");
Serial.println("");

Wire.begin();

// If begin is successful (1), then start example
int startErr = radarSensor.begin(i2cAddress, Wire);
if(startErr == 1)
{
Serial.println("Begin");
}
else // Otherwise, infinite loop
bool success = radarSensor.begin(i2cAddress, Wire);
if (success == false)
{
Serial.print("Start Error Code: ");
Serial.println(startErr);
Serial.println("Device failed to setup - Freezing code.");
while(1); // Runs forever
while (1)
; // Runs forever
}

// Start the sensor with default register values
int32_t setupError = radarSensor.presenceDetectorStart();
if(setupError != 0)
int32_t setupError = radarSensor.presenceDetectorStart(MY_XM125_RANGE_START, MY_XM125_RANGE_END);
if (setupError != 0)
{
Serial.print("Presence Detection Start Setup Error: ");
Serial.println(setupError);
Serial.print("Presence Detection Start Setup Error: ");
Serial.println(setupError);
}

// New line and delay for easier reading
Serial.print("Presense Detection Started - range: ");
Serial.print(MY_XM125_RANGE_START);
Serial.print("mm to ");
Serial.print(MY_XM125_RANGE_END);
Serial.println("mm");
Serial.println();

delay(500);
}

Expand All @@ -80,28 +86,32 @@ void loop()
// Busy wait loop until data is ready
radarSensor.presenceBusyWait();

// Get the presence distance value and print out if no errors
// Get the presence distance value and print out if no errors.
// Note - this returns if Presense is detected now, or since last check (sticky)
presValError = radarSensor.getPresenceDistanceValuemm(distance);

if(presValError == 0)
if (presValError == 0)
{
Serial.print("Presence Detected: ");
Serial.print(distance);
Serial.println("mm");
//Serial.print(distance * .01);
//Serial.println("cm");
//Serial.print(distance * .001);
//Serial.println("m");
//Serial.print(distance * .001);
//Serial.println("m");
//Serial.print(distance * .03937008);
//Serial.println("In");
Serial.print("Presence Detected: ");
// if distance is > 0, presence is detected, else it is not
if (distance > 0)
{
Serial.print("YES - Distance: ");
Serial.print(distance);
Serial.print("mm, ");
Serial.print(distance * .1);
Serial.print("cm, ");
Serial.print(distance * .001);
Serial.print("m, ");
Serial.print(distance * .03937008);
Serial.println("In");
}
else
Serial.println("NO");
}
else
{
Serial.println("Error returning presence distance value");
}
Serial.println("Error returning presence distance value");

// Delay 0.5 seconds between readings
delay(500);
// Delay 2.5 seconds between readings
delay(2500);
}
Loading