PIE1 – Raspberry Pi Sends Live Images from Near Space

HAB (High Altitude Ballooning) is a growing hobby where enthusiasts use standard weather balloons to put small payloads typically 100g-1kg into “near space” at altitudes of around 30km or so, carrying a tracking device (so the balloon position is known throughout the flight) and usually some sensors (temperature, pressure etc) and often a video or stills camera storing to an SD card for later retrieval. The job of the tracker is to read the location from the GPS receiver, possibly also read some sensors, and then format and send a telemetry sentence to the ground over a low power radio link. Flights only happen once the predicted path is known to be safe (avoiding airports and densely populated areas for example) and permission has been gained from (in the UK) the CAA. Here the tracking system uses the 70cm radio band (around 434MHz) using RTTY to send the telemetry down to a number of ground stations run by other enthusiasts. Telemetry from all receivers is sent to a central server that then drives a live map which can be viewed by anyone with an internet connection. The system works extremely well and has been used to track payloads at distances of 800km and more even though the transmitter is limited by UK law to 10mW ERP.

In early May I received my first Raspberry Pi computer, and having flown several high altitude balloons before I thought about using one as a flight computer. In almost all of my previous flights I used Arduino Mini Pro boards, and these are ideal – tiny, weigh almost nothing, simple and need very little power. I looked at the Pi and saw none of these desirable features! What I did see though was a USB port offering quick, easy and inexpensive access to a webcam, meaning that for the first time I could have live images (SSDV) sent down by my payload – something that hasn’t been done very often.

“Near Space” is a fairly hostile environment – less than 1% atmosphere, temperatures down to -50C or so – and if anything goes wrong it’s likely to stay wrong. The radio link is one-way so there’s no chance of remotely doing a “sudo reboot” let alone powering off then on again! Descent can be violent, as can the landing, so even things like SD card sockets can represent a potential failure mode. The Pi is a step up in complexity from the usual boards we use, that have no SD cards, or USB, or even an operating system, so the extra power and capability does come at a price, and the first one is an increase in the power requirement from around 60mA to over 500mA, and that of course means much higher power dissipation. People often worry about the low temperatures in near space, but when your payload is generating a few watts of power that is not likely to be a problem! I was much more concerned with how hot it was going to get inside the payload, so I added some heatsinks to the Pi:

I used special thermal adhesive to glue heatsinks to the USB/ETH chip and to the 3.3V regulator. Both get warm but not hot normally, and I feared that at 1% atmosphere (so less convection) they’d possibly get too hot. You can also see 2 wires carrying 5V directly to the Pi – soldered joints are more reliable than using a connector. Another modification was to remove the S2 video connector to make space for components on my expansion board. The final modification was to short out the USB fuses since my webcam’s current requirement exceeds their rating. I then added a small piece of stripboard carrying a Radiometrix NTX2 radio transmitter to send the telemetry and images down to the ground, and connected that to a simple GPS receiver on a wire tail so it can be kept away from the transmitting devices.

The final item for a basic tracker is a suitable power supply. Energizer Lithium AA cells are the obvious choice since they are specified to work down to -40 degrees C, and are very good at high currents (we need over 500mA for the Pi plus webcam). On the way to 30km the outside will get down to -50C, and even with minimal insulation the batteries will self-heat to stay within their operating range. The Pi needs 5V supplied to it, so I used an external LDO (Low DropOut) linear regulator fed from 6 AAs which will supply enough voltage to the regulator until they are pretty much flat. With the regulator dissipating up to 3 watts it needed and got a heatsink. This is a lot of heat to get rid of a payload (which is insulated because you don’t want it to get too cold either because that can affect other parts). I had some switched mode regulators ordered but they didn’t arrive in time for my flight, so it went up with the linear regulator.

The usual technique with the NTX2 is to send the ‘1’ and ‘0’ values in RTTY by waggling a general purpose I/O pin up and down at the correct rate. e.g. every 20ms for the common 50 baud data rate. This is easy when you’re programming a bare-metal AVR or PIC – just use a delay routine or, as in my trackers, a timer interrupt. However the Pi runs a non-real-time operating system, so I could not rely on accurate timing especially if the operating system is busy taking a photo from the webcam. There are other options but I opted for the simplest one – connect the NTX2 to the serial port. RTTY is just normal RS232-style serial marks and spaces and stop bits etc., so why not let the hardware UART do the timing for me? It didn’t take long to write a small ‘C’ program that opened the serial port at 4800 baud, read enough GPS strings to find the longitude, latitude and altitude, then close the port and re-open at 300 baud (I found that switching baud rates without closing and opening wasn’t always reliable) to send out a formatted telemetry string. Of course to do this I had to disable the login prompt on the serial port, and stop the kernel debug messages being sent to it, but all in all it was simple. All of this was done using the standard Debian image on a 4GB SD card.

Now for the live images. I had to apply a patch to Debian after which it happily recognised the webcam as /dev/video0. I tried a few webcams and settled on the Logitech C270 which is reasonable quality, light and cheap (in case the payload goes missing!). I tried several webcam imaging programs and found fswebcam to be the best (worked without fiddling, yet had enough options to tailor the picture taking). Remember that the radio system has low bandwidth and with a typical flight lasting 2 hours or so we don’t have time to send large images, so there’s no point using the very best webcam and the highest resolution. I settled on 432 x 240 pixels with 50% compression as a good compromise between quality and download speed. I measured the webcam current and it went from 50mA at idle to 250mA peak when taking a picture, hence the need to short out the USB fuse (140mA max). A simple shell script took a photo every 30 seconds, saving them on the SD card so that the tracker program could choose the “best” image (largest jpeg!) for transmission. Each chosen image is then converted to the form for download (split into blocks each with FEC) before being sent 1 block at a time. I interspersed the image data with telemetry – 4 image packets for each telemetry packet). Here’s the Pi making a self-portrait:

With the completed tracker tried and tested, and permission for the flight gained from the CAA, I built a container for the Pi, webcam, GPS, aerials, batteries and regulator. I didn’t want to use too much insulation as the package needed to not get too hot with 3 – 5 watts being generated inside, so I used 10mm thick EPX material. Any thinner would be too fragile.

As the launch day approached the wind predictions consistently showed an S-shaped flight path from the launch site near my home in West Berkshire, initially flying south, then east, then briefly north before turning west at higher altitudes. Then during descent it would go through those directions in the opposite sequence, finally landing somewhere in the Chilterns. With the weather (i.e. rain, as it’s summer now) looking OK if not ideal, I ordered and collected the gas for the balloon. I obtained permission for 2 flights, so a friend and fellow enthusiast Anthony Stirk could come down and fly two new trackers that he’d built. With 3 trackers and 2 flights we opted to fly a large balloon with a small light tracker, and then fly a second balloon with Anthony’s larger tracker and a GoPro HD video camera, then attach the Pi to that. After a bit more thought we decided to add a third tracker as a backup to make sure we got that GoPro back!

The flight day came, and so did the rain, but that was predicted to pass so we waited and then went to the launch site as it eased to a light drizzle. First was the larger balloon with the small payload, so Anthony could make an attempt at the altitude world record. Then came the rather more complicated flight with my Pi payload at the top, then the GoPro payload, and finally my backup “Buzz” tracker which I’d flown before. Here’s “PIE1” waiting to go:

and the balloon it’s being attached to:

The entire train of parachute and 3 payloads weighed 1kg (same as my very first payload) and from the balloon to the lowest payload it was around 60 metres in length! The launch was interesting, as initially the wind kept the balloon low and the line was nearly horizontal! After a short wait the wind eased, the balloon lifted and got to an angle where it was safe to launch after running towards the balloon as fast as I could! I was relieved to see it all lift nicely, and that huge train made an impressive sight as it went up towards the clouds.

The launch site is in the village where I live, so afterwards we drove the chase cars back to my house to our “mission control” to watch the tracking and images from there. The predicted landing spots meant there was no hurry to get back into the cars to chase the payloads, so we had plenty of time to watch the images come in and grab some food.

The first flight was the altitude attempt, using a make and size of balloon that from experience either bursts early at around 27km, or exceeds specification to reach 40km or so. In fact the top few places in the altitude record table are all held by that make/size. Anthony was of course watching the altitude reading in the telemetry quite closely!

Meanwhile I of course was much more interested in how well the Raspberry Pi was doing. The GPS position was still showing the position at the launch site, which is a sure sign of interference to the GPS signal. I’ve not determined yet which it is, but the GPS receiver and antenna were quite close to both the Pi and the webcam in the payload. For next time I’ll add screening and increase the distance a little. However, the image data was coming in perfectly, not only through my antenna and receiver at home, but also via other receivers around the country. As the balloon got higher the pictures got better, and more receivers started getting good data, with some image data even being received as far away as Northern Ireland (over 500km away – not bad for 10mW!). Now, a PIE flight isn’t complete without a PIE chart, so here is one, showing the number of image packets received by different listeners (thanks all!):

The first flight meanwhile was creeping up the altitude table, eventually reaching the #4 position only 300-odd metres below the world record. Part of me was hoping it would go higher, but part was happy that it didn’t knock me down from my #2 spot in the table! The balloon then burst, and initially the descent looked perfectly normal. However most of the balloon was still attached and it managed to produce a parachute-like shape which slowed the descent to only 2 metres per second at an altitude where it should have been doing at least 5 times that! Turning to the main flight, it was sending in image after image without errors, and each image being better than the last as the balloon got higher and higher.

We were expecting it to burst at around 34km, but obviously the balloon wasn’t aware of our calculations. It went through 34km, and 35, and …. and eventually burst just a few metres short of 40km (39,994 metres to be exact, putting it at 12’th place in the UK altitude record table). Quite amazing for a medium sized balloon with about 1kg of payloads underneath it! With both balloons having burst it was time to get going in the chase cars, both of which were equipped with aerials, radio receivers, netbooks or car PCs for decoding and mapping, and 3G internet. The landing prediction for the main flight was for near Didcot, so we headed there and parked up to check on the latest prediction. We weren’t far away when the payloads landed in at Milton Heights, just a few miles from the launch site. Amazingly, one of the receivers was close enough to still be picking up live images, and after a while everyone could see that the payload had safely landed in long grass:

Anthony saw the payloads first from his chase car, in long grass next to a football field. Having obtained permission from the club we rescued all 3 payloads and the parachute:

Meanwhile, the earlier flight was still coming down, but very very slowly – less than 1 fifth of the expected rate! We didn’t know at the time but we’re pretty sure now that the latex had managed to form its own parachute. Then, with a few km to go, it suddenly sped up (we think the latex tore) and landed in a field north of Oxford. Here’s the very unsual altitude plot:

It took a while for us to get the final position but having done so it seemed that it was in a rather inaccessible location. With the rain pouring down, Anthony decided to call it a day rather than try to retrieve what is only £50-worth of tracker. He then drove off, and I went online to tell the other receivers in the UKHAS chat room that I was about to go home too. “Ah, but it’s near a layby on the A34” I was told, “easy to get to” and “the rain will pass in 5 minutes”. Well, that didn’t sound so bad so I set off north up the A34, then back southbound to get to the layby.

Well, of those 3 statements, 1 was correct – it was just 155m from the layby. However the rain just kept on coming, only easing from torrential to very heavy as we sat in the car waiting. Eventually I decided to just go for it, and crawled past trees and bushes to find … a field full of 5′ high maize. No chance of seeing the payload from there, though I tried. After failing I went back to the car to get my Android phone loaded with HamGPS software that guides you to a target location. It took a lot of effort to get there, and for a while I felt like I was starring in “Dave Of The Triffids”, but as I got to the target position I walked into the nylon cord between the payload and remains of the balloon! It really wasn’t visible at all until I was almost on top of it. Here I am emerging, successful, after my expedition:

So, all in all, a great day HABbing. All 4 trackers worked well, all were recovered, and we got some stunning live images back. For more information on this fascinating hobby, visit the UKHAS web site. For more images and video, see:

Thanks go to Anthony Stirk for driving down from sunny Yorkshire to grimmest darkest Berkshire for the launch, and supplying the GoPro HD footage, to Philip Heron for providing the webcam imaging and image encoding software, to Nick for coming along to help out, and of course to my wife Julie for keeping us fed and watered during the day and for driving my chase car whilst I did the techie stuff.

We have reviewed the footage at length and we are confident it was lense flare probably through the GoPro’s polycarbonate case. We did catch the crescent moon though !

and @Chris

The balloons follow the atmospheric winds which do change both speed and direction at altitude. If you have a look at uAVA Track you will see as it climbs it changes direction quite drastically and it mirrors this on the way back down. The winds are unlikley to be so quick as to take the payload out over Europe/Atlantic in the short time we are up there.
Thanks to the team at CUSF we are also able to predict these paths with a reasonable accuracy in advance to ensure we don’t land anywhere daft.

It just goes where the winds take it, and if those aren’t strong it won’t get very far. Also, the winds at different altitudes can be in different directions, and this flight went south then east then north and and finally west for a while on ascent. So a lot of the movement at on level got cancelled out by opposite winds at another level.

Sometimes, especially if they get caught by the jet stream, then can go a lot further. One of mine landed in Belgium (as per the prediction), having reached speeds of 240mph at one point.

Nice work doing a lot with a little!
My last balloon flight cost over a million dollars and the 450 lb. package spent 2 days at 260,000 feet testing a cosmic ray detector destined for the first satellite to leave the solar system. No one trusted my data recorder of 1/2″ computer drive tape running over two 1/4″ 4 track heads (It worked perfectly). So, an illegal three watt transmitter running at the bottom of the FM band backed me up. A Sherwood FM tuner with a Radio Shack rural TV antenna was the ground station. Ah! Real hacking! The FCC never got us! The link sent solid data over 1,500 miles. It still amazes me how much work was done in a very short time when driven by the embarrassment of Sputnik!

I’m not a licensed radio amateur (that’s on the to-do list though!), however even though Anthony is, UK rules specifically preclude airborne transmissions. So APRS is, sadly, out. Pretty much all flights in the UK use the 10mW unlicensed portion of the 70cm band.

I was just thinking, totally off the wall I admit, that if your payload was in the form of a small glider, then I`m sure that the Pi could further be expanded to control flaps etc. and with gps onboard already be used to guide it self back to some acceptable landing sites…

That is nothing short of impressive. I’m not a radio amateur either but I’m keen as about radio and I was not aware a 10mW signal could travel over 40km (let alone 500km!) Surely the receivers had gain antennas? In Australasia our limit is 25mW so it would be interesting to try this out. Thanks for this post! 😀

Yeah, that’s a very wide-angle lens on the GoPro, which on the plus die gets a lot into the image, and on the down side has that weird distortion. I’m not really a fan of that, and the camcorder I use doesn’t have such a lens.

That’s fantastic. I’ve been building some home grown photography equipment around Arduino myself recently but nothing anywhere near as impressive as this. Just heard my Pi’s now on it’s way now after being in the queue for weeks too 🙂

I Watched aged 9 the Lunar Landings….I studied hard got adegree…met an inspiring lady called Rosie Dalziel..An American Lady who worked at East Ham College of Technolgy…..turned out she wrote the simulator for nasa for the lunar landing in less than 64k.

What you doing at EHTC she says i joined the London Dockland Development Corporation and they have given me a grant to develop my computer robotics contoller…..You meet some people along the way
YOU GUYS STAND TALL LOVE YOU XXXX

Dave,
Next time, try to put some tape on the balloon, and pop a little hole in it.
Balloon explodes quite often because of the vacuum of space and the pressure in the balloon, where on earth the balloon would be ok, in pure vaccuum the balloon has 1BAR more pressure within it.
For that reason it’s best to have a hole where the gas can escape out of; one way propelling the balloon a tiny bit upwards (when making the hole on the bottom), otherwise keeping the pressure lower.

It takes time and experience to determine the right size of the hole (I guess about the size of between a needle and a nail would be a good sized hole).

No, what actually happens is that the leak reduces the lift, and the balloon will float at a lower altitude than if it didn’t have the leak.

If the aim is to float, then a controlled leak (i.e. a valve in the neck) is the way to do it.

If the aim is altitude, then you fill with the correct amount of gas to achieve that. Too little and it will float; too much and it will burst too early. A leak serves no purpose.

Also, to get altitude you use hydrogen, and a leaking hydrogen balloon is not a good idea for obvious reasons. There’s also the danger that the balloon will slowly descend, and I don’t want to land a hydrogen balloon in smoeone’s back garden while they’re having a BBQ.

On this particular flight, we didn’t aim for particular high altitudes. In fact we over-filled to ensure the balloon burst with no danger of floating. We had an expensive camera on board so the aim was to get to a reasonable altitude (30km would have been plenty) and then retrieve the payloads. We used hydrogen because it’s 1/3rd the price of helium (a limited resource) not because of the altitude gain. I should note that both of us are experienced at filling balloons with hydrogen, and I strongly recommend that beginners use helium for the first launches.

How did you put the various components together ? any schematic? what is the role of raspberry pi – is it to connect to camera or gps or image recording — how did you transmit the images – which module? By the way it was the amazing scene – actually I dream to make the same (capturing and transmitting as well) with my foam plane – so looking for ideas. There is always conflict of Tx Rx frequencies with these setups, you luckily avoided 2-way control – so normally some 433MHz will do one way and maybe 2.4GHz 800mW will Tx images and maybe videos also well enough. That is where I thought that RPi is no go here some Atmel IMU with GPS, gyro, accel, Magneto would have done the job but then 2.4 GHz 2-way comes to play with huge power issues and control becomes big than the job of Tx’ing videos / images.

Hi
Thanks for the article and it has captured my attention. I run a small youth work project in Lostwithiel. We would love to set up a web cam or 2 on the woodlands we have and upload the images to the web. We exist totally off-grid. Would it be possible to adapt your project to do this please?
Thanks
Rich

I would like to get a copy of the C program you wrote to interface the GPS for tracking your location.
I am trying to build a simple low cost equipment tracking system.
The current GPS tracking equipment is expensive and the monthly fees are to expensive.
I appreciate your help.
Thank you,
Ed

The GPS program onlyworks in conjunction with the radio tracking system that other HAB enthusiasts set up for each flight. It uses low-power license-free transmitters that when on the ground only have a range of 100 metres or so, meaning that they’re completely useless for general tracking. Of course when attached to a balloon the line-of-sight is much greater enabling us to use them over distances of several hundred miles. However for your application this system just won’t work.

Now, if I can get one of my BBC Bs (the inspiration for the Pi) fitted with a new 14MHz 6502, connect it to my Vidicon camera, swap the bottles for FETs, stick on the 20″ aerial survey lens and bang on a couple of car batteries, I could do a retro verion???

I was wondering if you could please help me out a little Dave. I am also looking to use the raspberry pi to transmit images (though at significantly lower altitudes!), and was wondering if you could please provide a little more guidance on the software you used and the schematics for transmitter circuits.

My goal is to eventually use the pi to send images from deep within the bush for animal monitoring.

hi this is amazing and I had considered doing this myself but now i realize how difficult it is maybe we could do another one together?
anyhow if i ever have the knowledge to do this i definitely will try!

Did you connect the Raspberry PI’s TXD output directly to the Radiometrix TXD line? Or did you use some kind of v3.3 to v5.0 level conversion hardware? If you did level conversion, can you share your design? I am planning to build an APRS transmitter using a cheap USB GPS and a Radiometrix HX1, and I am wondering how complex the connection between the Raspberry Pi and the HX1 needs to be.

Connected via some resistors to set the level and bias. This means that the low/high digital outputs from the Pi result in 2 slightly different voltages at the NTX2, which then transmits two frequencies approx 600Hz apart.

The software isn’t open source. If you want to fly your own Pi (or any other suitable processor board) there is ample information at http://www.ukhas.org.uk on how to build a tracker and how to write the software.

Hi Dave
I have a PI running on 4 aa batteries, recharged via a solar panel. Would it be possible to run the Logitech webcam with this set-up please? Would you add more batteries?
Thanks for any help.
Rich

My (University) students recently brought your project to my attention when I assigned them a project of building balloon payloads to fly in “Mars-mode” where they must send all data back by radio (as opposed to just tracking the payloads and recovering them — much simpler — which I’ve done about 60 times (so far)).
Are you willing to share your code, or at least some suggestions about how to encode photos in RTTY which is new to us, so if they decide to pursue this idea they don’t have to reinvent the wheel?
James

hello
The greatest problem I thing is the air preasure in altitudes of 40 km.
The most problems will cause water-containing electronic parts, like electrolytical capaciators. OJK, some with low ESR will be better – on your pictures I stil see these capaciartors. The best will be ceramic capaciators.
And the LI-Ion cells with their electrolytes inside? In preasures only 1-2% of ground ATM-preasure – how did they survive ? or have you a special camber for these cells to keep ground-based preasure for these cells?
Whats about the heat convection of the circruits without the normal air-conditions?
And whats about the EM-shielding of the electronics in that altitudes?
Whats about the UV-filtering in front of the webcam-optics?
How long the equippment did need to pass the very cold temperature zone in 16-25 km altitude while ascending ?
In the web-video (http://www.spiegel.de/netzwelt/web/raspberry-pi-die-besten-projekte-fuer-den-46-euro-pc-a-874993-6.html) there is sound of the webcam-mic
and some radiotransmitter-accoustic-interferences you can hear….

This is definitely my favorite Raspberry Pi project to-date! My high school is thinking about doing a near-space balloon program before spring break this year so I’m definitely gonna use my Raspberry Pi for that and get a brake from programming useless text-based games xD Anyway nice job Dave! And thanks a lot for the helpful information!

Impressive. We use the PI for ODB diagnostics on cars which have spontaneous electrical problems. We connect the PI to the diagnostic port and the customer can drive some times till the error arrives. With these we can find almost every problem …

Hi , this was awesome, i saw couple years ago. but now that there is the pi zero which i would like to try with it. My question is. for the live images. how did you set up the radio link? any instructions? thanks
Santiago