Code Monkey home page Code Monkey logo

aht20's Introduction

AHT20

A Node.js library for reading temperature and humidity values over I2C from an AHT20

Installation

npm install aht20

The only dependency is i2c-bus and this package will work on any Linux board compatible with the library. See the library for more details.

Tested on a Raspberry Pi 3B.

Usage

const AHT20 = require( "aht20" );

const sensor = new AHT20(1);
sensor.readData().then( data => console.log( data ) );

Running the above code will use I2C bus 1 to read the temperature and humidity from a connected AHT20. The output is the temperature in Celsius and the humidity as a percentage and looks something like this:

{ 
    "humidity": 16.15, 
    "temperature": 23.96 
}

You can pass in different bus by changing the number in the constructor or passing in an i2c-bus bus object. See the API or example folder for more details.

See the i2c-bus README or look online for wiring.

API

All functionality is through the AHT20 Class. See ./examples for usage.

new AHT20(bus, address)

  • bus - a number or I2C Bus
  • address - optional, defaults to 0x38 - the address of the AHT20

Returns a new AHT20 object.

readData()

An asynchronous function that returns the temperature (Celsius) and humidity (%) date from the sensor.

reset()

An asynchronous function that resets the sensor.

Author & License

© 2024 OrangeJedi. Released under the MIT License.

aht20's People

Contributors

orangejedi avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.