Skip to content

Commit 3ce54b5

Browse files
committed
Merge with Wi6Labs Pull Request and add X-NUCLEO examples
1 parent 9b637ca commit 3ce54b5

9 files changed

Lines changed: 2266 additions & 0 deletions

File tree

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/**
2+
******************************************************************************
3+
* @file DISCO_IOT_HTS221_DataLog_Terminal.ino
4+
* @author WI6LABS from AST
5+
* @version V1.0.0
6+
* @date 7 July 2017
7+
* @brief Arduino test application for the STMicrolectronics STM32 DISCO_IOT
8+
* MEMS Inertial and Environmental sensor expansion board.
9+
* This application makes use of C++ classes obtained from the C
10+
* components' drivers.
11+
******************************************************************************
12+
* @attention
13+
*
14+
* <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
15+
*
16+
* Redistribution and use in source and binary forms, with or without modification,
17+
* are permitted provided that the following conditions are met:
18+
* 1. Redistributions of source code must retain the above copyright notice,
19+
* this list of conditions and the following disclaimer.
20+
* 2. Redistributions in binary form must reproduce the above copyright notice,
21+
* this list of conditions and the following disclaimer in the documentation
22+
* and/or other materials provided with the distribution.
23+
* 3. Neither the name of STMicroelectronics nor the names of its contributors
24+
* may be used to endorse or promote products derived from this software
25+
* without specific prior written permission.
26+
*
27+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
30+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
31+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
33+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
34+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
35+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37+
*
38+
******************************************************************************
39+
*/
40+
41+
42+
// Includes.
43+
#include <HTS221Sensor.h>
44+
45+
#define I2C2_SCL D33
46+
#define I2C2_SDA D34
47+
48+
// Components.
49+
HTS221Sensor *HumTemp;
50+
TwoWire *dev_i2c;
51+
52+
void setup() {
53+
// Led.
54+
pinMode(LED_BUILTIN, OUTPUT);
55+
// Initialize serial for output.
56+
Serial.begin(9600);
57+
58+
// Initialize I2C bus.
59+
dev_i2c = new TwoWire(I2C2_SDA, I2C2_SCL);
60+
dev_i2c->begin();
61+
62+
// Initlialize components.
63+
HumTemp = new HTS221Sensor (dev_i2c);
64+
HumTemp->Enable();
65+
}
66+
67+
void loop() {
68+
// Led blinking.
69+
digitalWrite(LED_BUILTIN, HIGH);
70+
delay(250);
71+
digitalWrite(LED_BUILTIN, LOW);
72+
delay(250);
73+
74+
// Read humidity and temperature.
75+
float humidity, temperature;
76+
HumTemp->GetHumidity(&humidity);
77+
HumTemp->GetTemperature(&temperature);
78+
79+
// Output data.
80+
Serial.print("Hum[%]: ");
81+
Serial.print(humidity, 2);
82+
Serial.print(" | Temp[C]: ");
83+
Serial.println(temperature, 2);
84+
}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/**
2+
******************************************************************************
3+
* @file X_NUCLEO_IKS01A1_HTS221_DataLog_Terminal.ino
4+
* @author AST
5+
* @version V1.0.0
6+
* @date 5 August 2016
7+
* @brief Arduino test application for the STMicrolectronics X-NUCLEO-IKS01A1
8+
* MEMS Inertial and Environmental sensor expansion board.
9+
* This application makes use of C++ classes obtained from the C
10+
* components' drivers.
11+
******************************************************************************
12+
* @attention
13+
*
14+
* <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
15+
*
16+
* Redistribution and use in source and binary forms, with or without modification,
17+
* are permitted provided that the following conditions are met:
18+
* 1. Redistributions of source code must retain the above copyright notice,
19+
* this list of conditions and the following disclaimer.
20+
* 2. Redistributions in binary form must reproduce the above copyright notice,
21+
* this list of conditions and the following disclaimer in the documentation
22+
* and/or other materials provided with the distribution.
23+
* 3. Neither the name of STMicroelectronics nor the names of its contributors
24+
* may be used to endorse or promote products derived from this software
25+
* without specific prior written permission.
26+
*
27+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
30+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
31+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
33+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
34+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
35+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37+
*
38+
******************************************************************************
39+
*/
40+
41+
42+
// Includes.
43+
#include <HTS221Sensor.h>
44+
45+
#if defined(ARDUINO_SAM_DUE)
46+
#define DEV_I2C Wire1 //Define which I2C bus is used. Wire1 for the Arduino Due
47+
#define SerialPort Serial
48+
#else
49+
#define DEV_I2C Wire //Or Wire
50+
#define SerialPort Serial
51+
#endif
52+
53+
// Components.
54+
HTS221Sensor *HumTemp;
55+
56+
char report[256];
57+
58+
void setup() {
59+
// Led.
60+
pinMode(13, OUTPUT);
61+
62+
// Initialize serial for output.
63+
SerialPort.begin(9600);
64+
65+
// Initialize I2C bus.
66+
DEV_I2C.begin();
67+
68+
// Initlialize components.
69+
HumTemp = new HTS221Sensor (&DEV_I2C);
70+
HumTemp->Enable();
71+
}
72+
73+
void loop() {
74+
char report[256];
75+
76+
// Led blinking.
77+
digitalWrite(13, HIGH);
78+
delay(250);
79+
digitalWrite(13, LOW);
80+
delay(250);
81+
82+
// Read humidity and temperature.
83+
float humidity, temperature;
84+
HumTemp->GetHumidity(&humidity);
85+
HumTemp->GetTemperature(&temperature);
86+
87+
// Output data.
88+
SerialPort.print("| Hum[%]: ");
89+
SerialPort.print(humidity, 2);
90+
SerialPort.print(" | Temp[C]: ");
91+
SerialPort.print(temperature, 2);
92+
SerialPort.println(" |");
93+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/**
2+
******************************************************************************
3+
* @file X_NUCLEO_IKS01A2_HTS221_DataLog_Terminal.ino
4+
* @author AST
5+
* @version V1.0.0
6+
* @date 5 August 2016
7+
* @brief Arduino test application for the STMicrolectronics X-NUCLEO-IKS01A2
8+
* MEMS Inertial and Environmental sensor expansion board.
9+
* This application makes use of C++ classes obtained from the C
10+
* components' drivers.
11+
******************************************************************************
12+
* @attention
13+
*
14+
* <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
15+
*
16+
* Redistribution and use in source and binary forms, with or without modification,
17+
* are permitted provided that the following conditions are met:
18+
* 1. Redistributions of source code must retain the above copyright notice,
19+
* this list of conditions and the following disclaimer.
20+
* 2. Redistributions in binary form must reproduce the above copyright notice,
21+
* this list of conditions and the following disclaimer in the documentation
22+
* and/or other materials provided with the distribution.
23+
* 3. Neither the name of STMicroelectronics nor the names of its contributors
24+
* may be used to endorse or promote products derived from this software
25+
* without specific prior written permission.
26+
*
27+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
30+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
31+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
33+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
34+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
35+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37+
*
38+
******************************************************************************
39+
*/
40+
41+
42+
// Includes.
43+
#include <HTS221Sensor.h>
44+
45+
#if defined(ARDUINO_SAM_DUE)
46+
#define DEV_I2C Wire1 //Define which I2C bus is used. Wire1 for the Arduino Due
47+
#define SerialPort Serial
48+
#else
49+
#define DEV_I2C Wire //Or Wire
50+
#define SerialPort Serial
51+
#endif
52+
53+
// Components.
54+
HTS221Sensor *HumTemp;
55+
56+
char report[256];
57+
58+
void setup() {
59+
// Led.
60+
pinMode(13, OUTPUT);
61+
62+
// Initialize serial for output.
63+
SerialPort.begin(9600);
64+
65+
// Initialize I2C bus.
66+
DEV_I2C.begin();
67+
68+
// Initlialize components.
69+
HumTemp = new HTS221Sensor (&DEV_I2C);
70+
HumTemp->Enable();
71+
}
72+
73+
void loop() {
74+
// Led blinking.
75+
digitalWrite(13, HIGH);
76+
delay(250);
77+
digitalWrite(13, LOW);
78+
delay(250);
79+
80+
// Read humidity and temperature.
81+
float humidity, temperature;
82+
HumTemp->GetHumidity(&humidity);
83+
HumTemp->GetTemperature(&temperature);
84+
85+
// Output data.
86+
SerialPort.print("| Hum[%]: ");
87+
SerialPort.print(humidity, 2);
88+
SerialPort.print(" | Temp[C]: ");
89+
SerialPort.print(temperature, 2);
90+
SerialPort.println(" |");
91+
}

keywords.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#######################################
2+
# Syntax Coloring Map For HTS221
3+
#######################################
4+
5+
#######################################
6+
# Datatypes (KEYWORD1)
7+
#######################################
8+
9+
HTS221Sensor KEYWORD1 HTS221Sensor
10+
11+
#######################################
12+
# Methods and Functions (KEYWORD2)
13+
#######################################
14+
15+
Enable KEYWORD2
16+
Disable KEYWORD2
17+
ReadID KEYWORD2
18+
Reset KEYWORD2
19+
GetHumidity KEYWORD2
20+
GetTemperature KEYWORD2
21+
GetODR KEYWORD2
22+
SetODR KEYWORD2
23+
ReadReg KEYWORD2
24+
WriteReg KEYWORD2
25+
IO_Read KEYWORD2
26+
IO_Write KEYWORD2
27+
28+
#######################################
29+
# Constants (LITERAL1)
30+
#######################################

library.properties

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=HTS221
2+
version=1.0
3+
author=AST, Wi6Labs
4+
maintainer=STMicroelectronics
5+
sentence=Capacitive digital sensor for relative humidity and temperature.
6+
paragraph=This library provides Arduino support for the capacitive digital sensor for relative humidity and temperature HTS221 for STM32 boards.
7+
category=Sensors
8+
url=https://github.com/stm32duino/HTS221
9+
architectures=stm32

0 commit comments

Comments
 (0)