Pressure and temperature measurement with GY-68

  • avatar
  • 576 Views
  • 6 mins read

The GY-68 module, also known as the BMP180 module, is a popular sensor module used for measuring atmospheric pressure, temperature, and altitude. It features a highly precise digital barometric pressure sensor that can be easily integrated with an Arduino board. In this tutorial, we will guide you through the process of connecting the GY-68 module to an Arduino, enabling you to gather accurate environmental data for your projects. So, let's get started!

Components

arduino-nano

1x Arduino Nano (or another Arduino module)

Buy now

mini-breadboard

1x Mini-breadboard

Buy now

gy68

1x GY-68 module

Buy now

dupont

Dupont wires

Buy now

github

BMP180 official library

Download here

Wiring schema

The connection to the controller is established using the I2C (Inter-Integrated Circuit) interface, which is a widely used serial communication protocol. The I2C interface consists of two lines: SDA (Serial Data Line) and SCL (Serial Clock Line). In the case of the Arduino Nano, the SDA (Serial Data Line) and SCL (Serial Clock Line) pins, which correspond to the I2C interface, are designated as A4 and A5, respectively.

Arduino Nano wiring with GY-68 module

To establish the connection, the controller acts as the master device, while the connected device operates as the slave. The master device initiates communication by sending control signals on the SDA and SCL lines. The SCL line provides the clock signal that synchronizes the data transfer. Data transfer in I2C communication can occur in both directions, allowing for bi-directional communication between the controller and the connected device.

Install Adafruit library for BMP180

To interact with the BMP180 sensor, we will use the official Adafruit library, which is also used for BMP085 module. This library, provides an interface that facilitates communication with the module, saving you significant time and providing a reliable and extensively tested code base. It can be downloaded from our official repository.

To import a library, open the Arduino IDE, go to Sketch > Include Library > Add .ZIP Library and select the library file downloaded from our GitHub repository.

Arduino IDE library import

Then you can simply use include statement:

#include "Adafruit_BMP085.h"

It will include the library with predefined functions to interact with the module.

Arduino code

Using the library makes the code much easier to understand.

#include "Wire.h"
#include "Adafruit_BMP085.h" // Adafruit BMP085/BMP180 library

Adafruit_BMP085 bmp;

void setup()
{
Serial.begin(115200);

if (!bmp.begin()) {
Serial.println ( "Sensor BMP180 not found, check the connections!" );

while (true);
}
}

void loop()
{
Serial.print("Temperature = ");
Serial.print(bmp.readTemperature());
Serial.print("\\xC2\\xB0"); //Print degree symbol
Serial.print("C");
Serial.println("");

Serial.print("Pressure = ");
Serial.print(bmp.readPressure());
Serial.println(" Pa");

// Calculate altitude assuming 'standard' barometric
// pressure of 1013.25 millibar = 101325 Pascal
Serial.print("Altitude = ");
Serial.print(bmp.readAltitude());
Serial.println(" meters");

Serial.print("Pressure at sealevel (calculated) = ");
Serial.print(bmp.readSealevelPressure());
Serial.println(" Pa");

// you can get a more precise measurement of altitude
// if you know the current sea level pressure which will
// vary with weather and such. If it is 1015 millibars
// that is equal to 101500 Pascals.
Serial.print("Real altitude = ");
Serial.print(bmp.readAltitude(101500));
Serial.println(" meters");

Serial.println();
delay(2000); // wait two seconds
}

Testing

The program is configured to produce output data at regular intervals of 2 seconds.

Testing GY-68 serial monitor output

The serial monitor will display similar output that reflects your location and environmental conditions.

Conclusion

In this tutorial, we have learned how to connect the GY-68 module to an Arduino board. By following the steps outlined above, you can now start gathering accurate atmospheric pressure, temperature, and altitude data for your projects. Have fun experimenting with your GY-68 module and exploring its capabilities!

Credits

Official GitHub: https://github.com/hibit-dev/gy68

Official Adafruit GitHub: https://github.com/adafruit/Adafruit-BMP085-Library

 Join Our Monthly Newsletter

Get the latest news and popular articles to your inbox every month

We never send SPAM nor unsolicited emails

0 Comments

Leave a Reply

Your email address will not be published.

Replying to the message: View original

Hey visitor! Unlock access to featured articles, remove ads and much more - it's free.