BMP280 - Measuring Vertical Velocity for Arduino Rocket?

I am making a two stage rocket with 2 F motors, and I think that I will be able to measure both velocity, altitude, temperature and pressure. with the BMP280 arduino module. I will upload this to an SD card, and retrieve it after the rocket lands. From what I understand you can measure approximate altitude with this module, so if I take the time between each of the readings, I will be able to do some math, and find the approximate velocity. I do not know how to do this, and I ran into this error code while working on the code.

Arduino: 1.8.13 (Mac OS X), Board: "Arduino Uno"


In file included from /Users/nbagley/Documents/Arduino/Rocket_code/Rocket_code.ino:3:0:
/Users/nbagley/Documents/Arduino/libraries/adafruit-Adafruit_BMP280_Library-2d94a81/Adafruit_BMP280.h:24:10: fatal error: Adafruit_Sensor.h: No such file or directory
 #include "Adafruit_Sensor.h"
          ^~~~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1
Error compiling for board Arduino Uno.

I am rather confused by this error code, but here is my full code below:

#include <SPI.h>
#include <SD.h>
#include <Adafruit_BMP280.h>
Adafruit_BMP280 bmp; // I2C Interface
File myFile;
File pressureFile;
File altitudeFile;
File velocityFile;
void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  Serial.print("Initializing SD card...");
  if (!SD.begin(10)) {
    Serial.println("initialization failed!");
    while (1);
    bmp.setSampling(Adafruit_BMP280::MODE_NORMAL,     /* Operating Mode. */
                    Adafruit_BMP280::SAMPLING_X2,     /* Temp. oversampling */
                    Adafruit_BMP280::SAMPLING_X16,    /* Pressure oversampling */
                    Adafruit_BMP280::FILTER_X16,      /* Filtering. */
                    Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */
  }
  Serial.println("initialization done.");
  myFile = SD.open("tempValue.txt", FILE_WRITE);
  // if the file opened okay, write to it:
  if (myFile) {
    myFile.println("The Data is Shown Below:)");
  }
  pressureFile = SD.open("pressureValue.txt", FILE_WRITE);
  // if the file opened okay, write to it:
  if (pressureFile) {
    pressureFile.println("The Data is Shown Below:)");
  }
  altitudeFile = SD.open("altitudeValue.txt", FILE_WRITE);
  // if the file opened okay, write to it:
  if (altitudeFile) {
    altitudeaFile.println("The Data is Shown Below:)");
  }
  velocityFile = SD.open("velocityValue.txt", FILE_WRITE);
  // if the file opened okay, write to it:
  if (velocityFile) {
    velocityFile.println("The Data is Shown Below:)");
  }
}
void loop() {
  myFile.print(F("Temperature = "));
  myFile.print(bmp.readTemperature());
  myFile.println(" *C");
  pressureFile.print(F("Pressure = "));
  pressureFile.print(bmp.readPressure() / 100); //displaying the Pressure in hPa, you can change the unit
  pressureFile.println(" hPa");
  altitudeFile.print("Approx altitude = ");
  altitudeFile.print(bmp.readAltitude(1028)); //The "1019.66" is the pressure(hPa) at sea level in day in your region
  altitudeFile.println(" m");                    //If you don't know it, modify it until you get your current altitude
  velocityFile.print("Approx Velocity = ");
  velocityFile.print( //This is where I do not know what to do

}

I hope you guys can help, thanks for your time!

The AdaFruitySensorThigy should have installed with an AdaFruity library installation but wait!

You can install it yourself!! Woot!

See adafruty sensor thingy library

Thanks! Downloading this totally fixed the error code. Thanks for your help!

Does anyone have any ideas about how to turn the altitude values into velocity values? Thanks!

Velocity is equivalent to a specification of an object's speed and direction of motion .

Altitude will give you the distance traveled from the ground. If a timer is started at launch, use the time of the reading to get rate of travel.

Remember in school how Joe walked 1 hour at 3 miles an hour how far did Joe do the thing?

Just like in school you'd use those 2 numbers to find the 3rd number.

I understand that, but I am fairly new at arduino, and I do not know how to set up a timer with arduino code. Could you please help me with that?

have you ever looked at the locked postings at the top of each forum's threads?

there are things like using millis() for timing and other useful stuff of common questions like how to do the timing thing.

As a note a timer has already been setup for you.

Your problem is that the sensor will pick up the atmospheric pressure plus a component of dynamic pressure dependant upon the position of the sensor . That affects accuracy .

I would guess there are some equations on google for pressure change with altitude. Rate of change of altitude gives you vertical velocity

There is indeed a standard atmospheric equation for pressure-with-altitude, which is what altimeters use.

It may be hard with a rocket to measure atmospheric pressure accurately if the speed is high - checkout

For short flights you can integrate the output of an accelerometer to obtain velocity.

Ok, thanks, I think I have figured out how to do it. Thanks!

I'd simply log raw readings from the sensor, as frequently as possible, and save them with a timestamp.

Leave the smarts to the ground station.

You won't be able to accurately measure the atmospheric pressure from a fast moving object, as the Bernoulli Effect severely distorts the readings.

It is possible to calibrate and compensate for the effect, but that depends critically on the actual design of the rocket and the sensor placement. The model would have to be built, then tested and calibrated in a wind tunnel.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.