Pressure and temperature measurement with GY-68
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
1x Arduino Nano (or another Arduino module) $3.18 | |
1x Mini-breadboard
| |
1x GY-68 module $1.39 | |
Dupont wires $1.61 | |
BMP180 official library |
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.
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.
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.
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
0 Comments