Git Product home page Git Product logo

htu21d's Introduction

HTU21D

A Library to add support of HTU21D temperature and humidity sensor to Particle core (Formerly Spark Core).

Usage

Before your setup function

#include "HTU21D.h"
HTU21D htu = HTU21D();

In your setup function

    // HT21D sensor setup
    while(! htu.begin()){
        Serial.println("Couldnt find HTU21D");
        delay(1000);
    }

In your loop you can now get values like that

    temperature = htu.readTemperature();
    humidity = htu.readHumidity();

Options

Resolution

The sensor offers 2 configurations: Maximum resolution : 12bits resolution for Relative humidity and 14bits for temperature or 11bit resolution for both temperature and relative humidity

    // Set maximum resolution
    htu.setResolution(HTU21D_RES_MAX);

    // Set 11bits resolution
    htu.setResolution(HTU21D_RES_11BITS);

Contributing

  1. Fork it (https://github.com/romainmp/HTU21D/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

htu21d's People

Contributors

romainmp avatar

Stargazers

 avatar

Watchers

 avatar  avatar

htu21d's Issues

No need to wait after Wire.requestFrom().

There is no need to wait for something after a Wire.requestFrom().
When the Wire.requestFrom() returns, I2C bus transaction has completely finished and the received data is waiting in a buffer in the Wire library.

These pieces of code can be removed:

//Wait for data to become available
int counter = 0;
while(!Wire.available()){
  counter++;
  delay(1);
  if(counter > 100) return HTU21D_I2C_TIMEOUT; //after 100ms consider I2C timeout
}

If you want, then it is possible to test if the Wire.requestFrom() was succesful or not:

Wire.requestFrom(HTDU21D_ADDRESS, 3);

//Test if something was wrong
if(Wire.available() != 3){
  return HTU21D_I2C_TIMEOUT;
}

uint16_t h = Wire.read();
h <<= 8;
h |= Wire.read();

You could replace the "TIMEOUT" error with a more appropriate name. When it failed, the Slave was not answering or there was a bus error.

Not working properly

Hi @romainmp.

I'm trying to get the code running with the adafruit HTU21DF and your library but it's not working. I just create the htu object and then see !htu.begin()

The LED in the front of the photon doesn't breathe cyan anymore (It's fixed) It's like the micro isn't responding. Do you know anything about this?

Thanks!

redefinition of 'class HTU21D'

Veryfing code using this library in Particle Build fails with this error:

HTU21D/HTU21D.h:39:7: error: redefinition of 'class HTU21D'
 class HTU21D {
       ^

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.