Brittany Bull
Published © MIT

Serial QNE Altitude

Quick and easy altitude readings in the serial monitor while using XinaBox xCHIPS and Arduino IDE.

EasyFull instructions provided5 minutes76
Serial QNE Altitude

Things used in this project

Hardware components

IP01
XinaBox IP01
×1
SW01
XinaBox SW01
×1
XC10
XinaBox XC10
×1
XinaBox CC01
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

QNE_AltitudeSM.ino

Arduino
Arduino code to display altitude readings on the serial monitor while using the xCHIPs
#include <xCore.h>  //add core library
#include <xSW01.h>  //add weather sensor 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 Serial Monitor
  Serial.begin(115200);

  //Start I2C communication
  Wire.begin();

  pinMode(CC01_RED, OUTPUT);

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

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

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

}

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(101300);


  //Display recorded data over the Serial Monitor

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

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

  delay(5000);

}

Credits

Brittany Bull

Brittany Bull

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

Comments