Serial QNE Altitude

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

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Things Used in This Project

Hardware components

Software apps and online services

Step 2: Story

Introduction

I built this project using XinaBox xChips and Arduino IDE. It is a 5 min project, that allows you to read altitude data received from the xSW01 on the serial monitor. This project is an adaption of my previous Easy Peasy Temperature Monitor project. Using the xChips assembly is easy. The Arduino IDE software makes creating the code for the project simple.

If you're not sure what QNE is you should follow this link. The explanation given is short, sweet and useful.

Step 3: Downloading the Libraries

  • Go to Github.xinabox
  • Download xCore ZIP
  • Install it into Arduino IDE by going to "Sketch", "Include Library", then "Add .ZIP Library". As seen below.

Figure 1: Adding the ZIP files

  • Download xSW01 ZIP
  • Add the library the same way as you did for the xCore.

Step 4: Programming

  • Connect the IP01 and CC01 using an xBUS Connector. Make sure the xChips' names are orientated correctly.

Figure 2: Connected IP01 and CC01

  • Insert into an available USB port.
  • Google your local air pressure in pascals for the day.
  • Download or copy and paste the code from the "CODE" heading into your Arduino IDE. Enter the air pressure where indicated. Alternatively you could create your own code using the relevant principles to achieve the same objective.
  • To ensure there are no errors compile the code.
  • After successful compilation(no errors found) you may upload the code to your xChips. Ensure the switches are facing "A" and "DCE" respectively before uploading, if it is an IP01 with switches.

Step 5: Final Assembly

  • Once the upload is successful, remove the IP01 from the USB port. Attach the SW01 with another xBUS Connector to the CC01.

Figure 3: Connected IP01, CC01 and SW01

  • Insert the board back into the same USB port.
  • Open the serial monitor in the top, right-hand corner of the screen. It should look like the image below after a few moments.

  • You can now view altitude readings from the SW01 on the serial monitor

Step 6: 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);

}

Be the First to Share

    Recommendations

    • Instrument Contest

      Instrument Contest
    • Make it Glow Contest

      Make it Glow Contest
    • STEM Contest

      STEM Contest

    Discussions