Home Built Arduino Altimeter

The Rocketry Forum

Help Support The Rocketry Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

Orion14ed

Well-Known Member
Joined
Jul 2, 2012
Messages
373
Reaction score
4
Hey Rocketry Forum!

A little backstory- my freshman engineering class had me design, build and program a solar powered automatic driving car. I learned plenty about the Arduino system and my first thought was hey, I should try and build an altimeter for my rockets. So once summer came around, I decided to give it a shot- here is my progress and results as of now.

Design/ Parts-
So when I decided to do this all I had at the time was an Redboard from Sparkfun. It is essentially an Arduino Uno and despite being a little large, I believed it should be a fine starting point. I could have gone with a smaller Arduino Micro, but I was cheap and just went with what I had.

With the processor picked, I needed to pick the components that would actually record data. I eventually settled on a Adafruit MPL3115A2 - I2C Barometric Pressure/Altitude/Temperature Sensor, and
Adafruit Triple-Axis Accelerometer - 2/4/8g @ 14-bit - MMA8451. I needed somewhere to record the data so I also purchased a Adafruit MicroSD card breakout board+ [ADA254].

I also used various jumper wires to build the board and connect everything, as well as a solder-able breadboard to host the final version of the altimeter.

Here is a list of my parts:
Adafruit MPL3115A2 - I2C Barometric Pressure/Altitude/Temperature Sensor
Adafruit Triple-Axis Accelerometer - 2/4/8g @ 14-bit - MMA8451
Adafruit MicroSD card breakout board+ [ADA254]
Breadboard
Redboard Arduino

Construction
So since I was not at school working on this project, all I had access to was a subpar too large soldering iron. It made putting everything together a pain and would never really be at the right temperature.I ended up having to buy a second SD breakout since the first was soldering incorrectly.

I decided not to hard core wire anything since I wanted to be able to probe all the connections easily, and I was not that confident in my soldering ability. This left the components looking a little silly and unprofessional, but no one is going to see them in the AV bay of your rocket. Cleaning each through wire up will be a future task, but this is what it looked like when finished but not yet mounted.

Breadboard and Arduino with the altimeter and gyro connected:
messybreakout.JPG
As you can see, the wires are the standard wires used with most breadboard-able projects, nothing special or professional.

Mounting-
The intial plan was to mount this inside of my Formula 75 e-bay, but that never came to happening. Instead, I just needed to be able to fit it inside of my 4" Patriot.

I cut one long piece of wood to attach all the components to. The SD breakout sat at the top, followed by the arduino (The SD cords needed to be the shortest), next was the gyro and altimeter, then the breadboard with the connections.
tophalf.JPG bottomhalf.JPG
full.JPG

Underneath the board is a cutout for a USB battery pack. The pack runs at a voltage lower than the Arduino rating, but after some testing I found it to work just fine. (I will edit the thread when I get a chance to look at it).


As you can see, its messy. I work a lot and so this all kinda came together at the last second and had no real time to be cleaned up. I had a launch on the 14th being the only one I could make all summer, so it was this or nothing.

Coding-
So, these components came with their own libraries which made the coding pretty easy. I will attach the code and you can go through it if you would like, but there are a few things to note.

-I am sure there are more effecient ways to do what I wanted to do, since the altimeter and the gyro use i2c and the sd used SPI. I just stuck with the libraries and whatever that meant in terms of speed and storage.
-To ensure that the data written would be saved, the program automatically close and reopens the file every 100 cycles- this obviously could be an issue if that 100th cycle fell during the flight, but I ran into storage issues so I never had a chance to work around this.
-The code essentially ran a startup and then a loop that called two functions - one to get gyro data, and one to get altimeter data.
-These functions never did anything but write data, which meant the system was never aware if it was in flight or anything like that. This meant once it was turned on, it would just record data until it was turned off- no launch detection or anything like that in this first version.

I will come back and edit this later with more discussion points, but in general this is what a snippet of the data returned from the code would look like:

NEW DATA SET
Loop start: 68
X: -1022 Y: 86 Z: 22
X: -9.77 Y: 0.63 Z: 0.32 m/s^2
Altitude(ft):
838.87
Altitude(ft):
838.87
Altitude(ft):
838.87
Altitude(ft):
838.87
Altitude(ft):
838.87
Altitude(ft):
838.87
Altitude(ft):
838.87
Altitude(ft):
838.87
Altitude(ft):
838.87
Altitude(ft):
838.87
X: -954 Y: 67 Z: -2
X: -9.77 Y: 0.18 Z: -0.31 m/s^2

The data for each loop contained the start time in ms, an initial gyro reading, 10 altitude measurements, and then a final gyro reading. This loop ran in about .5 - .8 seconds, essentially giving me 1 -2 loops per second, less if the file was closed on the 100th loop of the program.

Results:
This system flew for the first time on the 14th, on this flight.


The rocket flew on a H100 which was simed to reach around 855 feet. This sim however did not account for the added mass of the electronics, or the massive gopro I had hanging off the side.

However, the data I got back indicated that the rocket flew to around 558 feet.
The base altitude was around 800ft, and the peak altitude recorded was 1358ft.
altitudedata.PNG
The gyros also gave me some good data, which indicate a peak acceleration around 5G's
xaccel.PNG
Note: the negative X direction in this case indicated a positive acceleration.

And here is the acceleration data from all 3 of the gyros:
Blue is X, orange is Y, and grey is Z.
3axisgyro.PNG

I wanted to see how accurate the 550 feet apogee could be, so I looked at the video: the rocket is under the parachute for around 17 seconds. If I take the derivative of the position curve for the time under the canopy I end up with this:
parachutecurve.PNG
The rocket fell at around 26 ft/s. If I take this and plug multiply by 17 seconds I end up with 442 feet. From the video you can also see the rocket reaches apogee, and falls for some time as well. This is picked up in the altitude curve as well, and is meassured to have dropped around 100 feet in this time, meaning, the rocket likely did fly to around 550 feet feet instead of the projected 855.

I was weary when I first got this result, but since the video, the altitude data, and the gryro data all look to confirm each other, I think my system worked.

In hind sight, I should not have flown the GoPro on the test flight so I could get better data and compare it to the sim.

Discussion-
Somethings that I have noticed that seem a little off: There is no acceleration in the X axis after the motor burn out, which does not make sense as there should be a positive acceleration (against the motion of the rocket).
(I will add more here when I get more time)

This thread is kinda a work in progress. I will upload my code and data here and probably comment it all up within the next week, I just am really busy right now and would like to get this all down while its fresh.

Please let me know what you think!!

Here's an image of me loading it up :)
IMG_0993.JPG
 

Attachments

  • flightdata.txt
    14.1 KB · Views: 61
Last edited by a moderator:
Good project. I've often considered doing something similar but always seem to lack time.
 
Nice work. Good data and analysis for a first flight. Very educational for you :).

I would just add a gentle reminder about the forces involved in a rocket launch. In your case there was an acceleration of around 5G. That makes everything weigh about five times what it normally would. Consider that during flight all the electronics and wires will have this multiplier in action. The long wires could be prone to breaking or disconnecting (if plugged) if you fly it a few times. Since you are not relying on it for deployment yet don't sweat too much ;).

Keep up the good work :cool:
 
Nice work. Good data and analysis for a first flight. Very educational for you :).

I would just add a gentle reminder about the forces involved in a rocket launch. In your case there was an acceleration of around 5G. That makes everything weigh about five times what it normally would. Consider that during flight all the electronics and wires will have this multiplier in action. The long wires could be prone to breaking or disconnecting (if plugged) if you fly it a few times. Since you are not relying on it for deployment yet don't sweat too much ;).

Keep up the good work :cool:

That was a main concern of mine- dealing with the acceleration. I honestly was pretty surprised when I opened up the bay and the data write LED's were still active. I also was concerned with the depressurization as it would have wanted to pull the wires apart as well. I kept the wires this way so I could debug and disconnect instruments as I saw fit as my program struggled to deal with shorted out components. So in the event that it happened to occur at the launch pad before the flight I wanted to be able to diagnose the issue and take some components offline.

I think my next step will be to condense the wiring to hardcore wires and or print my own PCB. I know I can make the whole system at least 2x smaller, if not more, without a custom PCB.
 
Discussion-
Somethings that I have noticed that seem a little off: There is no acceleration in the X axis after the motor burn out, which does not make sense as there should be a positive acceleration (against the motion of the rocket).
(I will add more here when I get more time)

First of all great job! Its not easy to get all those pieces working to together before a first flight.

On your acceleration results, your data is correct. The accelerometer measures the rockets acceleration relative to its frame of reference and not the earths. In other words its incapable of sensing gravity, it only senses the acceleration due to thrust and drag on the rocket.

After burnout the only measurable force on the rocket (from the rocket) is the drag force. Since you were probably going a slow speed this drag force is very small, hence the small acceleration readings. Later on when your rocket was under parachute (presumably) your accelerometer reads ~1g. It was really measuring the force of the parachute on the rocket. The real acceleration relative to the earth at that point is actually 0g.
 
First off... nice work! As someone else said, the "packaging" of the system is risky. May I ask how much out of pocket you spent on this (not counting your time which also has value)?

Thanks
 
Back
Top