1.0.0 • Published 7 years ago

mbed-js-st-hts221 v1.0.0

Weekly downloads
5
License
Apache-2.0
Repository
github
Last release
7 years ago

mbed-js-hts221

HTS221 library wrappers for Javascript on Mbed

About library

Helper class providing functions for HTS221 sensor library (part of X_NUCLEO_IKS01A2) in JavaScript.

Requirements

This library is to be used with the following tools:

See this project for more information: mbed-js-example

Dependencies

You need to install dependencies before installing this library.

Installation

  • Before installing this library, make sure you have a working JavaScript on Mbed project and the project builds for your target device. Follow mbed-js-example to create the project and learn more about using JavaScript on Mbed.

  • Install this library using npm (Node package manager) with the following command:

cd project_path
npm install syed-zeeshan/mbed-js-hts221

Usage

/*****************
 * 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 + "]");