SHTC1 digital humidity sensor and ESP8266 example

In this article we look at another digital humidity sensor – this time its the SHTC1 and we will connect it to a Wemos Mini

The SHTC1 is a digital humidity sensor designed especially for high-volume consumer electronics applications. This humidity sensor is strictly designed to overcome conventional limits for size, power consumption, and price-performance ratio, in order to fulfill the current and future requirements of the consumer electronics market.

Sensirion’s CMOSens® technology offers a complete sensor system on a single chip, consisting of a capacitive humidity sensor, a band-gap temperature sensor, analog and digital signal processing, A/D converter, calibration data memory, and a digital communication interface supporting I2C fast mode. The ultra-small, 2 × 2 × 0.75 mm3 DFN package enables applications to be placed in even the most limited of spaces. The sensor covers a humidity measurement range of 0 to 100 %RH and a temperature measurement range of –30°C to 100°C with a typical accuracy of ±3 %RH and ±0.3°C.

The operating voltage of 1.8 V and an energy budget below 1 µJ per measurement make the SHTC1 suitable for mobile or wireless applications running on the lowest power budgets. With the industry-proven quality and reliability of Sensirion’s humidity sensors and constant accuracy over a large measurement range, the SHTC1 humidity sensor offers an unprecedented price-performance ratio. Tape and reel packaging together with suitability for standard SMD assembly processes make the SHTC1 predestined for high-volume applications.

Features

Interface I²C
Supply voltage 1.8 V
Power consumption 2µW (at 1 reading per second in low power mode)
Measuring range (RH) 0 – 100% relative humidity
Measuring range (T) -30 to +100°C (-22 to +212°F)
Response time (RH) 8s (tau63%)

Parts Required

 

Name Link
ESP8266 (Wemos Mini) D1 mini – ESP8266
SHTC1 SHTC1 digital temperature and humidity sensor
Connecting wire Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire
sensor shield Expansion IO Board Sensor Shield

Schematic/Connection

Wemos Sensor
3.3v Vcc
Gnd Gnd
SDA (D2) SDA
SCL (D1) SCL

 

Code Example

This uses the library from https://github.com/Sensirion/arduino-sht

#include <Wire.h>
#include "SHTSensor.h"
SHTSensor sht;
// To use a specific sensor instead of probing the bus use this command:
// SHTSensor sht(SHTSensor::SHT3X);
void setup() {
// put your setup code here, to run once:
Wire.begin();
Serial.begin(9600);
delay(1000); // let serial console settle
if (sht.init()) {
Serial.print("init(): success\n");
} else {
Serial.print("init(): failed\n");
}
sht.setAccuracy(SHTSensor::SHT_ACCURACY_MEDIUM); // only supported by SHT3x
}
void loop() {
// put your main code here, to run repeatedly:
if (sht.readSample()) {
Serial.print("SHT:\n");
Serial.print(" RH: ");
Serial.print(sht.getHumidity(), 2);
Serial.print("\n");
Serial.print(" T: ");
Serial.print(sht.getTemperature(), 2);
Serial.print("\n");
} else {
Serial.print("Error in readSample()\n");
}
delay(1000);
}

 

Output

Open the serial monitor and you should see something like this

init(): success
SHT:
RH: 43.97
T: 20.05
SHT:
RH: 43.99
T: 20.01
SHT:
RH: 44.01
T: 20.00

 

Links

 

 

 

 

 

ESP8266 and LPS22HB absolute pressure sensor example

In this article we look at another absolute pressure sensor – this time its the LPS22HB

Once again lets look at this sensor from the manufacturers perspective

Description

The LPS22HB is an ultra-compact piezoresistive absolute pressure sensor which functions as a digital output barometer. The device comprises a sensing element and an IC interface which communicates through I2C or SPI from the sensing element to the application.

The sensing element, which detects absolute pressure, consists of a suspended membrane manufactured using a dedicated process developed by ST.
The LPS22HB is available in a full-mold, holed LGA package (HLGA). It is guaranteed to operate over a temperature range extending from -40 °C to +85 °C. The package is holed to allow external pressure to reach the sensing element.

Features

  • 260 to 1260 hPa absolute pressure range
  • Current consumption down to 3 μA
  • High overpressure capability: 20x full-scale
  • Embedded temperature compensation
  • 24-bit pressure data output
  • 16-bit temperature data output
  • ODR from 1 Hz to 75 Hz
  • SPI and I²C interfaces
  • Embedded FIFO
  • Interrupt functions: Data Ready, FIFO flags, pressure thresholds
  • Supply voltage: 1.7 to 3.6 V
  • High shock survivability: 22,000 g

 

Parts Required

Around $5 for the module

Name Link
Wemos Mini D1 mini – ESP8266 by WeMos
LPS22HB Semoic Lps22Hb Pressure Resistance Pressure Sensor Module for High Intensity Industrial Control
Connecting wire Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire

Schematic/Connection

 

esp8266 and LPS22HB
esp8266 and LPS22HB

 

Code Example

This uses the library from https://github.com/adrien3d/IO_LPS22HB

This is the default example which works fine

/***************************************************************************
  This is a library for the LPS22HB Absolute Digital Barometer
 
  Designed to work with all kinds of LPS22HB Breakout Boards
 
  These sensors use I2C, 2 pins are required to interface, as this :
	VDD to 3.3V DC
	SCL to A5
	SDA to A4
	GND to common groud 
 
  Written by Adrien Chapelet for IoThings
 ***************************************************************************/
 
#include <Wire.h>
 
#include "IO_LPS22HB.h"
 
IO_LPS22HB lps22hb;
 
void setup()
{
	Serial.begin(9600);
	Serial.println("IoThings LPS22HB Arduino Test");
 
	lps22hb.begin(0x5D);
 
	byte who_am_i = lps22hb.whoAmI();
	Serial.print("Who Am I? 0x");
	Serial.print(who_am_i, HEX);
	Serial.println(" (expected: 0xB1)");
	if (who_am_i != LPS22HB_WHO_AM_I_VALUE) {
		Serial.println("Error while retrieving WHO_AM_I byte...");
		while (true) {
		      // loop forever
		}
	}
}
 
void loop()
{
	Serial.print("P=");
	Serial.print(lps22hb.readPressure());
	Serial.print(" mbar, T=");
	Serial.print(lps22hb.readTemperature());
	Serial.println("C");
	delay(300);
}

Output

Open the serial monitor and you should see something like this – I put my finger on the sensor, hence the value is rising

P=983.26 mbar, T=27.88C
P=983.22 mbar, T=28.27C
P=983.24 mbar, T=28.60C
P=983.24 mbar, T=28.93C
P=983.27 mbar, T=29.23C
P=983.24 mbar, T=29.50C
P=983.24 mbar, T=29.71C
P=983.25 mbar, T=29.89C
P=983.26 mbar, T=30.05C
P=983.25 mbar, T=30.21C
P=983.23 mbar, T=30.34C

I wanted to check the pressure out so I visited the following website – https://www.worldweatheronline.com . There are several others.

They stated that the pressure was – Pressure: 992 mb

So not to bad

Links

https://www.st.com/resource/en/datasheet/lps22hb.pdf

 

 

ESP8266 and BMA400 acceleration sensor example

In this article we look at another acceleration sensor – this time its the BMA400

Lets take a look at the sensor and its features

Description

The BMA400 is the first real ultra-low power acceleration sensor without compromising on performance. Featuring 12-bit digital resolution, continuous measurement and a defined selectable bandwidth combined with ultra-low power the BMA400 allows low-noise measurement of accelerations in three perpendicular axes. The BMA400 thus senses tilt, orientation, tab/double tab, and enables plug ’n’ play step counting with activity recognition especially suited for wearable devices, which need a long-lasting battery lifetime.

Thanks to the continuous measurement principle and always-defined bandwidth, the BMA400 is the ideal solution for smart home applications such as smart indoor climate systems and smart home security systems. In the latter, the BMA400 can distinguish between real alarm situations like broken glass and false signals coming from random vibrations. Thereby, the new acceleration sensor avoids false alarms.

Features

Parameter Technical data
Measurement range ±2 g, ±4 g, ±8 g, ±16 g
Digital resolution 12 bit
Output Data Rate (ODR) 12.5 Hz to 800 Hz
Low path filter bandwidth Selectable 0.48xODR or 0.24xODR
Current consumption (independent from ODR due to continuous measurement) Max. performance: 14.5 μA
Typical use case: 5.8 μA
Low power use case: 3.5μA
Noise density Max. performance: 180 μg/√Hz (Z: x 1.45)
Typical use case: 300 μg/√Hz (Z: x 1.45)
Low power: 415 μg/√Hz (Z: x 1.45)
Ultra low power / Auto-wake-up mode 800 nA @ 25 Hz ODR
Embedded features
  • Step counter (< 4 μA overall)
  • Activity recognition (walking, running, standing still)
  • Activity change
  • Orientation
  • Tab/Double tab (< 8 μA overall)
  • General interrupt 1 and 2 (programmable via thresholds, timer, logical AND/OR operations)
  • 1 kB FIFO
Offset ±80 mg
TCO ±1 mg/K
Interface SPI & I²C & 2 Interrupt pins
Supply voltage 1.71 V up to 3.6 V

Parts Required

 

Name Link
Wemos Mini D1 mini – ESP8266 by WeMos
BMA400 BMA400 Acceleration Sensor
Connecting wire Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire

Schematic/Connection

 

esp8266 and BMA400
esp8266 and BMA400

 

Code Example

This uses the library from https://github.com/Seeed-Studio/Grove_3Axis_Digital_Accelerometer_BMA400

No need to change the default code example – it worked just fine

#include "BMA400.h"
 
float x = 0, y = 0, z = 0;
int16_t temp = 0;
 
void setup(void)
{
    Wire.begin();
 
    Serial.begin(115200);
    while(!Serial);
    Serial.println("BMA400 Raw Data");
 
    while(1)
    {
        if(bma400.isConnection())
        {
            bma400.initialize();
            Serial.println("BMA400 is connected");
            break;
        }
        else Serial.println("BMA400 is not connected");
 
        delay(2000);
    }
}
 
void loop(void)
{
    bma400.getAcceleration(&x, &y, &z);
    temp = bma400.getTemperature();
 
    Serial.print(x);
    Serial.print(",");
    Serial.print(y);
    Serial.print(",");
    Serial.print(z);
    Serial.print(",");
 
    Serial.print(temp);
 
    Serial.println();
 
    delay(50);
}

 

Output

Open the serial monitor and you should see something like this when you move the sensor about

189.45,876.95,373.05,32
197.27,884.77,376.95,32
197.27,896.48,382.81,23
183.59,888.67,357.42,31
0.00,0.00,0.00,23
185.55,888.67,380.86,31
0.00,0.00,0.00,23
195.31,904.30,378.91,31
201.17,892.58,380.86,31
234.37,865.23,369.14,31
197.27,867.19,396.48,31

 

Links

https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BMA400-DS000.pdf

https://github.com/BoschSensortec/BMA400-API

https://www.bosch-sensortec.com/bst/products/all_products/bma400_1

 

 

ESP8266 and BMM150 digital geomagnetic sensor example

In this article we look at a digital geomagnetic sensor – this time its the BMM150 and as usual we will connect this to a Wemos Mini

Lets look at the manufacturers blurb about this sensor

Description

BMM150 is a low power and low noise 3-axis digital geomagnetic sensor to be used in compass applications. The 12-pin wafer level chip scale package (WLCSP) with a footprint of 1.56 x 1.56 mm² and 0.60 mm height provides highest design flexibility to the developer of mobile devices.

Applications like virtual reality or gaming on mobile devices such as mobile phones, tablet PCs or portable media players require 9-axis inertial sensing including magnetic heading information. Due to the stable performance over a large temperature range, the BMM150 is also especially suited for supporting drones in accurate heading.

BMM150 can be used with an inertial measurement unit (IMU) consisting of a 3-axis accelerometer and a 3-axis gyroscope like Bosch Sensortec’s BMI055.

 

Features

Parameter Technical data
Package CSWLP- (12 pin)
1.56×1.56×0.6 mm³
0.4 mm diagonal ball pitch
Temperature range -40°C … +85°C
Digital interfaces I²C and SPI
(2 interrupt pins)
Resolution 0.3μT
Supply voltage VDD: 1.62V to 3.6V
VDDIO: 1.2V to 3.6V
Zero-B offset ±50μT
Non-linearity <1% FS
Magnetic range typ. ±1300μT (x,y-axis)
±2500μT (z-axis)
Average current consumption 170 μA (low power preset)
500 μA (normal mode)
Interrupts New data, magnetic threshold high / low

Parts Required

You can pick up all these parts for about $5

Name Link
Wemos Mini D1 mini – ESP8266 by WeMos
BMM150 BMM150 Geomagnetic Sensor Breakout Board
Connecting wire Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire

Schematic/Connection

Nothing complex here, just remember to use 3.3v

esp8266 and bmm150
esp8266 and bmm150

 

Code Example

This uses the library from https://github.com/Seeed-Studio/Grove_3_Axis_Compass_V2.0_BMM150

This is the default example which worked just fine

#include <Arduino.h>
#include <Wire.h>
// libraries
#include "bmm150.h"
#include "bmm150_defs.h"
 
BMM150 bmm = BMM150();
 
void setup()
{
  Serial.begin(9600);
 
  if(bmm.initialize() == BMM150_E_ID_NOT_CONFORM) 
  {
    Serial.println("Chip ID can not read!");
    while(1);
  } 
  else 
  {
    Serial.println("Initialize done!");
  }
 
}
 
void loop()
{
  bmm150_mag_data value;
  bmm.read_mag_data();
 
  value.x = bmm.raw_mag_data.raw_datax;
  value.y = bmm.raw_mag_data.raw_datay;
  value.z = bmm.raw_mag_data.raw_dataz;
 
  float xyHeading = atan2(value.x, value.y);
  float zxHeading = atan2(value.z, value.x);
  float heading = xyHeading;
 
  if(heading < 0)
  heading += 2*PI;
  if(heading > 2*PI)
  heading -= 2*PI;
  float headingDegrees = heading * 180/M_PI;
  float xyHeadingDegrees = xyHeading * 180 / M_PI;
  float zxHeadingDegrees = zxHeading * 180 / M_PI;
 
  Serial.print("Heading: ");
  Serial.println(headingDegrees);
 
  delay(100);
}

 

Output

Open the serial monitor and you should see something like this – I was moving the module around. If you tie this up with an LCD you could make a digital compass – in fact that sounds a good idea for another article

Heading: 60.49
Heading: 56.58
Heading: 53.62
Heading: 37.93
Heading: 37.98
Heading: 38.95
Heading: 39.45
Heading: 42.31
Heading: 36.98
Heading: 18.60
Heading: 10.92
Heading: 355.60
Heading: 348.37
Heading: 351.50
Heading: 352.01
Heading: 29.29
Heading: 64.44

 

Links

https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BMM150-DS001.pdf

https://github.com/BoschSensortec/BMM150-Sensor-API