Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Air pressure detection
- #include "Seeed_BMP280.h"
- #include <Wire.h>
- BMP280 bmp280;
- void setup() {
- Serial.begin(9600);
- if (!bmp280.init()) {
- Serial.println("Device not connected or broken!");
- }
- }
- void loop() {
- float pressure;
- //get and print temperatures
- Serial.print("Temp: ");
- Serial.print(bmp280.getTemperature());
- Serial.println("C"); // The unit for Celsius because original arduino don't support speical symbols
- //get and print atmospheric pressure data
- Serial.print("Pressure: ");
- Serial.print(pressure = bmp280.getPressure());
- Serial.println("Pa");
- //get and print altitude data
- Serial.print("Altitude: ");
- Serial.print(bmp280.calcAltitude(pressure));
- Serial.println("m");
- Serial.println("\n");//add a line between output of different times.
- delay(1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement