Introduction: Electronic Barometric Altimeter for Stratosphere Balloons
Our team, RandomRace.ru, launches helium balloons. Small and big, with cameras and without.
We launch small ones to randomly drop checkpoints for adventure race competitions, and big ones to make great videos and photos from the very top of the atmosphere. It's not the space yet, but at 30 km of altitude air pressure is about 1% of normal. Does not look as the atmosphere anymore, huh? My responsibility in the team is electronics, and I wanna share one of my projects implemented on that duty.
How can we measure the balloon altitude? With GPS (most of them do not work above 18km) or with a barometric altimeter. Let's make one from an microcontroller(MCU) board! We want it to be light, cheap (since sometimes we loss our probes), and easy to build, easy to use. It also should measure very low pressures. The device should log data at least 5 hours in a row. Let's use some Lithium battery from any old mobile phone as a power source. Basing on the requirements, I have chosen Maple Mini board, based n ARM microcontroller(STM32F103RC) with an USB interface, 128 Kb of internal memory, which is enough for both MCU firmware and collected data. Unfortunately (or fortunately?) , LeafLabs does not produce those boards anymore, but their clones could be found in Chinese online stores for a couple of dollars only. Also we were donated with a number of MS5534 air pressure sensors, capable to measure 0.01...1.1 bar. That is more or less enough for 30 km altitude.
The device is quite easy to make, you only need some soldering skills and tools (there is no need to solder really small parts) and basic computer skills. Here you can find a github repository which contains both breakout PCB design in Eagle format and the firmware.
Step 1: Required Parts.
- Clone of Maple Mini MCU board
- 4*1 2.54mm(0.1") pin row (usually shipped with the MCU board)
- 1S LiPo battery. Batteries from old mobiles or action cams fit perfectly.
- 1S LiPo charger board
- MS5534 barometric sensor
- MS5534 breakout board
- 1N5819 Schottky diode or similar
- JST RCY pigtails, 1*Female, 2*Male
- Empty aluminium beer can
- thermal shrink tube D=2,5mm(0.1") of any color
- thermal shrink tube D=20mm(0.8"), transparent
Instead of MS5534 you can use MS5540, but it requires another breakout board. You can make it on your own, using EagleCAD or KiKad or whatever you prefer. You can also solder the sensor directly with wires if you have enough of soldering skills.
- Regular set of tools for soldering
- Scissors and plies
- Optionally a soldering fan. If you do not have one, you may use your soldering iron and a cigarette lighter instead.
- some standard 1 pin female-female wires
- a couple of extra contact pins
- A STM32 demo board to be used as an MCU flashing device. I used NUCLEO-F303RE, but any of STM32 Nucleo64 or Nucleo144 boards can be used also.
Step 2: Soldering Sensor Onto Breakout Board
First of all, you we need to solder the sensor on to the breakout board. Use soldering paste and soldering fan soldering iron, if you have ones. If not, you can do that with regular soldering iron and solder.
When it's done cut four pins row and two pieces of wire, about 4 cm each. Solder them to the breakout as shown on the second picture - pins + and - should be connected to wires, 4 other ones between them - to the pin row. Pins have to be on the bottom side of the breakout.
Step 3: Soldering the Rest of the Device.
Sensor board and MCU bard should be stacked, and the sensor must be placed over MCU chip
Connection diagram is shown on the 1st picture. And here are all the connections listed:
- Breakout pin "+" is connected to MCU board pin "Vcc"
- Breakout pin "GND" isconnected to MCU board pin "GND"
- Breakout pins "8", "9", "10", "11" are connected to MCU board pins of the same numbers.
- JST RCY Maleblack wire is connected to another "GND" pin of the MCU board
- JST RCY Male red wire is connected to a diode anode
- Diode cathode is connected to MCU board "Vin" pin
Before connecting JST pigtail, do not forget to put a piece of thin thermal stretch tube on the red wire.
Last thing to do - the diode must be insulated with thermal shrink tube. Just pull it over the diode, and then warm it with your soldering fan - recommended temperature is about 160C(320F). If you do not have the fan, just use a candle or a cigarette lighter, but be careful with that.
Step 4: Battery and Charger.
Lets make a power source for the device and a charger for it.
The female pigtail should be soldered to the battery. Red wire to "+", black to "-". Protect the connection with a drop of thermal glue, a patch of duct tape, or an insulation tape - on your choice.
The male pigtail must be soldered to the charger board - red wire to "B+", black to "B-". Secure the board with a piece of thermal shrink tube.
Now you can connect the charger to the battery,and the charger to any USB power supply or computer port. Red led on the board indicates charge ongoing, green one - fully charged battery. The board might warm during charging process, but not too much.
Step 5: Flashing the Device
To flash the device, you need to install some software. For Windows, you can use native application from st.com site. Unfortunately, you need to register here.
Under Linux or Mac (well, under Windows it's also possible), you can use OpenOCD. Please find installation and usage instructions on their site.
Now you can download the firmware.
To prepare the device for flashing, you need to temporary solder two more pins to contacts 21 and 22 of the MCU board.
To connect our device to the flasher:
- open both jumpers on CN2 connector of the Nucleo(white) board. That enables the board to flash external devices.
- connect MCU pin 21 to pin 2 of Nucleo CN4 connector
- connect black battery wire to pin 3 of Nucleo CN4 connector
- connect MCU pin 22 to pin 4 of Nucleo CN4 connector
- connect both device and Nucleo board to the computer with USB cables.
- flash the fiirmware (Windows)
- Run STM32 ST-LINK Utility
- Select File -> Open file... -> open downloaded firmware
- Select Target -> Option Bytes..., select Read Out Protection: Disabled. Click Apply
- Select Target -> Program & Verify, click Start
- Download and install OpenOCD.
- run the command
openocd -f interface/stlink-v2-1.cfg -f target/stm32f1x.cfg -c "init;reset halt;stm32f1x unlock 0; program baro_v4.hex; shutdown"
Step 6: How to Use the Device.
If everything is done properly, then we are ready to run the device. The altimeter has three modes:
Power the device through USB or through a red battery connector. Press the button (most far from the USB connector) and hold it for 2-3 seconds. Blue LED should start blinking very quickly and keep blinking that way until all the data is erased.
Connect the device to the battery with the red connector. Blue LED will blink frequently for a couple of seconds and then turn to blinking once a second. Every time when it blinks, a data sample is written to the internal device memory. The device can record up to 9 hours of measurements.
Reading the data
Disconnect the battery and connect the device to your computer with USB cable. After a couple seconds of frequent blinking it turns to blinking twice a second. This is data reading mode. The device is recognized as a flash drive named BARO_ELMOT. The drive is not writable, you can only read data from it. In a file manager you can find two files on the device - first one is named like LEFT_123.MIN. This is fake file, it does not contain any data, but that "123" means there is still room for 123 minutes of data logging. Another file, BARO.TXT, contains actual collected data, i.e. tab separated text - a header and then data lines. This format can be easily imported into MS Excel, or to any other spreadsheet application, including Google Sheets.
Each line contains a series number (S), a sample number (N) (=elapsed time in seconds), Temperature (T) in Celsius, Atmosphere pressure (P) in mbars, and rough altitude value (A), in meters above sea level.
Note! "A" values are really rough, you may calculate the altitude from pressure data on your own. See further steps.
Step 7: Testing the Device
- Connect the battery to the device. LED should start blinking.
- Press and hold user button. After 2-3 seconds LED will start rapidly. Release the button. Keep cool, do not disconnect the battery. Data is being erased.
- After a while the LED starts to blink once per second.
- Keep the device on for at least 30 seconds.
- Disconnect the battery
- Connect your device to a computer with USB cable.
- The device will appear as a small, 3Mb only, flash drive. Open BARO.TXT file there with any text editor.
- Check if columns T and P contain reasonable data - usually about 20-30 for T, about 1000 for P. If you are in a fridge or on the top of Everest, the numbers will be drastically different, of course.
Step 8: Sunlight Protector and Shrink Tube
After the previous step we are sure everything works ok, now we should unsolder flashing pins, because we do not need them anymore. Also it's better to accurately cut tails of pins which connect the sensor and the MCU board, otherwise they can puncture outer plastic cover of the device.
The sensor used in the project should not be exposed to a direct sunlight. We will make a protection shield from an aluminium beer can. Definitely, if you advanced that far already, you have deserved the content of that poor can. Cut with scissors a piece of aluminium of a size about 12*12mm (0.5"*0.5"). Then bend two opposite sides of it with pliers to make a small "tray" 7*12*2.5mm (0.28"*0.5"*0.1"). After bending, cut 1.5mm stripes from that bended sides, to make the tray a bit lower, about 1 mm high.
Put the tray on top of the sensor. Note - it should not touch any contacts! Then put the device with the tray into a piece of thermal shrink tube (a bit longer than the board) and heat it well, but carefully with the soldering fan (or the cigarette lighter). Check again if aluminium cover does not touch contacts of the sensor.
Step 9: Science
Now we have the device ready to run. It measures temperature and air pressure. And also roughly estimates the altitude. Unfortunately, the pressure depends on altitude very non-trivial way, you may read about that in wikipedia. How do we calculate a balloon altitude more precise way?
One of the ways is to use 1976 Standard Atmosphere Calculator. Your device contains the same model data, but not very precise due to device memory limitations. Using the barometer data and the calculator, you can compute the altitude much better than the deice does on it's own. Also taking in account the weather conditions at your balloon launching spot(obviously, that is recorded to the same altimeter in the very beginning), and your launch spot altitude you can find temperature shift and air pressure correction and. Then using the same calculator, you may compute everything even better. With some spreadsheet skills, you can also make data charts of a launch.
Runner Up in the
This is an entry in the
We have a be nice policy.
Please be positive and constructive.