"Sensors Reader" Sample Application for X-NUCLEO-IKS01A1 Expansion Board

Dependencies:   X_NUCLEO_IKS01A1 mbed

Fork of Sensors_Reader by ST Expansion SW Team

X-NUCLEO-IKS01A1 MEMS Inertial & Environmental Sensor Nucleo Expansion Board Firmware Package

Introduction

This firmware package includes Components Device Drivers, Board Support Package and example applications for STMicroelectronics X-NUCLEO-IKS01A1 MEMS Inertial & Environmental Nucleo Expansion Board.

Example Application

First of all, the example application outputs information retrieved from the Expansion Board over UART. Launch a terminal application (e.g.: PuTTY on Windows, Minicom on Linux) and set the UART port to 9600 bps, 8 bit, No Parity, 1 stop bit.

The "Sensors Reader" program is a more complex example of how to use the X-NUCLEO-IKS01A1 expansion board featuring among others:

  • Support for LSM6DS3 3D Accelerometer & Gyroscope (on DIL 24-pin socket) including free-fall detection
  • Usage of LED & Ticker
  • Exploitation of wait for event
  • (Top-/Bottom-Half) Interrupt handling
Revision:
18:645c96f209c7
Parent:
11:e20efb4e8a98
Child:
29:25c8f7d4515a
--- a/main.cpp	Fri May 29 14:33:14 2015 +0200
+++ b/main.cpp	Fri May 29 16:29:31 2015 +0200
@@ -90,6 +90,14 @@
 #endif // DBG_MCU
 
 static X_NUCLEO_IKS01A1 *mems_expansion_board = X_NUCLEO_IKS01A1::Instance();
+static GyroSensor &gyroscope = mems_expansion_board->gyroscope;
+static MotionSensor &accelerometer = mems_expansion_board->gyroscope;
+static MagneticSensor &magnetometer = mems_expansion_board->magnetometer;
+static HumiditySensor &humidity_sensor = mems_expansion_board->ht_sensor;;
+static PressureSensor &pressure_sensor = mems_expansion_board->pressure_sensor;
+static TempSensor &temp_sensor1 = mems_expansion_board->ht_sensor;
+static TempSensor &temp_sensor2 = mems_expansion_board->pressure_sensor;
+
 static Ticker ticker;
 static volatile bool timer_irq_triggered = false;
 static DigitalOut myled(LED1, LED_OFF);
@@ -125,11 +133,14 @@
 
 /* Initialization function */
 static void init(void) {
-	uint8_t hts221_id;
+	uint8_t hts221_id_hum;
+	uint8_t hts221_id_temp;
 
 	/* Determine ID of Humidity & Temperature Sensor */
-	mems_expansion_board->ht_sensor.ReadID(&hts221_id);
-    	printf("HTS221_ID = 0x%x (%u)\n", hts221_id, hts221_id);
+	humidity_sensor.ReadID(&hts221_id_hum);
+	temp_sensor1.ReadID(&hts221_id_temp);
+    	printf("HTS221_ID (Humidity)    = 0x%x (%u)\n", hts221_id_hum, hts221_id_hum);
+    	printf("HTS221_ID (Temperature) = 0x%x (%u)\n", hts221_id_temp, hts221_id_temp);
 }
 
 /* Main cycle function */
@@ -151,13 +162,13 @@
 	printf("===\n");
 
 	/* Determine Environmental Values */
-        mems_expansion_board->ht_sensor.GetTemperature(&TEMPERATURE_Value);
-        mems_expansion_board->ht_sensor.GetHumidity(&HUMIDITY_Value);
-        mems_expansion_board->pressure_sensor.GetPressure(&PRESSURE_Value);
-        mems_expansion_board->pressure_sensor.GetTemperature(&PRESSURE_Temp_Value);
-        mems_expansion_board->magnetometer.Get_M_Axes((int32_t *)&MAG_Value);
-        mems_expansion_board->gyroscope.Get_X_Axes((int32_t *)&ACC_Value);
-        mems_expansion_board->gyroscope.Get_G_Axes((int32_t *)&GYR_Value);
+        temp_sensor1.GetTemperature(&TEMPERATURE_Value);
+        humidity_sensor.GetHumidity(&HUMIDITY_Value);
+        pressure_sensor.GetPressure(&PRESSURE_Value);
+        temp_sensor2.GetTemperature(&PRESSURE_Temp_Value);
+        magnetometer.Get_M_Axes((int32_t *)&MAG_Value);
+        accelerometer.Get_X_Axes((int32_t *)&ACC_Value);
+        gyroscope.Get_G_Axes((int32_t *)&GYR_Value);
 
 	/* Print Values Out */
         printf("TEMP: %s, HUMIDITY: %s, PRESSURE (TEMP): %s (%s)\n",