Categories

An Arduino and SHTC1 digital humidity sensor example

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

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

InterfaceI²C
Supply voltage1.8 V
Power consumption2µ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

 

NameLink
Arduino UnoUNO R3 CH340G/ATmega328P, compatible for Arduino UNO
SHTC1
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

ArduinoSensor
5vVcc
GndGnd
SDASDA
SCLSCL

 

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

 

 

 

 

 

Share

A 1.8 inch TFT Full Color LCD Display Module with Adapter Board for Arduino UNO

In this article we look a shield which allows you to connect an Arduino Esplora TFT LCD to an Arduino Uno or Mega

The Graphic LCD screen is a backlit TFT LCD screen with headers. You can draw text, images, and shapes to the screen with the GLCD library.
There is an onboard micro-SD card slot on the back of the screen that can, among other things, store bitmap images for the screen to display.
The screen is 1.77″ diagonal, with 160 x 128 pixel resolution.
The TFT library interfaces with the screen’s controller through SPI when using the TFT library.
The screen runs on +5 VDC
The micro-SD slot is accessible through the SD card library.
The LED backlight is dimmable by PWM.

Here is a picture of the shield and TFT

Parts

Only $6 for the shield and TFT

PartLink
Arduino UnoArduino UNO R3
TFT shield and LCD1.8 inch TFT Full Color LCD Display Module with LCD Adapter Board Expansion Board

Code

The TFT uses the built-in TFT library which comes with many examples that you can use to test with. The easiest one is the TFTDisplayText example

#include <TFT.h> // Arduino LCD library
#include <SPI.h>
// pin definition for the Uno
#define cs 10
#define dc 9
#define rst 8
// pin definition for the Leonardo
// #define cs 7
// #define dc 0
// #define rst 1
// create an instance of the library
TFT TFTscreen = TFT(cs, dc, rst);
// char array to print to the screen
char sensorPrintout[4];
void setup() {
// Put this line at the beginning of every sketch that uses the GLCD:
TFTscreen.begin();
// clear the screen with a black background
TFTscreen.background(0, 0, 0);
// write the static text to the screen
// set the font color to white
TFTscreen.stroke(255, 255, 255);
// set the font size
TFTscreen.setTextSize(2);
// write the text to the top left corner of the screen
TFTscreen.text("Sensor Value :\n ", 0, 0);
// ste the font size very large for the loop
TFTscreen.setTextSize(5);
}
void loop() {
// Read the value of the sensor on A0
String sensorVal = String(analogRead(A0));
// convert the reading to a char array
sensorVal.toCharArray(sensorPrintout, 4);
// set the font color
TFTscreen.stroke(255, 255, 255);
// print the sensor value
TFTscreen.text(sensorPrintout, 0, 20);
// wait for a moment
delay(250);
// erase the text you just wrote
TFTscreen.stroke(0, 0, 0);
TFTscreen.text(sensorPrintout, 0, 20);
}
Share

Arduino and BMA400 acceleration sensor example

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

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

ParameterTechnical data
Measurement range±2 g, ±4 g, ±8 g, ±16 g
Digital resolution12 bit
Output Data Rate (ODR)12.5 Hz to 800 Hz
Low path filter bandwidthSelectable 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 densityMax. 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 mode800 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
InterfaceSPI & I²C & 2 Interrupt pins
Supply voltage1.71 V up to 3.6 V

Parts Required

 

NameLink
Arduino UnoUNO R3 CH340G/ATmega328P, compatible for Arduino UNO
BMA400BMA400 Acceleration 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

 

arduino and BMA400

arduino and BMA400

 

Code Example

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

#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(500);
}

 

Output

Open the serial monitor and you should see something like this

BMA400 is connected
564.45,808.59,201.17,23
1029.30,-105.47,400.39,23
908.20,-189.45,359.38,23
902.34,-265.63,345.70,23

 

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

 

 

Share

Arduino and LIS3MDL magnetic field sensor example

In this article we look at another sensor – this time its the LIS3MDL which is a 3-axis MEMS magnetic field sensor, digital output, I2C, SPI, low power mode, high performance

The LIS3MDL has user-selectable full scales of ±4/±8/±12/±16 gauss.
The self-test capability allows the user to check the functioning of the sensor in the final application.
The device may be configured to generate interrupt signals for magnetic field detection.
The LIS3MDL includes an I2C serial bus interface that supports standard and fast mode (100 kHz and 400 kHz) and SPI serial standard interface.
The LIS3MDL is available in a small thin plastic land grid array package (LGA) and is guaranteed to operate over an extended temperature range of -40 °C to +85 °C.

Features

  • Wide supply voltage, 1.9 V to 3.6 V
  • Independent IO supply (1.8 V)
  • ±4/±8/±12/±16 gauss selectable magnetic full scales
  • Continuous and single-conversion modes
  • 16-bit data output
  • Interrupt generator
  • Self-test
  • I2C/SPI digital output interface
  • Power-down mode / low-power mode

Parts Required

 

NameLink
Arduino UnoUNO R3 CH340G/ATmega328P, compatible for Arduino UNO
LIS3MDLTaidacent LIS3MDL High Precision 3 Axis Magnetometer Sensor Compass Module Tilt Compensated Compass Replacement HMC5883L
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

Couldn’t find a good fritzing part or image to use, this is the sensor I bought

 

As an added bonus here is the schematic for one of these modules

ArduinoSensor
3.3vVcc
GndGnd
SDA (A4)SDA
SCL (A5)SCL

 

Code Example

This uses the library from https://github.com/pololu/lis3mdl-arduino

/*
The sensor outputs provided by the library are the raw 16-bit values
obtained by concatenating the 8-bit high and low magnetometer data registers.
They can be converted to units of gauss using the
conversion factors specified in the datasheet for your particular
device and full scale setting (gain).
Example: An LIS3MDL gives a magnetometer X axis reading of 1292 with its
default full scale setting of +/- 4 gauss. The GN specification
in the LIS3MDL datasheet (page 8) states a conversion factor of 6842
LSB/gauss (where LSB means least significant bit) at this FS setting, so the raw
reading of 1292 corresponds to 1292 / 6842 = 0.1888 gauss.
*/
#include <Wire.h>
#include <LIS3MDL.h>
LIS3MDL mag;
char report[80];
void setup()
{
Serial.begin(9600);
Wire.begin();
if (!mag.init())
{
Serial.println("Failed to detect and initialize magnetometer!");
while (1);
}
mag.enableDefault();
}
void loop()
{
mag.read();
snprintf(report, sizeof(report), "M: %6d %6d %6d",
mag.m.x, mag.m.y, mag.m.z);
Serial.println(report);
delay(100);
}

 

Output

Open the serial monitor and you should see something like this

M: -1934 5556 6732
M: -2222 5096 6958
M: -1508 5329 7391
M: -1174 5782 7194
M: -119 6447 6429
M: 447 6333 4702
M: 92 6073 4256
M: -1190 6107 5068
M: -1401 5808 6758
M: -502 5195 7839
M: 740 4453 8173
M: 1327 3639 8161
M: 1421 3006 4294

 

Links

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

 

 

 

Share