GY-21P Module Features
The GY-21P module consists of two sensors, BMP280 and SI7021, which include pressure, temperature and humidity sensors. The communication protocol of this module is I2C.
This module is capable of measuring air pressure from 30,000Pa to 110,000Pa, measuring humidity from 0 to 100%, measuring altitude from 0 to 30,000 feet and measuring temperature from -40 to +85 degrees Celsius.
You can download the datasheet of this module here.
BMP280 Sensor Datasheet
1 file(s) 1.42 MB
SI7021 Sensor Datasheet
1 file(s) 1.56 MB
GY-21P Module Pinout
This sensor has 4 pins:
- VIN: Module power supply – 3.3 V
- GND: Ground
- SLC: I2C Clock
- SDA: I2C data
You can see pinout of this module in the image below.
Required Materials
Hardware Components
Software Apps
Interfacing GY-21P Module with Arduino
Step 1: Circuit
The following circuit shows how you should connect Arduino to GY-21P module. Connect wires accordingly.
Step 2: Code
Install the following library on Arduino.
Tip
If you need more help with installing a library on Arduino, read this tutorial: How to Install an Arduino Library
Upload the following code to your Arduino
/*
on Sep 21, 2020
by MohammedDamirchi
Home
*/
#include <Adafruit_Sensor.h>
#include "Adafruit_Si7021.h"
#include <Adafruit_BMP280.h>
Adafruit_BMP280 bme; // I2C
Adafruit_Si7021 sensor = Adafruit_Si7021();
void setup() {
Serial.begin(9600);
bme.begin();
sensor.begin();
}
void loop() {
Serial.print("Temperature(bme): ");
Serial.print(bme.readTemperature());
Serial.print(" *C\t");
Serial.print("Pressure: ");
Serial.print(bme.readPressure()*0.00750062);
Serial.print(" mmHg\t");
Serial.print("Approx altitude: ");
Serial.print(bme.readAltitude(1013.25)); // this should be adjusted to your local forcase
Serial.print(" m\t");
Serial.print("Humidity: ");
Serial.print(sensor.readHumidity(), 2);
Serial.print("\tTemperature(Si7021): ");
Serial.println(sensor.readTemperature(), 2);
delay(50);
}
After running the code, you will see the following image in the serial output.