Brittany Bull
Published © MIT

QNE Altitude Meter

Simplest portable altitude meter you could ever make.

BeginnerFull instructions provided5 minutes626
QNE Altitude Meter

Things used in this project

Hardware components

SW01
XinaBox SW01
×1
XinaBox CC01
×1
OD01
XinaBox OD01
×1
IP01
XinaBox IP01
×1
XC10
XinaBox XC10
×1
MD01
XinaBox MD01
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

QNE_Altitude_Meter.ino

Arduino
Copy and paste this code into the Arduino IDE software, then insert the pressure value you Googled for your region where mentioned. Compile then upload to the connected xCHIPs via the IP01. This code will display QNE and Altitude readings on the OLED screen of the OD01
#include <xCore.h>  //add core library
#include <xSW01.h>  //add weather sensor library
#include <xOD01.h>  //add OLED screen library


xSW01 SW01;

const int DelayTime = 500; //Defining set delay time that could be used elsewhere in the code

//Create a variable to store the data read from SW01
float altitude;
float QNE;

void setup() {

  //Initialise variable to zero
  altitude = 0;
  QNE = 0;

  //Start I2C Communication
  Wire.begin();
  
  //Start OLED screen
  OLED.begin();

  //Start I2C communication
  Wire.begin();

  pinMode(CC01_RED, OUTPUT);

  //Start SW01 Sensor
  if (!SW01.begin()) {
    OD01.println("SW01 Sensor not found");
    OD01.println("Check your connector");
    while (1) {
      digitalWrite(CC01_RED, OUTPUT);
    }
  }

  //String intro for project
  OD01.println("Altitude Experiment");
  OD01.println("____________________________");

  delay(5000);

  //Delay for sensor to normalise
  delay(3000);

  //Send command to clear screen
  OD01.clear();

  delay (DelayTime);

}

void loop() {

  //Read and calculate data from SW01
  SW01.poll();

  //Request to get QNE data then store in the variable
  QNE = SW01.getQNE();

  //Request to get Altitude data then input the variable in Pascals(Google value of pressure in your area)
  altitude = SW01.getAltitude(100700);


  //Display recorded data over the Serial Monitor

  OD01.print("Altitude:");
  OD01.print(altitude);
  OD01.println("m ");

  OD01.print("QNE:");
  OD01.print(QNE);
  OD01.println("m");

  delay(5000);

}

Credits

Brittany Bull

Brittany Bull

13 projects • 8 followers
A student exploring the world of coding and IoT from a beginners' perspective

Comments