Skip to content

Commit 7a8be06

Browse files
authored
Merge pull request #16 from sparkfun/release/v02.00.00
Moving Release to Main
2 parents 86289d0 + d41a879 commit 7a8be06

26 files changed

+5171
-3582
lines changed

LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2025 SparkFun Electronics
3+
Copyright (c) 2024-2025 SparkFun Electronics
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+92-29
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,112 @@
1-
SparkFun XM125 A121 Arduino Library
2-
========================================
31

4-
[![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)
2+
![SparkFun Pulsed Coherent Radar Sensor – Acconeer XM125 (Qwiic)](docs/images/gh-banner-2025-xm125.png "SparkFun Pulsed Coherent Radar Sensor")
53

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

8-
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.
6+
Arduino Library for the SparkFun Pulsed Coherent Radar Sensor
97

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

11-
Repository Contents
12-
-------------------
15+
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!
1316

14-
* **/examples** - Example sketches for the library (.ino). Run these from the Arduino IDE.
15-
* **/src** - Source files for the library (.cpp, .h).
16-
* **/docs** - Datasheet and application note for the XM125 and A121.
17-
* **keywords.txt** - Keywords from this library that will be highlighted in the Arduino IDE.
18-
* **library.properties** - General library properties for the Arduino package manager.
19-
* **[CONTRIBUTING.md](./CONTRIBUTING.md)** - guidance on how to contribute to this library.
17+
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!
2018

19+
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>.
2120

22-
Documentation
23-
--------------
21+
> [!NOTE]
22+
>
23+
> If upgrading from **Version 1** of this library, some changes are required before moving to **Version 2.0+**. The detals of this are outlined in the section titled [Upgrading to Version 2 from Version 1](#upgrading-to-version-2-from-version-1) later in this document.
2424
25-
* **[Installing an Arduino Library Guide](https://learn.sparkfun.com/tutorials/installing-an-arduino-library)** - Basic information on how to install an Arduino library.
26-
* **[Hookup Guide](https://docs.sparkfun.com/SparkFun_Qwiic_Pulsed_Radar_Sensor_XM125)** - Basic hookup guide for the SparkFUn Qwiic Pulsed Coherent Radar Sensor - XM125.
27-
* **[Product Repository](https://github.com/sparkfun/SparkFun_Qwiic_Pulsed_Radar_Sensor_XM125)** - Main repository for the SparkFun Qwiic XM125 (including hardware files)
25+
## Functionality
2826

27+
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.
2928

30-
Products that use this Library
31-
---------------------------------
29+
When running as a I2C client device, the Acconeer XM125 is loaded with a specific firmware application from Acconeer.
3230

33-
* [*SEN-24540*](https://www.sparkfun.com/products/24540)
31+
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.
3432

33+
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.
3534

36-
License Information
37-
-------------------
35+
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:
3836

39-
This product is _**open source**_!
37+
|Function|Firmware| Library Class To Use|
38+
|---|---|--|
39+
|Distance Detection | `i2c_distance_detector` | `SparkFunXM125Distance`|
40+
|Presence Detection | `i2c_presence_detector` | `SparkFunXM125Presence`|
4041

41-
Please review the LICENSE.md file for license information.
42+
## Documentation
4243

43-
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).
44+
|Reference | Description |
45+
|---|---|
46+
|[Quick Reference](https://docs.sparkfun.com/SparkFun_Qwiic_XM125_Arduino_Library/class_qw_dev_x_m125.html)| A quick reference API for the the main library object ```QwDevXM125```|
47+
|[Full Documentation](https://docs.sparkfun.com/SparkFun_Qwiic_XM125_Arduino_Library/)| The full documentation and API for this Arduino library|
48+
|[SparkFun Pulsed Coherent Radar Sensor](https://github.com/sparkfun/SparkFun_Qwiic_Pulsed_Radar_Sensor_XM125)| Hardware GitHub Repository|
49+
|[Hook Up Guide](https://docs.sparkfun.com/SparkFun_Qwiic_Pulsed_Radar_Sensor_XM125/introduction/) | Hardware Overview and Quick Start for the XM125 Qwiic Development Board |
4450

45-
Distributed as-is; no warranty is given.
51+
## Examples
4652

47-
- Your friends at SparkFun.
53+
The following examples are provided with the library
4854

49-
_<COLLABORATION CREDIT>_
55+
| Example | Description |
56+
|---|---|
57+
|[Presence Basic Readings](examples/Example01_PresenceBasicReadings/Example01_PresenceBasicReadings.ino)| The sensor is initialized, then the presence distance values will print out to the terminal.|
58+
| [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. |
59+
|[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.|
60+
|[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.|
61+
|[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.|
62+
|[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. |
63+
|[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. |
64+
|[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.|
65+
|[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. |
66+
67+
## Documentation
68+
69+
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).
70+
71+
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).
72+
73+
The Hookup Guide for the SparkFun Qwiic Soil Moisture Sensor is available [here](https://docs.sparkfun.com/SparkFun_Qwiic_Pulsed_Radar_Sensor_XM125/introduction/).
74+
75+
## License Information
76+
77+
This product is ***open source***!
78+
79+
This product is licensed using the [MIT Open Source License](https://opensource.org/license/mit).
80+
81+
## Upgrading to Version 2 from Version 1
82+
83+
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, `SfeXM125`, was divided into two distinct classes for schemantic clarity and code simplification.
84+
85+
### Version 2.0 Changes
86+
87+
#### Classes
88+
89+
The device single class was devided into two classes - one for each specific I2C application that the Acconeer XM125 can run. These classes are:
90+
91+
* SparkFunXM125Distance - Used when the XM125 is running the ***Distance*** application
92+
* SparkFunXM125Presence - Used when the XM125 is running the ***Presence*** application
93+
94+
#### Method Names
95+
96+
Additionally, the method naming pattern for each application was simplified - removing *Distance* and *Presence* from method names.
97+
98+
### Supporting Version 1.* Implementations
99+
100+
To simplify the transition from an application written using the Version 1.* library, two compatiblity classes are provided:
101+
102+
* SparkFunXM125DistanceV1 - Used when the XM125 is running the ***Distance*** application
103+
* SparkFunXM125PresenceV1 - Used when the XM125 is running the ***Presence*** application
104+
105+
These classes implement the version 1.*method names for the library, to minimize the porting requirements when upgrading to Version 2.*.
106+
107+
To upgrade to Version 2.0 of the library, perform one of the following:
108+
109+
* If the Acconeer XM125 is running the I2C Distance Application: Rename the device class from `SfeXM125` to `SparkFunXM125DistanceV1`
110+
* If the Acconeer XM125 is running the I2C Presence Application: Rename the device class from `SfeXM125` to `SparkFunXM125PresenceV1`
111+
112+
Once the class name is changed, your application is ready to use version 2.* of this library.

docs/images/gh-banner-2025-xm125.png

425 KB
Loading

examples/Example01_PresenceBasicReadings/Example01_PresenceBasicReadings.ino

+50-40
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
Using the Acconeer XM125 A121 60GHz Pulsed Coherent Radar Sensor.
55
66
This example shows how operate the XM125 when the device is in Presence Reading Mode.
7-
The sensor is initialized, then the presence distance values will print out
7+
The sensor is initialized, then the presence distance values will print out
88
to the terminal.
99
1010
By: Madison Chodikov
1111
SparkFun Electronics
1212
Date: 2024/1/22
1313
SparkFun code, firmware, and software is released under the MIT License.
14-
Please see LICENSE.md for further details.
14+
Please see LICENSE.md for further details.
1515
1616
Hardware Connections:
1717
QWIIC --> QWIIC
@@ -21,15 +21,15 @@
2121
Feel like supporting our work? Buy a board from SparkFun!
2222
https://www.sparkfun.com/products/ - Qwiic XM125 Breakout
2323
*/
24-
#include <Arduino.h>
2524
#include "SparkFun_Qwiic_XM125_Arduino_Library.h"
25+
#include <Arduino.h>
2626

27-
SfeXM125 radarSensor;
27+
SparkFunXM125Presence radarSensor;
2828

2929
// I2C default address
3030
uint8_t i2cAddress = SFE_XM125_I2C_ADDRESS;
3131

32-
// Presence distance values
32+
// Presence distance values
3333
uint32_t distance = 0;
3434

3535
// Error statuses
@@ -39,69 +39,79 @@ int32_t setupError = 0;
3939
int32_t presValError = 0;
4040
int32_t detectorError = 0;
4141

42+
// Presence range in mm used
43+
#define MY_XM125_RANGE_START 200
44+
#define MY_XM125_RANGE_END 1000
4245
void setup()
4346
{
4447
// Start serial
4548
Serial.begin(115200);
49+
50+
Serial.println("");
51+
Serial.println("-------------------------------------------------------");
4652
Serial.println("XM125 Example 1: Basic Presence Readings");
53+
Serial.println("-------------------------------------------------------");
4754
Serial.println("");
4855

4956
Wire.begin();
5057

5158
// If begin is successful (1), then start example
52-
int startErr = radarSensor.begin(i2cAddress, Wire);
53-
if(startErr == 1)
54-
{
55-
Serial.println("Begin");
56-
}
57-
else // Otherwise, infinite loop
59+
bool success = radarSensor.begin(i2cAddress, Wire);
60+
if (success == false)
5861
{
59-
Serial.print("Start Error Code: ");
60-
Serial.println(startErr);
6162
Serial.println("Device failed to setup - Freezing code.");
62-
while(1); // Runs forever
63+
while (1)
64+
; // Runs forever
6365
}
6466

6567
// Start the sensor with default register values
66-
int32_t setupError = radarSensor.presenceDetectorStart();
67-
if(setupError != 0)
68+
int32_t setupError = radarSensor.detectorStart(MY_XM125_RANGE_START, MY_XM125_RANGE_END);
69+
if (setupError != 0)
6870
{
69-
Serial.print("Presence Detection Start Setup Error: ");
70-
Serial.println(setupError);
71+
Serial.print("Presence Detection Start Setup Error: ");
72+
Serial.println(setupError);
7173
}
72-
73-
// New line and delay for easier reading
74+
Serial.print("Presense Detection Started - range: ");
75+
Serial.print(MY_XM125_RANGE_START);
76+
Serial.print("mm to ");
77+
Serial.print(MY_XM125_RANGE_END);
78+
Serial.println("mm");
7479
Serial.println();
80+
7581
delay(500);
7682
}
7783

7884
void loop()
7985
{
8086
// Busy wait loop until data is ready
81-
radarSensor.presenceBusyWait();
87+
radarSensor.busyWait();
8288

83-
// Get the presence distance value and print out if no errors
84-
presValError = radarSensor.getPresenceDistanceValuemm(distance);
89+
// Get the presence distance value and print out if no errors.
90+
// Note - this returns if Presence is detected now, or since last check (sticky)
91+
presValError = radarSensor.getDistanceValuemm(distance);
8592

86-
if(presValError == 0)
93+
if (presValError == 0)
8794
{
88-
Serial.print("Presence Detected: ");
89-
Serial.print(distance);
90-
Serial.println("mm");
91-
//Serial.print(distance * .01);
92-
//Serial.println("cm");
93-
//Serial.print(distance * .001);
94-
//Serial.println("m");
95-
//Serial.print(distance * .001);
96-
//Serial.println("m");
97-
//Serial.print(distance * .03937008);
98-
//Serial.println("In");
95+
Serial.print("Presence Detected: ");
96+
// if distance is > 0, presence is detected, else it is not
97+
if (distance > 0)
98+
{
99+
Serial.print("YES - Distance: ");
100+
Serial.print(distance);
101+
Serial.print("mm, ");
102+
Serial.print(distance * .1);
103+
Serial.print("cm, ");
104+
Serial.print(distance * .001);
105+
Serial.print("m, ");
106+
Serial.print(distance * .03937008);
107+
Serial.println("In");
108+
}
109+
else
110+
Serial.println("NO");
99111
}
100112
else
101-
{
102-
Serial.println("Error returning presence distance value");
103-
}
113+
Serial.println("Error returning presence distance value");
104114

105-
// Delay 0.5 seconds between readings
106-
delay(500);
115+
// Delay 2.5 seconds between readings
116+
delay(2500);
107117
}

0 commit comments

Comments
 (0)