Categories

Arduino Uno and HDC1080 humidity and temperature sensor

The HDC1080 is a digital humidity sensor with integrated temperature sensor that provides excellent measurement accuracy at very low power. The HDC1080 operates over a wide supply range, and is a low cost, low power alternative to competitive solutions in a wide range of common applications. The humidity and temperature sensors are factory calibrated.

Features
Relative Humidity Accuracy ±2% (typical)
Temperature Accuracy ±0.2°C (typical)
Excellent Stability at High Humidity
14 Bit Measurement Resolution
100 nA Sleep Mode Current

 

Connection

This was connected an Arduino Uno

 Arduino connection  Module connection
 3v3 3v3
 GND  GND
 SDA – A4  SDA
 SCL – A5  SCL

 

Code

You will need to download the following library and install it from  https://github.com/closedcube/ClosedCube_HDC1080_Arduino , this is the default example

 

 

#include <Wire.h>
#include "ClosedCube_HDC1080.h"
 
ClosedCube_HDC1080 hdc1080;
 
void setup()
{
Serial.begin(9600);
Serial.println("ClosedCube HDC1080 Arduino Test");
 
// Default settings:
// - Heater off
// - 14 bit Temperature and Humidity Measurement Resolutions
hdc1080.begin(0x40);
 
Serial.print("Manufacturer ID=0x");
Serial.println(hdc1080.readManufacturerId(), HEX); // 0x5449 ID of Texas Instruments
Serial.print("Device ID=0x");
Serial.println(hdc1080.readDeviceId(), HEX); // 0x1050 ID of the device
 
printSerialNumber();
 
}
 
void loop()
{
Serial.print("T=");
Serial.print(hdc1080.readTemperature());
Serial.print("C, RH=");
Serial.print(hdc1080.readHumidity());
Serial.println("%");
delay(3000);
}
 
void printSerialNumber() {
Serial.print("Device Serial Number=");
HDC1080_SerialNumber sernum = hdc1080.readSerialNumber();
char format[12];
sprintf(format, "%02X-%04X-%04X", sernum.serialFirst, sernum.serialMid, sernum.serialLast);
Serial.println(format);
}

 

 

 

Output

Open the serial monitor window and you should expect to see something like this

T=21.75C, RH=28.00%
T=21.60C, RH=28.21%
T=25.36C, RH=32.17%
T=27.87C, RH=43.27%
T=27.42C, RH=40.23%
T=26.90C, RH=32.15%
T=26.41C, RH=27.84%
T=26.00C, RH=25.77%
T=25.59C, RH=24.80%
T=25.15C, RH=24.43%
T=24.81C, RH=24.34%
T=24.45C, RH=24.47%
T=24.13C, RH=24.68%
T=23.82C, RH=24.89%
T=23.55C, RH=25.30%
T=23.26C, RH=25.72%
T=23.01C, RH=26.14%
T=22.71C, RH=26.64%
T=22.49C, RH=26.96%
T=22.28C, RH=27.27%

 

Links

1PC 2.7 V to 5.5 V HDC1080 high precision temperature and humidity sensor humidity temperature module

http://www.ti.com/lit/gpn/hdc1080

http://www.ti.com/lit/pdf/snau189

Share

Arduino and MPU6500 6-axis Motion Tracking device

The MPU-6500 is the company’s second-generation 6-axis Motion Tracking device for smartphones, tablets, wearable sensors, and other consumer markets.

The MPU-6500, delivered in a 3 mm x 3 mm x 0.9 mm QFN package, addresses the market requirements for high-performance applications such as pedestrian navigation, context-aware advertising, and other location-based services.

The device also supports the specifications for emerging wearable sensor applications, such as remote health monitoring, sports and fitness tracking, and other consumer applications.

Features

Digital-output of 6-axis MotionFusion data.
9-axis fused data from Motion Processing Library
Tri-Axis angular rate sensor (gyro) with a sensitivity up to 131 LSBs/dps and a full-scale range of ±250, ±500, ±1000, and ±2000dps
Tri-Axis accelerometer with a programmable full scale range of ±2g, ±4g, ±8g and ±16g
Reduced settling effects and sensor drift by elimination of board-level cross-axis alignment errors between accelerometers and gyroscopes
Digital Motion Processing™ (DMP™) engine offloads complex MotionFusion, sensor timing synchronization and gesture detection
MotionApps™ Platform support for Android, Linux, and Windows
Embedded algorithms for run-time bias and compass calibration
Digital-output temperature sensor
Digital input on FSYNC pin to support video Electronic Image Stabilization
Programmable interrupt supports gesture recognition, panning, zooming, scrolling, tap detection, and shake detection
VDD Supply voltage range of 1.71V–3.6V
Gyro operating current: 3.2mA (full power, gyro at all rates)
Gyro + Accel operating current: 3.4mA (full power, gyro at all rates, accel at 1kHz sample rate)
Accel low power mode operating currents: 18.65µA at 31.25Hz
Full Chip Idle Mode Supply Current: 6µA
400kHz Fast Mode I²C or up to 20MHz SPI serial host interfaces
10,000g shock tolerant

 

Layout

 

arduino and mpu-6500

arduino and mpu-6500

 

Code

I found a library here that seemed to work ok – http://www.uctronics.com/download/U3635_MPU6500.zip

 

// Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation
// is used in I2Cdev.h
#include "Wire.h"
 
// I2Cdev and MPU6050 must be installed as libraries, or else the .cpp/.h files
// for both classes must be in the include path of your project
#include "I2Cdev.h"
#include "MPU6050.h"
 
// class default I2C address is 0x68
// specific I2C addresses may be passed as a parameter here
// AD0 low = 0x68 (default for InvenSense evaluation board)
// AD0 high = 0x69
MPU6050 accelgyro;
 
int16_t ax, ay, az;
int16_t gx, gy, gz;
 
#define LED_PIN 13
bool blinkState = false;
 
void setup() {
// join I2C bus (I2Cdev library doesn't do this automatically)
Wire.begin();
 
// initialize serial communication
// (38400 chosen because it works as well at 8MHz as it does at 16MHz, but
// it's really up to you depending on your project)
Serial.begin(38400);
 
// initialize device
Serial.println("Initializing I2C devices...");
accelgyro.initialize();
 
// verify connection
Serial.println("Testing device connections...");
Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed");
 
// configure Arduino LED for
pinMode(LED_PIN, OUTPUT);
}
 
void loop() {
// read raw accel/gyro measurements from device
accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
 
// these methods (and a few others) are also available
//accelgyro.getAcceleration(&ax, &ay, &az);
//accelgyro.getRotation(&gx, &gy, &gz);
 
// display tab-separated accel/gyro x/y/z values
Serial.print("a/g:\t");
Serial.print(ax); Serial.print("\t");
Serial.print(ay); Serial.print("\t");
Serial.print(az); Serial.print("\t");
Serial.print(gx); Serial.print("\t");
Serial.print(gy); Serial.print("\t");
Serial.println(gz);
 
// blink LED to indicate activity
blinkState = !blinkState;
digitalWrite(LED_PIN, blinkState);
}

 

Output

Open the serial monitor

a/g: -280 -10732 -7336 32767 18392 -32768
a/g: 1620 -9008 -5564 32767 16477 -32768
a/g: 4368 -10656 -4060 32767 15867 -32768
a/g: 7724 -9952 -832 32767 14362 -32768
a/g: 6512 -6872 -340 32767 19106 -32768
a/g: 13252 -12072 3184 32767 20260 -32768
a/g: 15236 -12164 4784 32767 16474 -32768
a/g: 13152 -12644 2924 32767 10330 -32768
a/g: 16376 -11592 4708 31548 6686 -32768
a/g: 15676 -10160 4612 28194 3577 -32768
a/g: 15320 -10376 4480 25826 63 -32768
a/g: 17024 -9380 5472 25643 -483 -32768
a/g: 12064 -8728 4524 25102 -2927 -32768
a/g: 13240 -7600 5172 21817 -4007 -32768

 

Link

https://www.invensense.com/wp-content/uploads/2015/02/MPU-6500-Datasheet2.pdf

GY-6500 MPU-6500 6DOF six-axis accelerometer 6-axis attitude gyro sensor module SPI Interface MPU6500

Share

Arduino and LM75 temperature sensor example

The LM75 temperature sensor includes a delta-sigma analog-to-digital converter, and a digital overtemperature detector. The host can query the LM75 through its I²C interface to read temperature at any time. The open-drain overtemperature output (OS) sinks current when the programmable temperature limit is exceeded.

The OS output operates in either of two modes, comparator or interrupt. The host controls the temperature at which the alarm is asserted (TOS) and the hysteresis temperature below which the alarm condition is not valid (THYST). Also, the LM75’s TOS and THYST registers can be read by the host.

The address of the LM75 is set with three pins to allow multiple devices to work on the same bus. Power-up is in comparator mode, with defaults of TOS = +80°C and THYST = +75°C. The 3.0V to 5.5V supply voltage range, low supply current, and I²C interface make the LM75 ideal for many applications in thermal management and protection.

Key Features

SO (SOP) and µMAX® (µSOP) Packages
I²C Bus Interface
Separate Open-Drain OS Output Operates as Interrupt or Comparator/Thermostat Input
Register Readback Capability
Power-Up Defaults Permit Stand-Alone Operation as a Thermostat
3.0V to 5.5V Supply Voltage
Low Operating Supply Current 250µA (typ), 1mA (max)
4µA (typ) Shutdown Mode Minimizes Power Consumption
Up to Eight LM75s Can Be Connected to a Single Bus

 

Layout

I2C device you can power it from 3.3 or 5v

 

 

Code

I used this library – https://github.com/jlz3008/lm75

 

#define VERSION "1.1"
 
#include <inttypes.h>
#include <Wire.h>
 
#include <lm75.h>
 
TempI2C_LM75 termo = TempI2C_LM75(0x48,TempI2C_LM75::nine_bits);
 
 
void setup()
{
Serial.begin(9600);
Serial.println("Start");
Serial.print("Actual temp ");
Serial.print(termo.getTemp());
Serial.println(" oC");
delay(2000);
}
 
void loop()
{
Serial.print(termo.getTemp());
Serial.println(" oC");
delay(5000);
}

 

 

Links

LM75 temperature sensor high speed I2C interface high precision development board module

Share

Arduino Uno and BMP280 sensor example

BMP280 is an absolute barometric pressure sensor especially designed for mobile applications. The sensor module is housed in an extremely compact package. Its small dimensions and its low power consumption allow for the implementation in battery powered devices such as mobile phones, GPS modules or watches.

As its predecessor BMP180, BMP280 is based on Bosch’s proven Piezo-resistive pressure sensor technology featuring high accuracy and linearity as well as long term stability and high EMC robustness. Numerous device operation options offer highest flexibility to optimize the device regarding power consumption, resolution and filter performance. A tested set of default settings for example use case is provided to the developer in order to make design-in as easy as possible.

Applications

– Enhancement of GPS navigation (e.g. time-tofirst-fix improvement, dead-reckoning, slope detection)

– Indoor navigation (floor detection, elevator detection)

– Outdoor navigation, leisure and sports applications

– Weather forecast

– Health care applications (e.g. spirometry)

– Vertical velocity indication (e.g. rise/sink speed)

Parameter Technical data
Operation range (full accuracy) Pressure: 300…1100 hPa
Temperature: -40…85°C
Absolute accuracy
(Temp. @ 0…+65°C)
~ ±1 hPa
Relative accuracy
p = 700…900hPa
(Temp. @ +25…+40°C)
± 0.12 hPa (typical)
equivalent to ±1 m
Average current consumption (1 Hz data refresh rate) 2.74 μA, typical
(ultra-low power mode)
Average current consumption in sleep mode 0.1 μA
Average measurement time 5.5 msec
(ultra-low power preset)
Supply voltage VDDIO 1.2 … 3.6 V
Supply voltage VDD 1.71 … 3.6 V
Resolution of data Pressure: 0.01 hPa ( < 10 cm)
Temperature: 0.01° C
Temperature coefficient offset
(+25°…+40°C @900hPa)
± 0.12 hPa (typical)
equivalent to ±1 m
Interface I²C and SPI

 

Layout

This is a layout diagram using an adafruit part, my module had clearly marked SDA and SCL connections

In this example we will connect to an Arduino

arduino and bmp280

arduino and bmp280

 

Code

This example requires https://github.com/adafruit/Adafruit_BMP280_Library and https://github.com/adafruit/Adafruit_Sensor

 

/***************************************************************************
This is a library for the BMP280 humidity, temperature & pressure sensor
 
Designed specifically to work with the Adafruit BMEP280 Breakout
----> http://www.adafruit.com/products/2651
 
These sensors use I2C or SPI to communicate, 2 or 4 pins are required
to interface.
 
Adafruit invests time and resources providing this open source code,
please support Adafruit andopen-source hardware by purchasing products
from Adafruit!
 
Written by Limor Fried & Kevin Townsend for Adafruit Industries.
BSD license, all text above must be included in any redistribution
***************************************************************************/
 
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>
 
#define BMP_SCK 13
#define BMP_MISO 12
#define BMP_MOSI 11
#define BMP_CS 10
 
Adafruit_BMP280 bme; // I2C
//Adafruit_BMP280 bme(BMP_CS); // hardware SPI
//Adafruit_BMP280 bme(BMP_CS, BMP_MOSI, BMP_MISO, BMP_SCK);
 
void setup() {
Serial.begin(9600);
Serial.println(F("BMP280 test"));
 
if (!bme.begin()) {
Serial.println("Could not find a valid BMP280 sensor, check wiring!");
while (1);
}
}
 
void loop() {
Serial.print("Temperature = ");
Serial.print(bme.readTemperature());
Serial.println(" *C");
 
Serial.print("Pressure = ");
Serial.print(bme.readPressure());
Serial.println(" Pa");
 
Serial.print("Approx altitude = ");
Serial.print(bme.readAltitude(1013.25)); // this should be adjusted to your local forcase
Serial.println(" m");
 
Serial.println();
delay(2000);
}

 

 

 

Output

Temperature = 27.65 *C
Pressure = 100592.44 Pa
Approx altitude = 61.17 m

Temperature = 28.72 *C
Pressure = 100589.25 Pa
Approx altitude = 61.44 m

Temperature = 29.31 *C
Pressure = 100590.25 Pa
Approx altitude = 61.35 m

Temperature = 29.70 *C
Pressure = 100588.21 Pa
Approx altitude = 61.53 m

Temperature = 30.01 *C
Pressure = 100581.49 Pa
Approx altitude = 62.09 m

Temperature = 28.95 *C
Pressure = 100601.21 Pa
Approx altitude = 60.44 m

 

Link

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

1 piece I2C/SPI BMP280 3.3 Digital Barometric Pressure Altitude Sensor Module High Precision Atmospheric Module for Arduino

Share