Arduino Due and SHT20 sensor

In this article we connect an SHT20 sensor to an Arduino Due

The SHT2x series consists of a low-cost version with the SHT20 humidity sensor. the SHT2x provides calibrated, linearized sensor signals in digital, I2C format. The SHT2x humidity sensor series contains a capacitive-type humidity sensor, a band-gap temperature sensor, and specialized analog and digital integrated circuits – all on a single CMOSens® chip. This yields superior sensor performance in terms of accuracy and stability as well as minimal power consumption.

Every sensor is individually calibrated and tested. Furthermore, the resolution of the SHT2x humidity sensor can be changed on command (8/12 bit up to 12/14 bit for RH/T) and a checksum helps to improve communication reliability.

Performance

  • Size: 3 x 3 x 1.1mm
  • Output: I²C digital, PWM, SDM
  • Supply voltage range: 2.1 to 3.6V
  • Energy consumption:  3.2µW (at 8 bit, 1 measurement/s)
  • RH operating range: 0 – 100%RH
  • T operating range:  -40°C to +125°C (-40°F to +257°F)
  • RH response time: 8 sec (tau63%)

Parts List

 

Amount Part Type
1 Temperature and humidity detection sensor module SHT20
1 Compatible DUE R3 Board SAM3X8E 32-bit ARM Cortex-M3

 

Schematics/Layout

 

arduino due and SHT20 layout

arduino due and SHT20 layout

 

Code

We use the following library – https://github.com/DFRobot/DFRobot_SHT20

#include <Wire.h>
#include "DFRobot_SHT20.h"
 
DFRobot_SHT20    sht20;
 
void setup()
{
    Serial.begin(9600);
    Serial.println("SHT20 Example!");
    sht20.initSHT20();                                  // Init SHT20 Sensor
    delay(100);
    sht20.checkSHT20();                                 // Check SHT20 Sensor
}
 
void loop()
{
    float humd = sht20.readHumidity();                  // Read Humidity
    float temp = sht20.readTemperature();               // Read Temperature
    Serial.print("Time:");
    Serial.print(millis());
    Serial.print(" Temperature:");
    Serial.print(temp, 1);
    Serial.print("C");
    Serial.print(" Humidity:");
    Serial.print(humd, 1);
    Serial.print("%");
    Serial.println();
    delay(1000);
}

 

Output

Open the serial monitor – this is what I saw

SHT20 Example!
End of battery: no
Heater enabled: no
Disable OTP reload: yes
Time:202 Temperature:18.8C Humidity:64.3%
Time:1302 Temperature:18.8C Humidity:64.3%
Time:2402 Temperature:18.8C Humidity:64.2%
Time:3502 Temperature:20.2C Humidity:64.4%
Time:4602 Temperature:23.3C Humidity:67.4%
Time:5702 Temperature:24.7C Humidity:72.2%
Time:6802 Temperature:25.5C Humidity:75.0%
Time:7902 Temperature:26.1C Humidity:76.2%
Time:9002 Temperature:26.7C Humidity:76.7%

 

Links

Sensirion_Humidity_Sensors_SHT20_Datasheet.pdf

 

Share

Arduino Due and CCS811 gas sensor example

In this article we connect a CCS811 gas sensor to an Arduino Due

CCS811 is a low-power digital gas sensor solution, which integrates a gas sensor solution for detecting low levels of VOCs typically found indoors, with a microcontroller unit (MCU) and an Analog-to-Digital converter to monitor the local environment and provide an indication of the indoor air quality via an equivalent CO2 or TVOC output over a standard I2C digital interface.

Features

Integrated MCU
On-board processing
Standard digital interface
Optimised low power modes
IAQ threshold alarms
Programmable baseline
2.7mm x 4.0mm LGA package
Low component count
Proven technology platform

Specs

Interface I²C
Supply Voltage [V] 1.8 to 3.6
Power Consumption [mW] 1.2 to 46
Dimension [mm] 2.7 x 4.0 x 1.1 LGA
Ambient Temperature Range [°C] -40 to 85
Ambient Humidity Range [% r.h.] 10 to 95

Parts List

 

 

Amount Part Type
1 CJMCU-811 CCS811 Air Quality Gas Sensor
1 Compatible DUE R3 Board SAM3X8E 32-bit ARM Cortex-M3

 

Schematics/Layout

Remember and connect WAKE to gnd

arduino due and CCS811 layout

arduino due and CCS811 layout

 

Code

We use the adafruit library which can be added using the library manager

#include "Adafruit_CCS811.h"
Adafruit_CCS811 ccs;
void setup() {
Serial.begin(9600);
Serial.println("CCS811 test");
if(!ccs.begin()){
Serial.println("Failed to start sensor! Please check your wiring.");
while(1);
}
//calibrate temperature sensor
while(!ccs.available());
float temp = ccs.calculateTemperature();
ccs.setTempOffset(temp - 25.0);
}
void loop() {
if(ccs.available()){
float temp = ccs.calculateTemperature();
if(!ccs.readData()){
Serial.print("CO2: ");
Serial.print(ccs.geteCO2());
Serial.print("ppm, TVOC: ");
Serial.print(ccs.getTVOC());
Serial.print("ppb Temp:");
Serial.println(temp);
}
else{
Serial.println("ERROR!");
while(1);
}
}
delay(500);
}

 

Output

Open the serial monitor – this is what I saw. The higher CO2 level was when I breathed on the sensor

CO2: 742ppm, TVOC: 52ppb Temp:22.61
CO2: 629ppm, TVOC: 34ppb Temp:21.88
CO2: 460ppm, TVOC: 9ppb Temp:20.01
CO2: 400ppm, TVOC: 0ppb Temp:21.88
CO2: 400ppm, TVOC: 0ppb Temp:24.61
CO2: 400ppm, TVOC: 0ppb Temp:25.00
CO2: 400ppm, TVOC: 0ppb Temp:24.61
CO2: 400ppm, TVOC: 0ppb Temp:24.61

 

Links

ccs811 datasheet

 

Share

Arduino Due and TMP175 sensor

Another sensor or module to cross our path, this time we will look at the TMP175 digital temperature sensors

The TMP175 devices is a digital temperature sensors ideal for NTC and PTC thermistor replacement. The device offers a typical accuracy of ±1°C without requiring calibration or external component signal conditioning. IC temperature sensors are highly linear and do not require complex calculations or look-up tables to derive the temperature. The on-chip 12-bit ADC offers resolutions down to 0.0625°C.

The TMP175  feature SMBus, Two-Wire, and I2C interface compatibility. The TMP175 device allows up to 27 devices on one bus. . The TMP175  feature an SMBus Alert function.

The TMP175 are ideal for extended temperature measurement in a variety of communication, computer, consumer, environmental, industrial, and instrumentation applications.

Features

  • TMP175: 27 Addresses
  • Digital Output: SMBus™, Two-Wire™, and I2C
    Interface Compatibility
  • Resolution: 9 to 12 Bits, User-Selectable
  • Accuracy:
    • ±1°C (Typical) from –40°C to 125°C
    • ±2°C (Maximum) from –40°C to 125°C
  • Low Quiescent Current: 50-µA, 0.1-µA Standby
  • Wide Supply Range: 2.7 V to 5.5 V
  • Small 8-Pin MSOP and 8-Pin SOIC Packages

 

Connection

 

Module Connection Arduino Due Connection
VCC 3v3
GND Gnd
SDA SDA
SCL SCL

 

Code

#include <Wire.h> 
 
byte TempHi;              // Variable hold data high byte
byte TempLo;              // Variable hold data low byte
boolean P_N;              // Bit flag for Positive and Negative
unsigned int Decimal;     // Variable hold decimal value
 
void Cal_Temp();
/*******************************************************************************
                      Setup
*******************************************************************************/ 
void setup() 
{ 
  Serial.begin(9600);
  Wire.begin();             // join i2c bus (address optional for master) 
  delay(1000);
} 
 
/*******************************************************************************
                      Main Loop
*******************************************************************************/  
void loop() 
{
  const int I2C_address = 0x37;  // I2C write address 
 
  delay(100);
  Wire.beginTransmission(I2C_address);
  Wire.write(1);             // Setup configuration register
  Wire.write(0x60);          // 12-bit
  Wire.endTransmission(); 
 
  Wire.beginTransmission(I2C_address);
  Wire.write(0);             // Setup Pointer Register to 0
  Wire.endTransmission(); 
 
  while (1)
  {
    delay(1000);
 
    // Read temperature value
    Wire.requestFrom(I2C_address, 2);
    while(Wire.available())          // Checkf for data from slave
    {                                
      TempHi = Wire.read();       // Read temperature high byte
      TempLo = Wire.read();       // Read temperature low byte
    } 
    Cal_Temp ();
 
    // Display temperature
    Serial.print("The temperature is ");
    if (P_N == 0)
      Serial.print("-");
    Serial.print(TempHi,DEC);
    Serial.print(".");
    Serial.print(Decimal,DEC);
    Serial.println(" degree C");
  }  
}
 
void Cal_Temp()
{
  if (TempHi&0x80)          // If bit7 of the TempHi is HIGH then the temperature is negative
    P_N = 0;
  else                      // Else the temperature is positive
    P_N = 1;
 
  TempHi = TempHi & 0x7F;   // Remove sign
  TempLo = TempLo & 0xF0;   // Filter out last nibble
  TempLo = TempLo >>4;      // Shift right 4 times
  Decimal = TempLo;
  Decimal = Decimal * 625;  // Each bit = 0.0625 degree C
 
}

 

Output

Open up the trusty serial monitor and you will see something like this all going well

The temperature is 18.6250 degree C
The temperature is 18.6250 degree C
The temperature is 18.6250 degree C
The temperature is 18.6250 degree C
The temperature is 19.1250 degree C
The temperature is 22.5000 degree C
The temperature is 24.1250 degree C
The temperature is 25.3125 degree C
The temperature is 26.3125 degree C

 

Link

1pcs CJMCU-175 TMP175 27 Address Digital Temperature Sensor

Share

Arduino Due and MPL3115A2 example

In this example we connect a MPL3115A2 to an Arduino Due

The MPL3115A2 is a compact, piezoresistive, absolute pressure sensor with an I2C digital interface. MPL3115A2 has a wide operating range of 20 kPa to 110 kPa, a range that covers all surface elevations on earth. The MEMS is temperature compensated utilizing an on-chip temperature sensor. The pressure and temperature data is fed into a high resolution ADC to provide fully compensated and digitized outputs for pressure in Pascals and temperature in °C.

The compensated pressure output can then be converted to altitude, utilizing the formula stated in Section 9.1.3 “Pressure/altitude” provided in meters.The internal processing in MPL3115A2 removes compensation and unit conversion load from the system MCU, simplifying system design

• Operating range: 20 kPa to 110 kPa absolute pressure
• Calibrated range: 50 kPa to 110 kPa absolute pressure
• Calibrated temperature output: −40 °C to 85 °C
• I2C digital output interface
• Fully compensated internally
• Precision ADC resulting in 0.1 meter of effective resolution
• Direct reading
– Pressure: 20-bit measurement (Pascals) 20 to 110 kPa
– Altitude: 20-bit measurement (meters) –698 to 11,775 m
– Temperature: 12-bit measurement (°C) –40 °C to 85 °C
• Programmable interrupts
• Autonomous data acquisition
– Embedded 32-sample FIFO
– Data logging up to 12 days using the FIFO
– One-second to nine-hour data acquisition rate
• 1.95 V to 3.6 V supply voltage, internally regulated
• 1.6 V to 3.6 V digital interface supply voltage
• Operating temperature from −40 °C to +85 °C

Parts List

 

Amount Part Type
1 MPL3115A2 I2C Intelligent Temperature Pressure Altitude Sensor V2.0 For Arduino
1 Compatible DUE R3 Board SAM3X8E 32-bit ARM Cortex-M3

 

Schematics/Layout

 

arduino due and mpl3115a2

arduino due and mpl3115a2

 

Code

Again we use a library and again its an adafruit one – https://github.com/adafruit/Adafruit_MPL3115A2_Library

#include <Wire.h>
#include <Adafruit_MPL3115A2.h>
 
// Power by connecting Vin to 3-5V, GND to GND
// Uses I2C - connect SCL to the SCL pin, SDA to SDA pin
// See the Wire tutorial for pinouts for each Arduino
// http://arduino.cc/en/reference/wire
Adafruit_MPL3115A2 baro = Adafruit_MPL3115A2();
 
void setup() {
  Serial.begin(9600);
  Serial.println("Adafruit_MPL3115A2 test!");
}
 
void loop() {
  if (! baro.begin()) {
    Serial.println("Couldnt find sensor");
    return;
  }
 
  float pascals = baro.getPressure();
  // Our weather page presents pressure in Inches (Hg)
  // Use http://www.onlineconversion.com/pressure.htm for other units
  Serial.print(pascals/3377); Serial.println(" Inches (Hg)");
 
  float altm = baro.getAltitude();
  Serial.print(altm); Serial.println(" meters");
 
  float tempC = baro.getTemperature();
  Serial.print(tempC); Serial.println("*C");
 
  delay(250);
}

 

Output

Open the serial monitor – here are my results

 

 

Links

https://www.nxp.com/docs/en/data-sheet/MPL3115A2.pdf

 

Share

Arduino Due and MLX90615 example

The MLX90615 is a miniature infrared thermometer for non-contact temperature measurements. Both the IR sensitive thermopile detector chip and the signal conditioning ASIC are integrated in the same miniature TO-46 can.

The infrared thermometer comes factory calibrated with a digital SMBus output giving full access to the measured temperature in the complete temperature range(s) with a resolution of 0.02 °C. The sensor achieves an accuracy of ±0.2°C within the relevant medical temperature range. The user can choose to configure the digital output to be PWM.

Features and benefits

Factory calibrated in wide temperature range: -20 to 85°C for sensor temperature and -40 to 115°C for object temperature
High accuracy of 0.5°C over wide temperature range (0..+50 C for both Ta and To)
Medical accuracy of 0.2°C in a limited temperature range
Measurement resolution of 0.02°C
SMBus compatible digital interface for fast temperature readings and building sensor networks
Customizable PWM output for continuous reading
3V supply voltage with power saving mode

 

Parts List

 

 

Amount Part Type
1 1PCS MLX90615 Digital Infrared Temperature Sensor for Arduino
1 Compatible DUE R3 Board SAM3X8E 32-bit ARM Cortex-M3

 

Layout

 

 

Code Example

This particular example comes from the following library which I installed – https://github.com/skiselev/MLX90615

I had issues with one of the other libraries – this one works just fine

#include <Wire.h>
#include <mlx90615.h>
MLX90615 mlx = MLX90615();
void setup()
{
Serial.begin(9600);
Serial.println("Melexis MLX90615 infra-red temperature sensor test");
mlx.begin();
Serial.print("Sensor ID number = ");
Serial.println(mlx.get_id(), HEX);
}
void loop()
{
Serial.print("Ambient = ");
Serial.print(mlx.get_ambient_temp());
Serial.print(" *C\tObject = ");
Serial.print(mlx.get_object_temp());
Serial.println(" *C");
delay(500);
}

 

Output

Open the serial monitor and you should see something like this. I moved a hot object near the sensor when the second value increased

 

 

Links

https://www.melexis.com/-/media/files/documents/datasheets/mlx90615-datasheet-melexis.pdf

Share