Skip to content

boeserfrosch/GuL_TI_Humidity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GuL TI Humidity HDC10XX

GuL TI Humidity HDC10XX is a library for the Arduino-Framework to work with the humditiy sensors series HDC10XX (HDC1010 and HDC1080) from Texas Instruments

Installation

  1. Arduino Library Manager (Recommended)
  2. Download or clone this repository into your arduino libraries directory

Usage

  1. Include module

    #include <HDC1010.h> // Or HDC1080.h
  2. Create a instance with the serial port it uses

  //The modul uses the namespace GuL, instead of Serial1 you can use Serial, Serial2, or own instantiated HardwareSerial or SoftwareSerial
   GuL::HDC1010 hdc(Wire); 
  1. In setup(), basic setup of the modul.

    void setup() {
       Wire.begin();
      hdc.resetConfiguration();
      hdc.enableHeater();
      hdc.setHumidityResolution(GuL::HDC1080::HumidityMeasurementResolution::HUM_RES_14BIT);
      hdc.setTemperaturResolution(GuL::HDC1080::TemperatureMeasurementResolution::TEMP_RES_14BIT);
      hdc.setAcquisitionMode(GuL::HDC1080::AcquisitionModes::BOTH_CHANNEL);
    }
  2. In loop() of the sketch, run the object's loop() method.

    void loop() {
      hdc.startAcquisition(GuL::HDC1080::Channel::BOTH);
      delay(hdc.getConversionTime(GuL::HDC1080::Channel::BOTH)/1000);
    
      float temperature = hdc.getTemperature();
      float humidity = hdc.getHumidity();
    
      Serial.printf("%f °C \n %f % \n",temperature,humidity);
    }

APIs

Constructors

   GuL_TI_Humidity_HDC10XX(TwoWire &wire); // Not recommended
   HDC1010(TwoWire &wire, uint8_t addr = 0b1000000);
   HDC1080(TwoWire &wire);

The first constructor is not recommended, but results in the same behaviour like HDC1080(...). HDC1010 and HDC1080 are for the specific devices whereby the HDC1080 construction leads to the usage of the address 0b1000000 and with the the HDC1010(...) the address can be specified. The address have to be in the range of 0b1000000 up to 0b1000011, otherwise the default (0b1000000) will be used.

methods

      std::string getSensorName() { return _name; }

Return the device name (Like HDC1010 or HDC1080)

      bool startAcquisition(Channel chan);

Start the acquisition of the given channel

      bool setAcquisitionMode(AcquisitionModes mode);

set the mode of the acquisition

      bool resetConfiguration();

Set the device configuration to default

      bool enableHeater();

Enable the heater, (further details)[#heater-details]

      bool disableHeater();

Disable the heater (further details)[#heater-details]

      bool heaterEnabled();

Checks if the heater in enabled or disabled

      bool setHumidityResolution(HumidityMeasurementResolution res);

Set the conversion resolution of the humidity channel

      bool setTemperaturResolution(TemperatureMeasurementResolution res);

Set the conversion resolution of the temperature channel

      BatteryStatus getBatteryStatus();

Get the status of the battery, thereby it is assumpt that the battery is directly connected to the powerline of the sensor. If the voltage of the sensor if > 2.8V than the return is BatteryStatus::BATTERY_OK otherwise BatteryStatus::BATTERY_LOW

      uint16_t getDeviceID();

Get the device id (0x1000 for HDC1010 and 0x1050 for HDC1080)

      uint16_t getManufacturerID();

Get the manufacturer id (0x5449)

      uint64_t getSerialID();

Get the sensor unique id (40bit width)

      uint16_t getConversionTime(Channel chan); // Returns the conversion time in µs!

Get the needed time of conversion dependen of the resolution. The time is in µs!

      float getTemperature(); // in °C

Get the measured temperature in °C

      float getHumidity();    // in %

Get the relative humidity in %

HDC1010 specific

  void setDRDYnPin(uint8_t pin);

Set the GPIO Input-Pin for the DRDYn input, internaly it will be set as an input with pullup

  bool isAcquisitionReady();

Returns false if the pin is not set or the DRDYn-Pin is high

Heater details

See HDC1010 and HDC1080 Datasheet

8.3.3 Heater The heater is an integrated resistive element that can be used to test the sensor or to drive condensation off the sensor. The heater can be activated using HEAT, bit 13 in Configuration Register. The heater helps in reducing the accumulated offset after long exposure at high humidity conditions. Once enabled the heater is turned on only in the measurement mode. To have a reasonable increase of the temperature it is suggested to increase the measurement data rate.

What's Next

  • Write tests
  • Add examples

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages