By continuing to use this site, you agree to our use of cookies. Find out more
Forum sponsored by:
Forum sponsored by CML

Simple arduino altimeter

All Topics | Latest Posts

Search for:  in Thread Title in  
dave windymiller24/05/2019 20:24:18
avatar
75 forum posts
100 photos

With the revision of restrictions around airports changed recently, our club, previously inside the FRZ now thankfully finds its self outside ! In theory we can now fly models greater than 7kg but we need to change the club rule. The limit of 400 ft is the sticking point for the club committee.

I decided to look for a simple altitude recording device and found this simple arduino project  Standalone-Arduino-Altimeter. Only three components & around 10 quid to build.

I decided to build one but decided the software need tweaking to suit. I wanted an altitude above launch. As it stood, it indicated pressure temperature and altitude with altitude min and altitude max. The altitude was dependent on both baro pressure and locality height. It could be possible to calibrate it but this would vary with weather. Also 2 decimal places was too much.

My software simply sets a zero altitude on power up/reset and a maximum in relation to this datum . Ive also set it to feet rather than meters!  The bmp280 chip is apparently good for around +/- 3ft 

20190524_195615.jpg

My device mounted in a small plastic box 50mm X 35mm and weighs less than 20g. The plastic screw is mounted above the arduino reset button to act as a button to reset the altimeter to zero before flight.

If anyones interested i could post my revised software!

 

Edited By dave windymiller on 24/05/2019 20:32:01

Anthony Scott 224/05/2019 20:30:51
71 forum posts
12 photos

Yes please.

dave windymiller24/05/2019 20:38:54
avatar
75 forum posts
100 photos

Here it is, not the best written code im sure but it works!

 

 #include "U8glib.h"
#include "BMP280.h"
#include "Wire.h"
#define P0 1013.25 
BMP280 bmp;

// OLED Type
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NO_ACK);

char sT[20];
char sP[9];
char sA[9];
char sA_MIN[9];
char sA_MAX[9];
char sA_DIFF[9];
char sA_NOW[9];

double A_MIN = 0;
double A_MAX = -1000;
double A_DIFF = 0;
double A_NOW = 0;
double cal = 5.0;
double count = 0;


void draw2( double A_DIFF, double A_NOW) {
  u8g.setFont(u8g_font_unifont);


  dtostrf(A_DIFF, 4, 0, sA_DIFF);
  dtostrf(A_NOW, 4, 0, sA_NOW);
  

  u8g.drawStr( 5, 10, "Alt NOW: " ) ;
  u8g.drawStr( 70, 10, sA_NOW);
  
  u8g.drawStr( 5, 40, "Max" ) ;
  u8g.drawStr( 5, 60, "Alt Ft:" ) ;
  u8g.drawStr( 70, 60, sA_DIFF) ;
}

void setup() {
 
  Serial.begin(9600);
  if (!bmp.begin()) {
    Serial.println("BMP init failed!" ) ;
    while (1);
  }
  else Serial.println("BMP init success!" ) ;

  bmp.setOversampling(4);

  u8g.setColorIndex(1);
  u8g.setFont(u8g_font_unifont);
}


void loop(void) {
  double T, P;
  
  char result = bmp.startMeasurment() ;

  if (result != 0) {
    delay(result);
    result = bmp.getTemperatureAndPressure(T, P);

    P = P + cal;
 
    if (result != 0) {
      double A = bmp.altitude(P, P0);
      A = A * 3.28084;

      if ( A > A_MAX) {
        A_MAX = A;
      }

      if ( count == 0 ) {
        A_MIN = A;
        count = count + 1 ;
        
      }
    A_DIFF = A_MAX - A_MIN;
    A_NOW = A - A_MIN;

      do {
        draw2( A_DIFF, A_NOW);
      } while ( u8g.nextPage() ) ;
      u8g.firstPage();
      delay(500);
      
    }
    else {
      Serial.println("Error. " ) ;
    }
  }
  else {
    Serial.println("Error. " ) ;
  }

  delay(100);

}

Edited By dave windymiller on 24/05/2019 21:01:20

Edited By dave windymiller on 24/05/2019 21:02:12

Anthony Scott 224/05/2019 21:16:48
71 forum posts
12 photos

Thanks.

All Topics | Latest Posts

Please login to post a reply.

Magazine Locator

Want the latest issue of RCM&E? Use our magazine locator link to find your nearest stockist!

Find RCM&E! 

Latest Forum Posts
Support Our Partners
electricwingman 2017
Motion RC
Revoc
Gliders Distribution
CML
Pepe Aircraft
Slec
Wings & Wheels 2019
Sarik
Advertise With Us
Does your club have a safety officer?
Q: Does your club have a safety officer, or is the emphasis on individual members to each be their own safety officer?

 Yes we have a SO
 No, it's down to everyone

Latest Reviews
Digital Back Issues

RCM&E Digital Back Issues

Contact us

Contact us