NEQTO Docs
  • Languages iconEnglish
    • 日本語
  • Docs
  • API
  • FAQ

›I2C

Getting Started

  • NEQTO Hello World!
  • Tutorial Step 1. NEQTO Console Setting
  • Tutorial Step 2. Device Settings & Launching Service (NEQTO Bridge)
  • Tutorial Step 2. Device Settings & Launching Service (STM32 Discovery)
  • Tutorial Step 2. Device Settings & Launching Service (SPRESENSE)
  • Tutorial Step 3. Application development using scripts

NEQTO

  • NEQTO Account Registration
  • Sub-accounts
  • API Usage
  • NEQTO CloudSync for GCP
  • NEQTO Engine Firmware List
  • Support Guidelines

NEQTO Console

  • Introduction
  • Fundamentals
  • Administrative Actions
  • Device Management
  • Linux-based Device Management
  • Batch Registration
  • Scripts
  • Actions and Contacts
  • View Data from the Console
  • NEQTO Apps

    • About NEQTO Apps
    • NEQTO Infinitypool
    • NEQTO Insights
    • NEQTO Custodia
    • NEQTO Flow
  • Machine Driver
  • Recommended Browsers
  • Billing Information

SPRESENSE

    Hardware Specifications

    • 01. About Spresense

    Software Specifications

    • 01. Operational Flow
    • 02. Initial Installation
    • 03. Spresense Wi-Fi Initial Setup
    • 04. Spresense LTE-M Initial Setup
    • 05. Debug Log Acquisition
    • 06. System LED Indications
    • 07. Event Messages
    • 08. Updating Firmware

    neqto.js

    • 01. About neqto.js
    • 02. Log
    • 03. Timers
    • 04. HTTP
    • 05. HTTPS
    • 06. MQTT
    • 07. Secure
    • 08. Storage
    • 09. Sleep
    • 10. RTC
    • 11. GPIO
    • 12. UART
    • 13. SPI
    • 14. I2C
    • 15. ADC
    • 16. GNSS
    • 17. Camera
    • 18. Utils
    • 19. nqSpresense
    • 20. nqService
    • 21. nqMqtt
    • 22. nqFOTA
    • 23. nqWiFi
    • 24. nqLte

STM32 Discovery

    Hardware Specifications

    • 01. About STM32 Discovery Kit (B-L4S5I-IOT01A)

    Software Specifications

    • 01. Operational Flow
    • 02. Initial Installation
    • 03. STM32 Discovery Wi-Fi Initial Setup
    • 04. Debug Log Acquisition
    • 05. System LED Indications
    • 06. Event Messages
    • 07. Updating Firmware

    neqto.js

    • 01. About neqto.js
    • 02. Log
    • 03. Timers
    • 04. HTTP
    • 05. HTTPS
    • 06. MQTT
    • 07. Secure
    • 08. Storage
    • 09. Sleep
    • 10. RTC
    • 11. UserSW
    • 12. GPIO
    • 13. UART
    • 14. SPI
    • 15. I2C
    • 16. ADC
    • 18. Utils
    • 19. nqDiscovery
    • 20. nqService
    • 21. nqMqtt
    • 22. nqFOTA
    • 23. nqWiFi

NEQTO Bridge

    Hardware Specifications

    • 01. NEQTO Bridge Module
    • 02. NEQTO Bridge Wi-Fi Module
    • 03. NEQTO Bridge LTE-1 Module
    • 04. NEQTO Bridge LTE-M/NB Module
    • 05. NEQTO Bridge IO Board
    • 06. NEQTO Bridge Digital IO Board
    • 07. NEQTO Bridge Connector Board

    Software Specifications

    • 01. Operational Flow
    • 02. NEQTO Bridge Wi-Fi Module Initial Setup
    • 03. NEQTO Bridge LTE Module Initial Setup
    • 04. Debug Log Acquisition
    • 05. System LED Indications
    • 06. Event Messages
    • 07. Updating Firmware

    neqto.js

    • 01. About neqto.js
    • 02. Log
    • 03. Timers
    • 04. HTTP
    • 05. HTTPS
    • 06. MQTT
    • 07. Secure
    • 08. Storage
    • 09. Sleep
    • 10. RTC
    • 11. UserSW
    • 12. GPIO
    • 13. UART
    • 14. SPI
    • 15. I2C
    • 16. ADC
    • 17. BLE
    • 18. Utils
    • 19. nqBridge
    • 20. nqService
    • 21. nqMqtt
    • 22. nqFOTA
    • 23. nqWiFi
    • 24. nqLte
    • 25. nqLAN
    • 26. nqEx

Linux-based device

    Software Specifications

    • 01. System Requirements
    • 02. Installation
    • 03. Software Configurations
    • 04. Operational Flow
    • 05. Debug Log Acquisition
    • 06. Event Messages
    • 07. Updating Software

    neqto.js

    • 01. About neqto.js
    • 02. Log
    • 03. Timers
    • 04. HTTP
    • 05. HTTPS
    • 06. MQTT
    • 07. Secure
    • 08. Storage
    • 09. RTC
    • 10. UNIXSocket
    • 11. FileSystem
    • 12. SubProcess
    • 13. Utils
    • 14. nqLinux
    • 15. nqService
    • 16. nqMqtt
    • 17. nqFOTA
    • 18. nqLAN

neqto.js Libraries

  • About neqto.js Libraries
  • UART

    • GM65 Barcode Reader
    • SRF Ultrasonic Range Finder - Serial Mode

    I2C

    • HTS221 v2 Temperature and Humidity Sensor
    • LIS2DW12 v2 Accelerometer
    • SRF Ultrasonic Range Finder - I2C Mode
    • [Archive] HTS221 Temperature and Humidity Sensor
    • [Archive] LIS2DW12 Accelerometer

    Utils

    • RTC Alarm Synchronized Scheduler

    Integration

    • AWS S3 v2
    • AWS IoT Core v2
    • Azure IoT v2
    • GCP IoT Core
    • [Archive] AWS S3
    • [Archive] AWS IoT Core

neqto.js Snippets

  • About neqto.js Snippets
  • DataDog
  • Dropbox
  • Google Sheets
  • InfluxDB
  • Oracle Cloud Object Storage
  • Salesforce
  • SAP Cloud Platform Internet of Things
  • Splunk
  • Niagara

Release Notes

  • NEQTO Console Updates
  • NEQTO Firmware (Bridge Wi-Fi/LTE Module) Releases
  • NEQTO Firmware (STM32 Discovery Wi-Fi) Releases
  • NEQTO Firmware (Spresense Wi-Fi/LTE-M) Releases
  • NEQTO Engine for Linux Releases

[Archive] HTS221 Temperature and Humidity Sensor

This library has been archived and is no longer supported. The latest version of the HTS221 Temperature and Humidity Sensor Library can be found here.

The HTS221 is an accurate and versatile sensor used for detecting the ambient temperature and humidity of an area. The HTS221 sensor supports communication via the I2C communication protocol.

The HTS221 is very simple to operate in both hardware and software.

For information on how to import neqto.js libraries, please refer to this documentation.

Setup

Hardware

The NEQTO HTS221 module has 5 pins on its bottom for connecting to the I2CM port at the bottom of the NEQTO Bridge. The HTS221 module lines up its pins from right to left, and should fit snugly into the module port. When aligned correctly, the two screw-holes at the bottom of the module should be exposed for more permanent attachment.

For other devices, the NEQTO HTS221 module can connect with any I2C port by means of a sensor connector.

Software

To interface with an HTS221 sensor, it is required to create a sensor object and then call the init function to initialize the sensor. Once the sensor object is created and initialized, it is possible to read the sensor data using the getResult function.

Usage

Creation

All NEQTO I2C libraries follow the same format for creation. The HTS221 takes the following parameter at creation:

  • i2c: the I2C instance representing the I2C node on the board that this sensor connects to. In this case, users should pass an I2C instance made from node 1.

init

The HTS221 needs to be initialized before it can read data from its surroundings. Calling on the HTS221 sensor object will ready it to take readings. This only needs to happen once.

Returns: {boolean}

If it is unable to initialize, the init() function returns false. Otherwise, it does not return.

getResult

Returns: {object}

A JavaScript object containing the sensor data, in the following format:

{
    temp: temperature (Number), // UNIT: Celsius (C), -40 to +120, RESO: 0.1
    humi: humidity (Number)     // UNIT: Percent (%),   0 to  100, RESO: 0.1
}

Example Script

The following script is an example of a user script after importing the HTS221 sensor library.

The user will turn on interfaces on the NEQTO Bridge, and create a new I2C device object to interface with the HTS221 sensor.

The user wants to measure 10 readings from the HTS221 at a rate of one reading per second, and output the average to the serial console.

// IMPORTED LIBRARIES
// - HTS221

// Logging setup
log.setLevel(2);   //-1:NONE 0:ERROR 1:WARNING 2:DEBUG 3:TRACE
log.printLevel(2);  //0:DISABLE 1:LOG 2:CONSOLE 3:BOTH
log.clear();

//Use standard interface of NEQTO IO board
nqEx.enI2CS(true);
nqEx.enI2CL(true);

//I2C Config
var baudrate = 400000;
var i2c = new I2C(1);

i2c.open(baudrate);
var hts = new HTS221(i2c);
var ready = hts.init();

var iteration = 1;
var sums = [0, 0];
var MAX_NUM_ITERATIONS = 10;
var ITERATION_INTERVAL = 1000; // in milliseconds

if (!ready) {
    print("UNABLE TO CONNECT TO HTS221");
    print("EXITING...");
} else {
    var loop = setInterval(function () {
        var results = hts.getResult();
        sums[0] += results.temp;
        sums[1] += results.humi;

        if (iteration++ == MAX_NUM_ITERATIONS) {
            print("PRINTING AVERAGE TEMPERATURES...");
            print((sums[0] / 10).toFixed(2));
            print("PRINTING AVERAGE HUMIDITIES...");
            print((sums[1] / 10).toFixed(2));

            sums = [0, 0];
            iteration = 1;
        }
    }, ITERATION_INTERVAL)
}

Updated: 2021-02-19
← SRF Ultrasonic Range Finder - I2C Mode[Archive] LIS2DW12 Accelerometer →
  • Setup
    • Hardware
    • Software
  • Usage
    • Creation
    • init
    • getResult
  • Example Script
AboutNewsProductsFAQPrivacy Policy}
NEQTO Console
IntroductionFundamentalsAdministrative ActionsDevice Management NEQTO Apps
NEQTO Bridge
NEQTO Bridge ModuleNEQTO Bridge Wi-Fi ModuleNEQTO Bridge LTE-1 ModuleError Logging Event Messages
API Documentation
API UsageGlobal APIRegional APIAPI Terms of Service
Jigsaw, Inc.
© 2023 JIG-SAW INC.