GY-21P module example connected to an Arduino Due

The GY-21P is a module that combines a BMP280 sensor and an SI7021 sensor. The on-board BMP280+SI7021 sensor measures atmospheric pressure from 30kPa to 110kPa as well as relative humidity and temperature.

A quick look at both sensors

BMP280
Pressure range: 300-1100 hPa (9000 meters above sea level at -500m)
Relative accuracy (at 950 – 1050 hPa at 25 ° C): ± 0.12 hPa, equiv. to ± 1 m
Absolute accuracy (at (950 – 1050 hPa, 0 – +40 ° C): ± 0.12 hPa, equiv. To ± 1 m
Mains voltage: 1.8V – 3.6V
Power consumption: 2.7µA at 1Hz readout rate
Temperature range: -40 to + 85 ° C

SI7021
HVAC/R
Thermostats/humidistats
Respiratory therapy
White goods
Indoor weather stations
Micro-environments/data centers
Automotive climate control and defogging
Asset and goods tracking
Mobile phones and tablets
Size: 1.3*1cm/0.51*0.39″

Features:

Operation Voltage: 3.3V
I2C & SPI Communications Interface
Temp Range: -40C to 85C
Humidity Range: 0 – 100% RH, =-3% from 20-80%
Pressure Range: 30,000Pa to 110,000Pa, relative accuracy of 12Pa, absolute accuracy of 100Pa
Altitude Range: 0 to 30,000 ft (9.2 km), relative accuracy of 3.3 ft (1 m) at sea level, 6.6 (2 m) at 30,000 ft.

Parts List

name Link
Arduino Due Black Due R3 Board DUE-CH340 ATSAM3X8E ARM Main Control Board with 50cm USB Cable CH340G for arduino
GY-21p module Atmospheric Humidity Temperature Sensor Breakout Barometric Pressure BMP280 SI7021 for Arduino GY-21P
connecting wire Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire

Connection

Arduino Due GY21-p module
3v3 Vin
Gnd Gnd
20 – SDA SDA
21 – SCL SCL

Code

You need to use a variety of Adafruit libraries, i basically took the default examples and made the following out of them

https://github.com/adafruit/Adafruit_Sensor

https://github.com/adafruit/Adafruit_BMP280_Library

https://github.com/adafruit/Adafruit_Si7021

 

 

[codesyntax lang=”cpp”]

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>
#include "Adafruit_Si7021.h"

Adafruit_BMP280 bme; // I2C
Adafruit_Si7021 sensor = Adafruit_Si7021();

void setup() 
{
Serial.begin(9600);
Serial.println("BMP280 and SI7021 (GY-21p) test");

if (!bme.begin()) 
{ 
Serial.println("Could not find a valid BMP280 sensor, check wiring!");
while (1);
}

if (!sensor.begin()) 
{
Serial.println("Did not find Si7021 sensor!");
while (true);
}
}

void loop() 
{
Serial.println("BMP280 results");
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();

Serial.println("SI7021 results");
Serial.print("Humidity: "); 
Serial.println(sensor.readHumidity(), 2);
Serial.print("Temperature: "); 
Serial.println(sensor.readTemperature(), 2);
Serial.println();
delay(2000);
}

[/codesyntax]

 

Output

OPen the serial monitor

BMP280 results
Temperature = 27.26 *C
Pressure = 99042.63 Pa
Approx altitude = 191.78 m

SI7021 results
Humidity: 31.04
Temperature: 27.30

BMP280 results
Temperature = 28.43 *C
Pressure = 99044.82 Pa
Approx altitude = 191.60 m

SI7021 results
Humidity: 32.59
Temperature: 28.56

BMP280 results
Temperature = 28.17 *C
Pressure = 99037.41 Pa
Approx altitude = 192.22 m

SI7021 results
Humidity: 32.88
Temperature: 28.46

You can see the temperature output is close between the sensors

 

Links

Atmospheric Humidity Temperature Sensor Breakout Barometric Pressure BMP280 SI7021 for Arduino

Share
This div height required for enabling the sticky sidebar
Ad Clicks : Ad Views : Ad Clicks : Ad Views :