Menu

HTU21D.h library ....Help

Help
2018-04-02
2018-04-04
  • guillermo falcon carrasco

    Hello.
    Please, I need support for create this library.
    Can you help me forthis.
    Thanks in advance.

     
  • stan cartwright

    stan cartwright - 2018-04-02

    I googled the device. I think it would be another bmp280 tedious job.
    double getTemperature(int fd)
    {
    unsigned char buf [4];
    wiringPiI2CWrite(fd, HTU21D_TEMP);
    delay(100);
    read(fd, buf, 3);
    unsigned int temp = (buf [0] << 8 | buf [1]) & 0xFFFC;
    // Convert sensor reading into temperature.
    // See page 14 of the datasheet
    double tSensorTemp = temp / 65536.0;
    return -46.85 + (175.72 * tSensorTemp);
    }

    // Get humidity
    double getHumidity(int fd)
    {
    unsigned char buf [4];
    wiringPiI2CWrite(fd, HTU21D_HUMID);
    delay(100);
    read(fd, buf, 3);
    unsigned int humid = (buf [0] << 8 | buf [1]) & 0xFFFC;
    // Convert sensor reading into humidity.
    // See page 15 of the datasheet
    double tSensorHumid = humid / 65536.0;
    return -6.0 + (125.0 * tSensorHumid);
    }
    yes, it's so easy :)

     

    Last edit: stan cartwright 2018-04-02
  • guillermo falcon carrasco

    Thanks Stan
    I check it.

     
  • Anobium

    Anobium - 2018-04-02

    Page 15 of datasheet explains the maths.   Should be relatively   easy.

     
  • stan cartwright

    stan cartwright - 2018-04-02

    @gfc
    I think the data sheet is lots of info.
    It's i2c..don't forget pull-ups
    how is data requested and sent...sort that and away.
    when you know the data feed then the maths is just decimal points.
    floats have been a problem for me as c code doesn't tranlate easy to gcb.
    I think you might get some support as similar devices have been sorted recently....lot's of effort for bmp280..see the forum.
    I google it more for you...a few times only. I don't have or need one.
    What info can YOU find?

     
  • David Stephenson

    Attached is a subroutine that I use for si7006 humidity sensors. They use the same addresses and the same calculations as the HTU21.
    You will need to define many of the constants as word.

     

    Last edit: David Stephenson 2018-04-03
  • guillermo falcon carrasco

    Thanks David

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.