Categories

Follow

SHT20 temperature and humidity sensor and ESP8266

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.

 

Parts List

 

Amount Part Type
1 Temperature and humidity detection sensor module SHT20
1 Wemos D1 mini V2

 

Schematics/Layout

 

 

Code

Again we use a 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

Time:105462 Temperature:21.1C Humidity:55.6%
Time:106565 Temperature:21.1C Humidity:55.6%
Time:107669 Temperature:22.0C Humidity:55.7%
Time:108772 Temperature:24.8C Humidity:58.0%
Time:109875 Temperature:26.3C Humidity:61.1%
Time:110978 Temperature:27.3C Humidity:63.1%
Time:112081 Temperature:28.0C Humidity:64.4%

 

Links

Sensirion_Humidity_Sensors_SHT20_Datasheet.pdf

 

ADS1115 analog-to-digital converter and ESP8266

The ADS1115 device is a precision, low-power, 16-bit, I2C-compatible, analog-to-digital converters (ADCs) offered in an ultra-small, leadless, X2QFN-10 package, and a VSSOP-10 package. The ADS1115 device incorporates a low-drift voltage reference and an oscillator. The ADS1115 also incorporate a programmable gain amplifier and a digital comparator. These features, along with a wide operating supply range, make the ADS1115 well suited for power- and space-constrained, sensor measurement applications.

The ADS1115 perform conversions at data rates up to 860 samples per second (SPS). The PGA offers input ranges from ±256 mV to ±6.144 V, allowing precise large- and small-signal measurements. The ADS1115 features an input multiplexer  that allows two differential or four single-ended input measurements. Use the digital comparator in the ADS1115 for under- and overvoltage detection.

The ADS1115 operates in either continuous-conversion mode or single-shot mode. The devices are automatically powered down after one conversion in single-shot mode; therefore, power consumption is significantly reduced during idle periods.

Features

Wide Supply Range: 2.0 V to 5.5 V
Low Current Consumption: 150 µA
(Continuous-Conversion Mode)
Programmable Data Rate: 8 SPS to 860 SPS
Single-Cycle Settling
Internal Low-Drift Voltage Reference
Internal Oscillator
I2C Interface: Four Pin-Selectable Addresses
Four Single-Ended or Two Differential Inputs (ADS1115)
Programmable Comparator (ADS1114 and ADS1115)
Operating Temperature Range: –40°C to +125°C

Parts List

This module will cost less than $2

Amount Part Type
1 ADS1115
1 Wemos D1 mini V2

 

Schematics/Layout

 

In the layout below we just show basic connection between Wemos Mini and ADS1115 – you can add a pot, connect an LDR to one of the A0 – A3 inputs of the ADS1115

esp8266 and ads1115

esp8266 and ads1115

 

Code

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

 

 

#include <Wire.h>
#include <Adafruit_ADS1015.h>
 
Adafruit_ADS1115 ads(0x48);
 
void setup(void)
{
Serial.begin(9600);
Serial.println("Hello!");
 
Serial.println("Getting single-ended readings from AIN0..3");
Serial.println("ADC Range: +/- 6.144V (1 bit = 3mV/ADS1015, 0.1875mV/ADS1115)");
 
ads.begin();
}
 
void loop(void)
{
int16_t adc0, adc1, adc2, adc3;
 
adc0 = ads.readADC_SingleEnded(0);
adc1 = ads.readADC_SingleEnded(1);
adc2 = ads.readADC_SingleEnded(2);
adc3 = ads.readADC_SingleEnded(3);
Serial.print("AIN0: ");
Serial.println(adc0);
Serial.print("AIN1: ");
Serial.println(adc1);
Serial.print("AIN2: ");
Serial.println(adc2);
Serial.print("AIN3: ");
Serial.println(adc3);
Serial.println(" ");
 
delay(1000);
}

 

 

Links

http://www.ti.com/lit/ds/symlink/ads1115.pdf

I2C ADS1115 16 Bit ADC 4 channel Module with Programmable Gain Amplifier 2.0V to 5.5V RPi

QRE1113 IR reflectance sensor and ESP8266 example

The QRE1113 features an easy-to-use analog output, which will vary depending on the amount of IR light reflected back to the sensor. The QRE1113 IR reflectance sensor is comprised of two parts – an IR emitting LED and an IR sensitive phototransistor.

When you apply power to the VCC and GND pins the IR LED inside the sensor will illuminate.

Because dark colors will bounce back less light, the sensor can be used to tell the difference between white and black areas and can be used in robots as a line follower

qre113

qre113

Schematic/Connection/Layout

 

Code

int QRE1113_Pin = A0; 
 
void setup()
{
Serial.begin(9600);
}
 
void loop()
{
int QRE_Value = analogRead(QRE1113_Pin);
Serial.println(QRE_Value);
delay(1000);
}

 

Output

Open the serial monitor, the lower example readings were when I put a white piece of paper near the sensor

889
871
76
85
75
76
871
890
81

 

Links

http://www.onsemi.com/pub/Collateral/QRE1113-D.PDF

QRE1113 Linear Sensor Breakout Board Infrared Reflective Sensor Module Digital Output 3.3V 5V For Line Following Robots

MAX30102 pulse and heart-rate monitor sensor and ESP8266

The MAX30102 is an integrated pulse oximetry and heart-rate monitor biosensor module. It includes internal LEDs, photodetectors, optical elements, and low-noise electronics with ambient light rejection. The MAX30102 provides a complete system solution to ease the design-in process for mobile and wearable devices.

The MAX30102 operates on a single 1.8V power supply and a separate 5.0V power supply for the internal LEDs. Communication is through a standard I2C-compatible interface. The module can be shut down through software with zero standby current, allowing the power rails to remain powered at all times.

Key Features

Heart-Rate Monitor and Pulse Oximeter Biosensor in LED Reflective Solution
Tiny 5.6mm x 3.3mm x 1.55mm 14-Pin Optical Module
Integrated Cover Glass for Optimal, Robust Performance
Ultra-Low Power Operation for Mobile Devices
Programmable Sample Rate and LED Current for Power Savings
Low-Power Heart-Rate Monitor (< 1mW)
Ultra-Low Shutdown Current (0.7µA, typ)
Fast Data Output Capability
High Sample Rates
Robust Motion Artifact Resilience
High SNR
-40°C to +85°C Operating Temperature Range

 

Parts List

This module will cost less than $2

Amount Part Type
1 MAX30102
1 D1 mini V2

 

Schematics/Layout

 

esp8266 and max30102

esp8266 and max30102

Code

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

 

 

#include <Wire.h>
#include "MAX30105.h"
 
#include "heartRate.h"
 
MAX30105 particleSensor;
 
const byte RATE_SIZE = 4; //Increase this for more averaging. 4 is good.
byte rates[RATE_SIZE]; //Array of heart rates
byte rateSpot = 0;
long lastBeat = 0; //Time at which the last beat occurred
 
float beatsPerMinute;
int beatAvg;
 
void setup()
{
Serial.begin(115200);
Serial.println("Initializing...");
 
// Initialize sensor
if (!particleSensor.begin(Wire, I2C_SPEED_FAST)) //Use default I2C port, 400kHz speed
{
Serial.println("MAX30105 was not found. Please check wiring/power. ");
while (1);
}
Serial.println("Place your index finger on the sensor with steady pressure.");
 
particleSensor.setup(); //Configure sensor with default settings
particleSensor.setPulseAmplitudeRed(0x0A); //Turn Red LED to low to indicate sensor is running
particleSensor.setPulseAmplitudeGreen(0); //Turn off Green LED
}
 
void loop()
{
long irValue = particleSensor.getIR();
 
if (checkForBeat(irValue) == true)
{
//We sensed a beat!
long delta = millis() - lastBeat;
lastBeat = millis();
 
beatsPerMinute = 60 / (delta / 1000.0);
 
if (beatsPerMinute < 255 && beatsPerMinute > 20)
{
rates[rateSpot++] = (byte)beatsPerMinute; //Store this reading in the array
rateSpot %= RATE_SIZE; //Wrap variable
 
//Take average of readings
beatAvg = 0;
for (byte x = 0 ; x < RATE_SIZE ; x++)
beatAvg += rates[x];
beatAvg /= RATE_SIZE;
}
}
 
Serial.print("IR=");
Serial.print(irValue);
Serial.print(", BPM=");
Serial.print(beatsPerMinute);
Serial.print(", Avg BPM=");
Serial.print(beatAvg);
 
if (irValue < 50000)
Serial.print(" No finger?");
 
Serial.println();
}

 

 

 

Output

Open the serial monitor – this is what I saw, it took a little bit of time for the readings to appear

IR=110798, BPM=93.46, Avg BPM=74
IR=110791, BPM=93.46, Avg BPM=74
IR=110879, BPM=93.46, Avg BPM=74
IR=110899, BPM=93.46, Avg BPM=74
IR=110969, BPM=93.46, Avg BPM=74
IR=111070, BPM=93.46, Avg BPM=74
IR=111021, BPM=93.46, Avg BPM=74
IR=110997, BPM=93.46, Avg BPM=74
IR=111116, BPM=93.46, Avg BPM=74

 

Links

https://datasheets.maximintegrated.com/en/ds/MAX30102.pdf

Low Power MAX30102 Heart Rate Oxygen Pulse Breakout for Arduino