Displaying HDC1008 sensor values on an LCD

In this example we will gain some sensor readings on an LCD shield attached to a Linkit One, this time we will use a HDC1008 humidity and temperature sensor with this and display the temperature and humidity on the LCD

Our initial HDC1008 example is at – Linkit One and HDC1008 humidity and temperature sensor

Layout

Again we are showing the sensor connected to the LCD shield

lcd-and-hdc1008_bb

Code

This requires the HDC100X library

https://github.com/adafruit/Adafruit_HDC1000_Library  .

If you are using Arduino IDE 1.6.5 or later you can easily import this library by going to Sketch -> Include Library -> Manage Libraries

[codesyntax lang=”cpp”]

#include <LiquidCrystal.h>
#include <Wire.h>
#include "Adafruit_HDC1000.h"

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
Adafruit_HDC1000 hdc = Adafruit_HDC1000();

void setup() 
{
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  Serial.begin(9600);
  if (!hdc.begin()) 
  {
    Serial.println("Couldn't find HDC1008 sensor!");
    while (1);
  }
}


void loop() 
{
  // set the cursor to column 0, line 0
  lcd.setCursor(0, 0);
  //display the temperature
  lcd.print("Temperature = " );
  lcd.print(hdc.readTemperature());
  
  // set the cursor to column 0, line 1
  lcd.setCursor(0, 1);
  //display the humidity
  lcd.print("Humidity = ");
  lcd.print(hdc.readHumidity());
  
  delay(1000);
}

[/codesyntax]

 

Links