JavaScript library for HTS221 on Mbed OS
npm install mbed-js-st-hts221See this project for more information: mbed-js-example
* Install this library using npm (Node package manager) with the following command:
```
cd project_path
npm install syed-zeeshan/mbed-js-hts221
/*
Instantiation
*/
// Instantiate HTS221 library
var hts221 = HTS221_JS();/**
Initialization
**/
// Initialize using DevI2C
hts221.init_i2c(dev_i2c);
// Initialize using DevI2C, address and drdy pin
hts221.init_i2c(dev_i2c, address, drdy_pin);
// Initialize using SPI
hts221.init_spi(spi);
// Initialize using SPI, CS pin and drdy pin
hts221.init_spi(spi, cs_pin, drdy_pin);
/*
Reading sensor data
*/
// To read temperature data (string output)
hts221.get_temperature();
// To read humidity data (string output)
hts221.get_humidity();
`Example using DevI2C (Nucleo-F429ZI)
`
// Initialize DevI2C with SDA and SCL pins
var dev_i2c = DevI2C(D14, D15);// Instantiate HTS221 library
var hts221 = HTS221_JS();
// Initialize HTS221 library
hts221.init_i2c(dev_i2c);
// Print sensor data
var temp = hts221.get_temperature();
var hum = hts221.get_humidity();
print("[Temperature]: [" + temp + "]");
print("[Humidity]: [" + hum + "]");
``