Categories

Arduino and HDC2080 humidity and temperature sensor example

In this article we look at yet another humidity and temperature sensor from TI – this time its the HDC2080 which we will connect up to an Arduino Uno

Lets look at some of the technical information and data from TI

HDC2080 Information

The HDC2080 device is an integrated humidity and temperature sensor that provides high accuracy measurements with very low power consumption in a small DFN package. The capacitive-based sensor includes new integrated digital features and a heating element to dissipate condensation and moisture. The HDC2080 digital features include programmable interrupt thresholds to provide alerts and system wake-ups without requiring a microcontroller to be continuously monitoring the system. Combined with programmable sampling intervals, a low power consumption, and a support for a 1.8-V supply voltage, the HDC2080 is designed for battery-operated systems.

The HDC2080 provides high accuracy measurement capability for a wide range of environmental monitoring and Internet of Things (IoT) applications such as smart thermostats and smart home assistants. For designs where printed-circuit board (PCB) area is critical, a smaller CSP package option is available thru the HDC2010 with complete software compatibility with the HDC2080.

For applications with strict power-budget restrictions, Auto Measurement Mode enables the HDC2080 to automatically initiate temperature and humidity measurements. This feature allows users to configure a microcontroller into deep sleep mode because the HDC2080 is no longer dependent upon the microcontroller to initiate a measurement.

Programable temperature and humidity thresholds in the HDC2080 allow the device to send a hardware interrupt to wake up the microcontroller when necessary. In addition, the power consumption of the HDC2080 is significantly reduced, which helps to minimize self-heating and improve measurement accuracy.

The HDC2080 is factory-calibrated to 0.2°C temperature accuracy and 2% relative humidity accuracy.

Features

Relative humidity range: 0% to 100%
Humidity accuracy: ±2% (typical), ±3% (maximum)
Temperature accuracy: ±0.2°C (typical), ±0.4°C (maximum)
Sleep mode current: 50 nA (typical), 100 nA (maximum)
Average supply current (1 measurement/second)
300 nA: RH% only (11 bit)
550 nA: RH% (11 bit) + temperature (11 bit)

Temperature range:
Operating: –40°C to 85°C
Functional: –40°C to 125°C
Supply voltage range: 1.62 V to 3.6 V

 

Parts Required

I connected a sensor shield to an Arduino and then the sensor via connecting wire

NameLink
Arduino UnoUNO R3 CH340G/ATmega328P, compatible for Arduino UNO
HDC2080HDC2080 Temperature and Humidity Low Power Digital I2C Sensor
Connecting wireFree shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire
sensor shieldExpansion IO Board Sensor Shield

Schematic/Connection

This is a 3.3v rated sensor even though the pin says Vcc

arduino and hdc2080 breadboard

arduino and hdc2080_bb

Code Example

I used the library from https://github.com/tinkeringtech/HDC2080_breakout

This is the default example with a few cosmetic changes

#include <HDC2080.h>
 
#define ADDR 0x40
HDC2080 sensor(ADDR);
 
float temperature = 0, humidity = 0;
 
void setup() {
 
  Serial.begin(9600);
  Serial.println("TinkeringTech HDC2080 Test");
 
  // Initialize I2C communication
  sensor.begin();
 
  // Begin with a device reset
  sensor.reset();
 
  // Set up the comfort zone
  sensor.setHighTemp(48);         // High temperature of 28C
  sensor.setLowTemp(2);          // Low temperature of 22C
  sensor.setHighHumidity(95);     // High humidity of 55%
  sensor.setLowHumidity(10);      // Low humidity of 40%
 
  // Configure Measurements
  sensor.setMeasurementMode(TEMP_AND_HUMID);  // Set measurements to temperature and humidity
  sensor.setRate(ONE_HZ);                     // Set measurement frequency to 1 Hz
  sensor.setTempRes(FOURTEEN_BIT);
  sensor.setHumidRes(FOURTEEN_BIT);
 
  //begin measuring
  sensor.triggerMeasurement();
}
 
void loop() {
 
  Serial.print("Temperature (C): ");
  Serial.print(sensor.readTemp());
  Serial.print("\t\tHumidity (%): ");
  Serial.println(sensor.readHumidity());
 
  // Wait 1 second for the next reading
  delay(2000);
 
}

 

Output

Open the serial monitor and you should see something like this

Temperature (C): 25.14 Humidity (%): 52.86
Temperature (C): 25.12 Humidity (%): 52.89
Temperature (C): 25.11 Humidity (%): 52.95
Temperature (C): 25.10 Humidity (%): 52.96
Temperature (C): 25.17 Humidity (%): 53.18

I do get some erratic readings at times, values like the following. I haven’t investigated this fully – I did try and increase and decrease the delay between readings with no luck.

Temperature (C): -40.00 Humidity (%): 0.00

 

Links

https://www.ti.com/lit/gpn/hdc2080

 

Summary

A nice little sensor but at just over $8 there are cheaper sensors available which have the same functionality, the library and code may need some work to work more reliably.

Share

AM2320 temperature and humidity sensor and Arduino example

Temperature and humidity combined sensor AM2320 digital temperature and humidity sensor is a digital signal output has been calibrated. Using special temperature and humidity acquisition technology, ensure that the product has a very high reliability and excellent long-term stability. Sensor consists of a capacitive moisture element and an integrated high-precision temperature measurement devices, and connected with a high-performance microprocessor .

AM2320 communication using a single bus, two communication modes standard I2C. Standard single-bus interface, the system integration becomes easy and quick. Ultra-small size, low power consumption, signal transmission distance up to 20 meters, making all kinds of applications and even the most demanding applications the best choice. I2C communication using standard communication sequence, the user can directly linked to the I2C communication bus without additional wiring, simple to use. Two communication modes are used as humidity, temperature, and other digital information directly CRC checksum temperature-compensated output, users do not need to calculate the secondary digital output, and no need for temperature compensation of the humidity, temperature and humidity can be accurately information. Two communication modes are free to switch, the user can freely choose, easy to use, wide range of applications.

 

Specifications

• Operating Voltage: 3.1 VDC to 5.5 VDC
• Operating Temperature Range: -40 ° C to + 80 ° C
• Humidity Range: 0 to 99.9% RH
• Accuracy ( 25 ° C environment)
Temperature: ± 0.5 ° C
Humidity: ± 3%
• RH (10 … 90% RH)
Resolution: Temperature: 0.1 ° C
Resolution: Humidity: 0.1% RH
• Attenuation values
Temperature: <0.1 ℃ / Year
Humidity: <1% RH / Year
• Response time: Temperature: 5s
• Response Time: Humidity: 5s 1 / e (63%)
• Output signal: single bus / IIC signal
• Housing material: PC plastic

 

Layout

I couldn’t find a fritzing part but as you can see being a simple I2C sensor with a 3.1 to 5.5v range its straightforward to connect this device to an Arduino Uno

 

arduino and am2302

arduino and am2302

 

Code

You will need to install the folllowing library from https://github.com/EngDial/AM2320

This is the default example

 

#include <Wire.h>
#include <AM2320.h>
 
AM2320 th;
 
void setup() {
Serial.begin(9600);
Wire.begin();
}
 
void loop() {
Serial.println("Chip = AM2320");
switch(th.Read()) {
case 2:
Serial.println(" CRC failed");
break;
case 1:
Serial.println(" Sensor offline");
break;
case 0:
Serial.print(" Humidity = ");
Serial.print(th.Humidity);
Serial.println("%");
Serial.print(" Temperature = ");
Serial.print(th.cTemp);
Serial.println("*C");
Serial.println();
break;
}
delay(2000);
}

 

 

 

Output

Open the serial monitor

Chip = AM2320
Humidity = 47.10%
Temperature = 24.80*C

Chip = AM2320
Humidity = 48.70%
Temperature = 25.10*C

Chip = AM2320
Humidity = 53.60%
Temperature = 25.40*C

Chip = AM2320
Humidity = 55.80%
Temperature = 25.80*C

Chip = AM2320
Humidity = 59.80%
Temperature = 26.20*C

 

Links

AM2320 Digital Temperature and Humidity Sensor Replace AM2302 SHT10

https://akizukidenshi.com/download/ds/aosong/AM2320.pdf

Share

Arduino and SI7021 Humidity and Temperature Sensor example

The Si7021 I2C Humidity and Temperature Sensor is a monolithic CMOS IC integrating humidity and temperature sensor elements, an analog-to-digital converter, signal processing, calibration data, and an I2C Interface. The patented use of industry-standard, low-K polymeric dielectrics for sensing humidity enables the construction of low-power, monolithic CMOS Sensor ICs with low drift and hysteresis, and excellent long term stability, it would be a great sensor to have on the roller. It would be able to measure everything before I go out for a ride around town.

Features

  • Relative Humidity Sensor:
    • Si7013/21: ± 3% RH (maximum) @ 0-80% RH
    • Si7020: ± 4% RH (maximum) @ 0-80% RH
    • Si7006: ± 5% RH (maximum) @ 0-80% RH
  • Temperature Sensor:
    • Si7013/20/21: ±0.4°C accuracy (maximum) @ -10 to +85°C
    • Si7006: ±1.0°C accuracy (maximum) @ -10 to +85°C
  • 0 to 100% RH operating range
  • Up to -40 to +125°C operating range
  • Wide operating voltage range (1.9 to 3.6V)
  • Low Power Consumption: 2.2µW average power at 3.3V and 1 sample per second
  • I2C host interface
  • Integrated on-chip heater
  • 3mm x 3mm QFN package
  • Excellent long term stability
  • Factory calibrated
  • Optional factory-installed filter/cover
    • Lifetime protection during reflow and in operation
    • Protects against contamination from dust, dirt, household chemicals and other liquids
    • AEC-Q100 automotive qualified (Si7013/20/21)

Connection

Must use 3v3 for Vin

Arduino PinsModule Pins
 3v3 Vin
 Gnd Gnd
 SDA SDA
 SCL SCL

Code

#include <Wire.h>
 
const int ADDR =0x40;
int X0,X1,Y0,Y1,Y2,Y3;
double X,Y,X_out,Y_out1,Y_out2;
 
void setup()
{
  Serial.begin(9600);
  Wire.begin();
  delay(100);
  Wire.beginTransmission(ADDR);
  Wire.endTransmission();
}
 
void loop()
{
  /**Send command of initiating temperature measurement**/
  Wire.beginTransmission(ADDR);
  Wire.write(0xE3);
  Wire.endTransmission();
 
  Serial.print("Temp");
  Serial.print("\t");
  Serial.println("Humidity");
 
  /**Read data of temperature**/
  Wire.requestFrom(ADDR,2);
 
  if(Wire.available()<=2);
  {
    X0 = Wire.read();
    X1 = Wire.read();
    X0 = X0<<8;
    X_out = X0+X1;
  }
 
  /**Calculate and display temperature**/
  X=(175.72*X_out)/65536;
  X=X-46.85;
  Serial.print(X);
  Serial.print("C");
  Serial.print("\t");
 
  /**Send command of initiating relative humidity measurement**/
  Wire.beginTransmission(ADDR);
  Wire.write(0xE5);
  Wire.endTransmission();
 
  /**Read data of relative humidity**/
  Wire.requestFrom(ADDR,2);
  if(Wire.available()<=2);
  {
    Y0 = Wire.read();
    Y2=Y0/100;
    Y0=Y0%100;
    Y1 = Wire.read();
    Y_out1 = Y2*25600;
    Y_out2 = Y0*256+Y1;
  }
 
  /**Calculate and display relative humidity**/
  Y_out1 = (125*Y_out1)/65536;
  Y_out2 = (125*Y_out2)/65536;
  Y = Y_out1+Y_out2;
  Y=Y-6;
  Serial.print(Y);
  Serial.println("%");
 delay(300);
 
 
Serial.println();
delay(1000);
 
}

Output

Open the serial monitor, you should see something like this

Temp    Humidity
23.12C    52.83%

Temp    Humidity
24.04C    53.13%

Temp    Humidity
26.28C    53.83%

Temp    Humidity
27.42C    54.57%

Temp    Humidity
28.27C    55.32%

Temp    Humidity
27.94C    56.11%

Links
Humidity Temperature Sensor Breakout Barometric Pressure SI7021 for Arduino GY-21

Share

Sending SHT31 data to thingspeak using an Arduino Uno

In this example we will take the SHt31, read the temperature and humidity and send this data to an online IoT platform, in this case we will use Thingspeak. To achieve this we will need an Arduino Uno with an Ethernet shield fitted and then we will connect the SHt31sensor to this.

We covered the SHT31 in the Arduino and SHT31 module so we will focus on the thingspeak part and arduino code here

You will now need to create a new account at thingspeak – https://thingspeak.com. Once done create a new channel and add two new fields called temperature and humidity. You can see this in a screen capture of my simple channel, notice the ChannelID you will need that in your code later. You can also fill in other fields such as Name, description and there are a few others as well. The key ones are Field1 and Field2 – this effectively is the data you send to thingspeak

thingspeak1

Layout

This layout shows the SHT31 connected to the ethernet shield

ethernet-and-sht31_bb

Code

You will need to install the thingspeak library first of all. 2 options here

In the Arduino IDE, choose Sketch/Include Library/Manage Libraries. Click the ThingSpeak Library from the list, and click the Install button.

— or —

  1. Download the ZIP file from https://github.com/mathworks/thingspeak-arduino to your machine.
  2. In the Arduino IDE, choose Sketch/Include Library/Add Zip Library
  3. Navigate to the ZIP file, and click Open

 

 

Here is the code, its basically a merge of a basic SHt31 example and the thingspeak WriteVoltage example with a lot of the hardware specific code removed – so it only works for an Arduino Uno and an Ethernet shield whereas the WriteVoltaghe example can cater for various pieces of hardware such as an ESP8266, WiFi shield, Arduino Yun

#define USE_ETHERNET_SHIELD
 
#include "ThingSpeak.h"
#include <Arduino.h>
#include <Wire.h>
#include "Adafruit_SHT31.h"
#include <SPI.h>
#include <Ethernet.h>
 
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
 
EthernetClient client;
Adafruit_SHT31 sht31 = Adafruit_SHT31();
//change the following for your channel and api key
unsigned long myChannelNumber = 11111;
const char * myWriteAPIKey = "api key in here";
 
void setup()
{
 //start the serial
 //Serial.begin(9600);
 //network stuff
 Ethernet.begin(mac);
 ThingSpeak.begin(client);
 //start the sensor
 if (! sht31.begin(0x44))
 {
 //Serial.println("Couldn't find SHT31");
 while (1) delay(1);
 }
}
 
void loop()
{
 
 // Write to ThingSpeak. There are up to 8 fields in a channel, allowing you to store up to 8 different
 // pieces of information in a channel. Here, we write to field 1 and 2
 ThingSpeak.setField(1,sht31.readTemperature());
 ThingSpeak.setField(2,sht31.readHumidity());
 ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
 delay(20000); // ThingSpeak will only accept updates every 15 seconds.
}

 

Testing

Navigate to your thingspeak channel and take a look at the private view, all going well you should see a nice graph of data. You can actually get code and embed this on another site. You can also play about with colours and more

Here is a screen capture of mine

thingspeaksht31

 

 

 

Further Steps

There are obviously alternatives to thingspeak which we will look at and we are only scratching the surface using two fields when 8 are available. This example used a specific hardware combination and we will look at others in future articles such as a Wifi shield

 

Links

https://thingspeak.com/

1PCS/LOT SHT31 Temperature & SHT31-D Humidity Sensor module Breakout Weather for Arduino

 

Share