Skip to content

Commit 78001bd

Browse files
committed
First release
1 parent f9f5007 commit 78001bd

File tree

19 files changed

+25656
-1
lines changed

19 files changed

+25656
-1
lines changed

README.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,47 @@
11
# X-NUCLEO-IKS5A1
2-
Arduino library to support industrial motion MEMS and environmental sensor expansion board
2+
3+
The X-NUCLEO-IKS5A1 is a industrial motion MEMS sensor expansion board for the STM32 Nucleo.
4+
It is equipped with Arduino UNO R3 connector layout, and is designed around the ISM6HG256X 3D accelerometer and 3D gyroscope,
5+
the ISM330IS 3D accelerometer and 3D gyroscope with ISPU, the IIS2DULPX 3D accelerometer, the IIS2MDC 3D magnetometer,
6+
and the ILPS22QS pressure sensor.
7+
The X-NUCLEO-IKS5A1 interfaces with the STM32 microcontroller or the Arduino boards via the I²C pin.
8+
9+
# Examples
10+
11+
There are several examples with the X-NUCLEO-IKS5A1 library.
12+
* X_NUCLEO_IKS5A1_HelloWorld: This application provides a simple example of usage of the X-NUCLEO-IKS5A1
13+
Expansion Board. It shows how to display on a hyperterminal the values of all on-board industrial MEMS sensors.
14+
* X_NUCLEO_IKS5A1_IIS2DULPX_6D_Orientation: This application shows how to use IIS2DULPX sensor to find out the 6D orientation and display data on a hyperterminal.
15+
* X_NUCLEO_IKS5A1_IIS2DULPX_Wake_Up_Detection: This application shows how to detect the wake-up event using the IIS2DULPX sensor.
16+
* X_NUCLEO_IKS5A1_ISM6HG256X_6D_Orientation: This application shows how to use ISM6HG256X to find out the 6D orientation and display data on a hyperterminal.
17+
* X_NUCLEO_IKS5A1_ISM6HG256X_Double_Tap_Detection: This application shows how to detect the double tap event using the ISM6HG256X.
18+
* X_NUCLEO_IKS5A1_ISM6HG256X_FIFO_Polling: This application shows how to get data from FIFO in pooling mode and print them on terminal.
19+
* X_NUCLEO_IKS5A1_ISM6HG256X_FIFO_Interrupt: This application shows how to get data from FIFO using interrupt and print them on terminal.
20+
* X_NUCLEO_IKS5A1_ISM6HG256X_Free_Fall_Detection: This application shows how to detect the free fall event using the ISM6HG256X.
21+
* X_NUCLEO_IKS5A1_ISM6HG256X_Pedometer: This application shows how to use ISM6HG256X to count steps.
22+
* X_NUCLEO_IKS5A1_ISM6HG256X_Single_Tap_Detection: This application shows how to detect the single tap event using the ISM6HG256X.
23+
* X_NUCLEO_IKS5A1_ISM6HG256X_Tilt_Detection: This application shows how to detect the tilt event using the ISM6HG256X.
24+
* X_NUCLEO_IKS5A1_ISM6HG256X_Wake_Up_Detection: This application shows how to detect the wake-up event using the ISM6HG256X.
25+
* X_NUCLEO_IKS5A1_ISM330IS_ISPU_Sensor_Fusion: This application implements the sensor fusion of the accelerometer and gyroscope,
26+
configured in high-performance mode at 104 Hz. The configuration generates an interrupt on INT1 when the quaternion for the new sample
27+
is computed and available in the output registers.
28+
* X_NUCLEO_IKS5A1_ISM330IS_ISPU_Tap: This application implements the tap detection solution based on the accelerometer data.
29+
The configuration generates an interrupt on INT1 when the tap event for the new sample is computed and available in the output registers.
30+
31+
# Dependencies
32+
33+
The X-NUCLEO-IKS5A1 library requires the following STM32duino libraries:
34+
35+
* STM32duino ISM6HG256X: https://github.com/stm32duino/ISM6HG256X
36+
* STM32duino ISM330IS: https://github.com/stm32duino/ISM330IS
37+
* STM32duino IIS2DULPX: https://github.com/stm32duino/IIS2DULPX
38+
* STM32duino IIS2MDC: https://github.com/stm32duino/IIS2MDC
39+
* STM32duino ILPS22QS: https://github.com/stm32duino/ILPS22QS
40+
41+
## Documentation
42+
43+
You can find the source files at
44+
https://github.com/stm32duino/X-NUCLEO-IKS5A1
45+
46+
The X-NUCLEO-IKS5A1 datasheet is available at
47+
https://www.st.com/en/ecosystems/x-nucleo-iks5a1.html
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
/*
2+
@file X_NUCLEO_IKS5A1_HelloWorld.ino
3+
@author STMicroelectronics
4+
@brief Example to use the STMicrolectronics X-NUCLEO-IKS5A1
5+
*******************************************************************************
6+
Copyright (c) 2025, STMicroelectronics
7+
All rights reserved.
8+
This software component is licensed by ST under BSD 3-Clause license,
9+
the "License"; You may not use this file except in compliance with the
10+
License. You may obtain a copy of the License at:
11+
opensource.org/licenses/BSD-3-Clause
12+
*******************************************************************************
13+
*/
14+
15+
// Includes
16+
#include <ILPS22QSSensor.h>
17+
#include <ISM6HG256XSensor.h>
18+
#include <ISM330ISSensor.h>
19+
#include <IIS2DULPXSensor.h>
20+
#include <IIS2MDCSensor.h>
21+
22+
#ifdef ARDUINO_SAM_DUE
23+
#define DEV_I2C Wire1
24+
#elif defined(ARDUINO_ARCH_STM32)
25+
#define DEV_I2C Wire
26+
#elif defined(ARDUINO_ARCH_AVR)
27+
#define DEV_I2C Wire
28+
#else
29+
#define DEV_I2C Wire
30+
#endif
31+
#define SerialPort Serial
32+
33+
// Components
34+
ILPS22QSSensor PressTemp(&DEV_I2C);
35+
ISM6HG256XSensor AccGyr(&DEV_I2C);
36+
ISM330ISSensor AccGyr2(&DEV_I2C);
37+
IIS2DULPXSensor Acc3(&DEV_I2C);
38+
IIS2MDCSensor Mag(&DEV_I2C);
39+
40+
void setup() {
41+
// Led.
42+
pinMode(LED_BUILTIN, OUTPUT);
43+
44+
// Initialize serial for output.
45+
SerialPort.begin(115200);
46+
47+
// Initialize I2C bus.
48+
DEV_I2C.begin();
49+
50+
PressTemp.begin();
51+
PressTemp.Enable();
52+
AccGyr.begin();
53+
AccGyr.Enable_X();
54+
AccGyr.Enable_G();
55+
AccGyr2.begin();
56+
AccGyr2.Enable_X();
57+
AccGyr2.Enable_G();
58+
Acc3.begin();
59+
Acc3.Enable_X();
60+
Mag.begin();
61+
Mag.Enable();
62+
}
63+
64+
void loop() {
65+
// Led blinking.
66+
digitalWrite(LED_BUILTIN, HIGH);
67+
delay(250);
68+
digitalWrite(LED_BUILTIN, LOW);
69+
delay(250);
70+
71+
// Read pressure and temperature.
72+
float pressure = 0, temperature = 0;
73+
PressTemp.GetPressure(&pressure);
74+
PressTemp.GetTemperature(&temperature);
75+
76+
// Read accelerometer and gyroscope.
77+
ISM6HG256X_Axes_t accelerometer;
78+
ISM6HG256X_Axes_t gyroscope;
79+
AccGyr.Get_X_Axes(&accelerometer);
80+
AccGyr.Get_G_Axes(&gyroscope);
81+
82+
// Read accelerometer and gyroscope.
83+
ISM330IS_Axes_t accelerometer2;
84+
ISM330IS_Axes_t gyroscope2;
85+
AccGyr2.Get_X_Axes(&accelerometer2);
86+
AccGyr2.Get_G_Axes(&gyroscope2);
87+
88+
//Read accelerometer
89+
IIS2DULPX_Axes_t accelerometer3;
90+
Acc3.Get_X_Axes(&accelerometer3);
91+
92+
//Read magnetometer
93+
int32_t magnetometer[3];
94+
Mag.GetAxes(magnetometer);
95+
96+
// Output data.
97+
SerialPort.print("| Pres[hPa]: ");
98+
SerialPort.print(pressure, 2);
99+
SerialPort.print(" | Temp[C]: ");
100+
SerialPort.print(temperature, 2);
101+
SerialPort.println(" |");
102+
SerialPort.print("| Acc[mg]: ");
103+
SerialPort.print(accelerometer.x);
104+
SerialPort.print(" ");
105+
SerialPort.print(accelerometer.y);
106+
SerialPort.print(" ");
107+
SerialPort.print(accelerometer.z);
108+
SerialPort.print(" | Gyr[mdps]: ");
109+
SerialPort.print(gyroscope.x);
110+
SerialPort.print(" ");
111+
SerialPort.print(gyroscope.y);
112+
SerialPort.print(" ");
113+
SerialPort.print(gyroscope.z);
114+
SerialPort.println(" |");
115+
SerialPort.print("| Acc2[mg]: ");
116+
SerialPort.print(accelerometer2.x);
117+
SerialPort.print(" ");
118+
SerialPort.print(accelerometer2.y);
119+
SerialPort.print(" ");
120+
SerialPort.print(accelerometer2.z);
121+
SerialPort.print(" | Gyr2[mdps]: ");
122+
SerialPort.print(gyroscope2.x);
123+
SerialPort.print(" ");
124+
SerialPort.print(gyroscope2.y);
125+
SerialPort.print(" ");
126+
SerialPort.print(gyroscope2.z);
127+
SerialPort.println(" |");
128+
SerialPort.print("| Acc3[mg]: ");
129+
SerialPort.print(accelerometer3.x);
130+
SerialPort.print(" ");
131+
SerialPort.print(accelerometer3.y);
132+
SerialPort.print(" ");
133+
SerialPort.print(accelerometer3.z);
134+
SerialPort.println(" |");
135+
SerialPort.print("| Mag[mGauss]: ");
136+
SerialPort.print(magnetometer[0]);
137+
SerialPort.print(" ");
138+
SerialPort.print(magnetometer[1]);
139+
SerialPort.print(" ");
140+
SerialPort.print(magnetometer[2]);
141+
SerialPort.println(" |");
142+
SerialPort.println("");
143+
}
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
/*
2+
@file X_NUCLEO_IKS5A1_IIS2DULPX_6D_Orientation.ino
3+
@author STMicroelectronics
4+
@brief Example to use the IIS2DULPX 6D Orientation
5+
*******************************************************************************
6+
Copyright (c) 2025, STMicroelectronics
7+
All rights reserved.
8+
This software component is licensed by ST under BSD 3-Clause license,
9+
the "License"; You may not use this file except in compliance with the
10+
License. You may obtain a copy of the License at:
11+
opensource.org/licenses/BSD-3-Clause
12+
*******************************************************************************
13+
*/
14+
#include <IIS2DULPXSensor.h>
15+
16+
#define INT1_pin A2
17+
18+
IIS2DULPXSensor IIS2DULPX(&Wire);
19+
// Interrupts.
20+
volatile int mems_event = 0;
21+
22+
char report[256];
23+
24+
void INT1Event_cb();
25+
void sendOrientation();
26+
27+
void setup()
28+
{
29+
30+
// Initialize serial.
31+
Serial.begin(115200);
32+
delay(1000);
33+
34+
// Initialize LED.
35+
pinMode(LED_BUILTIN, OUTPUT);
36+
37+
// Initialize I2C.
38+
Wire.begin();
39+
40+
// Enable INT1 pin.
41+
attachInterrupt(INT1_pin, INT1Event_cb, RISING);
42+
43+
// Initialize components.
44+
IIS2DULPX.begin();
45+
IIS2DULPX.Enable_X();
46+
// Enable 6D Orientation.
47+
IIS2DULPXStatusTypeDef ret = IIS2DULPX.Enable_6D_Orientation(IIS2DULPX_INT1_PIN);
48+
}
49+
50+
void loop()
51+
{
52+
if (true) {
53+
mems_event = 0;
54+
55+
// Initialize the structure to zero at the beginning of each loop using memset
56+
IIS2DULPX_Event_Status_t status;
57+
memset(&status, 0, sizeof(IIS2DULPX_Event_Status_t));
58+
59+
IIS2DULPX.Get_X_Event_Status(&status);
60+
61+
if (status.D6DOrientationStatus) {
62+
// Send 6D Orientation
63+
sendOrientation();
64+
65+
// LED blinking.
66+
digitalWrite(LED_BUILTIN, HIGH);
67+
delay(100);
68+
digitalWrite(LED_BUILTIN, LOW);
69+
}
70+
}
71+
}
72+
73+
void INT1Event_cb()
74+
{
75+
mems_event = 1;
76+
}
77+
void sendOrientation()
78+
{
79+
uint8_t xl = 0;
80+
uint8_t xh = 0;
81+
uint8_t yl = 0;
82+
uint8_t yh = 0;
83+
uint8_t zl = 0;
84+
uint8_t zh = 0;
85+
86+
IIS2DULPX.Get_6D_Orientation_XL(&xl);
87+
IIS2DULPX.Get_6D_Orientation_XH(&xh);
88+
IIS2DULPX.Get_6D_Orientation_YL(&yl);
89+
IIS2DULPX.Get_6D_Orientation_YH(&yh);
90+
IIS2DULPX.Get_6D_Orientation_ZL(&zl);
91+
IIS2DULPX.Get_6D_Orientation_ZH(&zh);
92+
93+
if (xl == 1 && yl == 0 && zl == 0 && xh == 0 && yh == 0 && zh == 0) {
94+
sprintf(report, "\r\n ________________ " \
95+
"\r\n | | " \
96+
"\r\n | * | " \
97+
"\r\n | | " \
98+
"\r\n | | " \
99+
"\r\n | | " \
100+
"\r\n | | " \
101+
"\r\n |________________| \r\n");
102+
}
103+
104+
else if (xl == 0 && yl == 1 && zl == 0 && xh == 0 && yh == 0 && zh == 0) {
105+
sprintf(report, "\r\n ________________ " \
106+
"\r\n | | " \
107+
"\r\n | * | " \
108+
"\r\n | | " \
109+
"\r\n | | " \
110+
"\r\n | | " \
111+
"\r\n | | " \
112+
"\r\n |________________| \r\n");
113+
}
114+
115+
else if (xl == 0 && yl == 0 && zl == 0 && xh == 0 && yh == 1 && zh == 0) {
116+
sprintf(report, "\r\n ________________ " \
117+
"\r\n | | " \
118+
"\r\n | | " \
119+
"\r\n | | " \
120+
"\r\n | | " \
121+
"\r\n | | " \
122+
"\r\n | * | " \
123+
"\r\n |________________| \r\n");
124+
}
125+
126+
else if (xl == 0 && yl == 0 && zl == 0 && xh == 1 && yh == 0 && zh == 0) {
127+
sprintf(report, "\r\n ________________ " \
128+
"\r\n | | " \
129+
"\r\n | | " \
130+
"\r\n | | " \
131+
"\r\n | | " \
132+
"\r\n | | " \
133+
"\r\n | * | " \
134+
"\r\n |________________| \r\n");
135+
}
136+
137+
else if (xl == 0 && yl == 0 && zl == 0 && xh == 0 && yh == 0 && zh == 1) {
138+
sprintf(report, "\r\n __*_____________ " \
139+
"\r\n |________________| \r\n");
140+
}
141+
142+
else if (xl == 0 && yl == 0 && zl == 1 && xh == 0 && yh == 0 && zh == 0) {
143+
sprintf(report, "\r\n ________________ " \
144+
"\r\n |________________| " \
145+
"\r\n * \r\n");
146+
}
147+
148+
else {
149+
sprintf(report, "None of the 6D orientation axes is set in accelerometer.\r\n");
150+
}
151+
152+
Serial.print(report);
153+
}

0 commit comments

Comments
 (0)