LoRa PC Gateway

I generally use the Raspberry Pi to receive LoRa transmissions from balloons, and to upload the packets to the HabHub servers.  However it sometimes might be more convenient to use a PC or Mac, or a phone or tablet, for internet connectivity, in which case we need some way of interfacing a LoRa module to those devices.

Hardware

Here I have used an Arduino Mini Pro, connected to the LoRa module via SPI and 2 I/O pins, and using software derived from my Handheld LoRa Receiver to allow control of the module via the Arduino’s serial interface.  I’ve built 2 such devices, the first of which connects to a PC via USB, using a Prolific PL2303 USB-serial adapter:

IMG_2811

IMG_2809

The second device uses the same firmware, but connects to the PC (or Mac, tablet, phone) via bluetooth using a HC-06 bluetooth serial adapter.  Power comes from a small LiPo, using a USB charging module.

P1110723 IMG_2813

Firmware

The firmware handles incoming packets directly, copying them to memory before sending to the host PC or mobile device.  It also sends various status values – current RSSI every second, and packet RSSI, SNR and frequency error before each packet.  It accepts simple commands to set the LoRa frequency, bandwidth, spreading factor, error coding, packet header type and low data-rate optimisation.

Software

Currently I’ve produced Windows software that communicates with either device using a virtual serial port (USB or Bluetooth), and expect to make that cross-platform soon (OSX, Android, iOS).  This program allows the LoRa parameters (frequency, bandwidth, spreading factor etc.) to be set, displays incoming telemetry packets, and optionally uploads those packets to Habitat (so the balloon position is displayed on the live map).  SSDV isn’t supported yet.

WindowsGateway

Build

To make your own device, you will need:

  • Arduino Mini Pro
  • Programmer for above
  • LoRa Module (RFM96 for 868MHz or RFM98 for 434MHz)
  • Wire and solder
  • SMA Socket
  • Suitable case

Plus for the USB version:

  • FTDI or Prolific USB-serial adapter

or, for the Bluetooth version:

  • HC-06 Bluetooth interface
  • LiPo battery
  • USB LiPo Charger
  • On/Off Switch

Connections from the Arduino to LoRa are described in the firmware.  Remember to connect GND on Arduino to GND on LoRa, and Vcc on Arduino to 3.3V on LoRa.

For the serial version, first check if your USB adapter supplies 5V or 3,3V or both; for 5V you need to connect the 5V line to the Arduino “Raw” supply input; for 3.3V connect to the Vcc pin instead.  Also, connect 0V/GND from USB adapter to the Arduino GND pin.  The USB Tx connects to Arduino Rx, and USB Rx to Arduino Tx.

For the Bluetooth version, the LiPo connects to the Arduino Raw pin via a switch.  The Bluetooth device then takes power from the Arduino 3.3V line.  Rx/Tx pins connect as above.  All GNDs connect together of course, and to the battery -ve wire.  The LiPi charger connects to the battery directly.

Download the firmware and program the Arduino with it.

To the USB version to a PC, just plug it in and hope that Windows installs the driver OK; if not then download and install the driver appropriate to your device.  Check in Device Manager to see which serial port number it has installed.

For the Bluetooth version, connect and install a USB Bluetooth adapter if one is not already installed.  Power on your LoRa/Bluetooth receiver and then search for the bluetooth device in Windows.  You should see “HC-06” show up.  If you are asked for a PIN number it is 1234.  Check in Device Manager to see which serial port number it has installed; if it doesn’t show then be prepared to wait – for some reason it can take several minutes.

If you are using my Windows software, download that to a new folder and just run the .exe file.  Choose the serial port that was installed earlier, and within a couple of seconds you should see the “Current RSSI” value start to update.  Choose your LoRa settings and click the “Set” button.  Once you’ve done that, you should start seeing packets arrive (assuming you have a tracker running using those LoRa settings, of course).

 

Posted in Weather Balloon | 2 Comments

One Little Cloud In The Blue Sky

On Saturday I helped with a school launch by Greg Tomlin, who drove here from Coventry with his SKYBLUE payload and a minibus full of excited schoolchildren. It was their first launch, but not Greg’s, as he’d launched twice before with his previous school.

Predictions were for a fairly gusty and showery day overall, but with a chance of launching in the morning before the wind got up and the clouds and rain arrived. Landing predictions were also good for the morning, but poorer later as the winds would take the balloon down to the Severn Estuary. I ran through several permutations of balloon size and gas fill, and finally opted for a 1600g balloon with a standard ascent rate of 5m/s.  To help keep the flight away from a watery end, I chose a slightly undersized parachute so the final descent wouldn’t drift too far south.

Greg kindly offered a free ride for one of my trackers if I had anything to test, and I did. I’ve been working on a tracker that uses a servo-controlled parafoil to guide a payload to a specific landing spot. I’ve run this through emulated flights but hadn’t flown it for real, so this was an opportunity to do just that, with the fallback of another tracker in case things went wrong (which they did!). So, I quickly put together RTLS1 (Return To Launch Site), without servos of course, but with all the software intact.  Hardware was an original Pi Zero (I didn’t want to fly a camera this time) and prototype PITS Zero board with LSM303 compass/accelerometer connected.  As an extra test, I added code for a BME280 pressure/temperature/humidity sensor. Together with the RTLS compass data, and various landing prediction and flight control values, there was quite a lot of telemetry to send, so I opted for a 140 bytes/second LoRa mode for transmission.

rtls

I had another reason to fly something. My wife’s maiden name is Cloud, so last year I bought a cloud necklace, with the intention of sending it up to near space so she owned a very high-flying cloud! I hadn’t got round to actually flying it, but with our 30th wedding anniversary in a few days this was a good opportunity! The launch day also turned out to be the 12th anniversary of when Julie’s dad died, so it was particularly poignant. To add one more coincidence, he used to be a CB operator with callsign “Skyblue”.

With Greg and team en route, I prepared for launch so we could get the balloon flying as soon as possible (delays would mean a higher chance of a wet landing). So when they arrived, I had my tracker online and payload sealed with line attached, groundsheet out, balloon tied to the filler, and lines tied to the parachute. Greg and his team wasted little time in getting cameras started, tracker running and online, and payload sealed up and tied to the parachute and my payload.

IMG_1959

Meanwhile I inflated the balloon. The wind by now was quite gusty, but with quiet periods where I could get on with filling with gas and checking the neck lift.

After sealing the balloon sealed and tying it to the payloads, I took the balloon out to the field, followed by Greg and his team carrying the payloads, parachute and line. Out in the middle of the field, the wind was quite gentle and as I let up the balloon it wasn’t far off being vertically above me. Holding the lower (my) payload …
IMG_1970… I took a few steps downwind and launched. The entire flight train that rose into the grey sky above.

IMG_1971

Back in the house, I checked the transmissions and map. initially the live prediction was a bit alarming, showing a landing south-east of the Severn (I’d aimed for North-West), but then I remembered that the live predictor generally assumes a burst altitude of 30km, and ours should be 36km or so. Also, the initial ascent rate with hydrogen is lower than the average, whilst the predictor assumes the ascent rate will be constant.

With a fairly high flight landing not far away, we didn’t have to rush into the chase vehicles. So we had time to watch the flight progressing, and I had time to finish getting my chase car set up. Part of that was starting up my LCARS-based touchscreen, and when I did I noticed that the RTLS1 position wasn’t updating. A quick check of the telemetry showed that it had stopped at about 12km altitude, which was a very strong indication that the GPS wasn’t in flight mode. It later turned out I hadn’t re-enabled that code after disabling it for my emulated tests. Oops. At least the SKYBLUE1 tracker was still working fine, and I knew that RTLS1 would start sending the correct GPS data once the flight descends back through 12km, and that I would have plenty enough test data from it anyway.

Once it was certain that the landing point was going to be west of the Severn, we drove down to Monmouth to wait for the balloon to burst. Parking at a convenient and free location (Lidl !), Julie bought some supplies as we all watched the flight proceed and then burst. We waited a few minutes for the predicted landing position to stabilise, and then set off for the most likely landing area. We had to change our target a couple of times, and were a couple of miles away when the flight landed (which isn’t bad considering the how narrow and windy the roads are in that area!). My LCARS system had a last position of 166m altitude which was only 46 metres above the landing position, and 4 metres below the road near that position! I later found out that my home receiver had a last position of 368 metres altitude, which again was very good considering the hills between the launch and landing sites.

fullpath

Using that last position, we drove through a small forest (usually a bad sign when chasing a payload!) to a track which, according to the satnav, was the closest pint we could get to by road, with the payload about 350 metres away. I still had no signal from either tracker, which seemed very odd as normally I’d get a signal 1km or so away. With a single tracker I’d wonder if the tracker didn’t survive the landing, but it seemed unlikely that both trackers would stop. So we kept going in the hope of getting a signal further along the road. We still couldn’t get a signal so parked up and got out the Yagi which, with radials horizontal (meaning the payload was on its side or the aerial was squished against the ground) finally got a good, decodable signal. Tapping that into the satnav, we were directed back to that track we passed earlier. So we parked up, and Greg and I went to the adjacent house to find out who owned the land that we’d just dropped our payloads on, and to gain permission and hopefully directions too!

onfoot

With that done, we opted to walk down the track, which got progressively more muddy and after a while wasn’t getting us any closer to the payload. By then we managed to get satellite mapping loaded on my phone, and it became clear that it was going to be better to go back to the house and find a different route. When we got there I chatted with the landowners – a retired couple in the house – and they couldn’t have been more helpful. The husband was recovering from an operation, but the wife offered to come out with us, so once a quick rain shower subsided she got her wellies and we all followed her down a footpath and across (in single file!) a field to a second field where the children soon spotted their blue payload. They seemed pretty excited!

IMG_20160625_144458837

I, of course, was relieved that I hadn’t lost Julie’s necklace!

13524388_1050072618395749_1982685103118272568_n

13502103_1050025765067101_6399385235339609339_n

Back at the house, the SKYBLUE team showed some of their photos to the landowners, and after some more chat we all left.

IMG_20160625_153411555

Julie and I decided to stop in Monmouth to have lunch by the river.

IMG_20160625_163015376_HDR

So, a very good flight, and I now have lots of real data to peruse before I start testing my RTLS project with a parafoil.

Posted in Raspberry Pi, Weather Balloon | 1 Comment

To Zero, And Beyond

As many reading this will know, I flew the new Pi Zero on the day it was announced, in order to test a prototype of our new PITS-Zero tracker board.  I’d been pleading with Eben since I first saw a prototype of the original Pi Zero, that its low weight would be ideal for live-imaging HAB applications, if only it had a camera port.  The camera is much the entire reason for using a Pi for HAB – if you don’t want pictures then a smaller/lighter/simpler AVR or PIC microcontroller will easily do the job (and with less battery power) – so I felt that the CSI-less Pi Zero was a missed opportunity.  Eben agreed, and said he would try to make it happen.

PiZero1.3_700

So, when I received a sample Pi Zero with CSI port, I was keen to try it out.  However launching an unreleased device, to possibly parachute down in front of a curious Pi fan, might not be the best idea in the world, so I had to wait.  Fortunately the wind predictions were good for a balloon launch on the Pi Zero CSI launch day, and the flight went well albeit the burst was rather lower than predicted (balloons vary).

Sony Camera

I had hoped to fly the new Sony camera for the Pi, but in testing the camera would become invisible to raspistill after about 2 hours and roughly 2-300 photos.  2 hours isn’t long enough for a regular flight, and mine was expected to take more than 3 hours just to ascend, so this wasn’t good.  I searched the Pi forum and found that a couple of people using time-lapse photography had found the same issue, and as it was a new issue with no fix or workaround yet, I had to opt for the Omnivision camera instead.  This of course gave me a reason to fly the same tracker again as soon as there was a solution for the Sony firmware issue; once there was I tested it, and planned my next flight.

Waiting For Baudot

"It's currently a problem of access to gigabits through punybaud"

I’ve written previously about LoRa, but the key points about these Long Range Radio Modules when compared to the old (first used from the air in 1922) RTTY system are:

  • Higher data rates
  • Longer range with the same rate/power
  • Can receive as well as transmit
  • Low host CPU requirements even for receiving

The higher data rates mean that we can send larger images more quickly (throughput is up to 56 times that of 300 baud RTTY), and the receiving capability makes it easy to have the payload respond to messages sent up from the ground.  For this flight, those messages are used to request the tracker to re-send any missing packets (ones that the receiving stations didn’t hear), thus reducing the number of annoying missing image sections down to about zero.  To give you an idea of the improvement, the following single large picture was sent in about a quarter of the time taken by the inset picture (from my first Pi flight, and at the same pixel scale):

progress

LCARS Chase Car Computer

For this flight, I tried out my new chase-car computer.  This has a Pi B V2, Pi touchscreen, LoRa module, GPS receiver and WLAN (to connect to a MiFi in the chase car).  The user interface mimics the Star Trek LCARS panels, and was written in Python with PyQt.  It receives telemetry both locally (LoRa, or RTTY via a separate PC) and also from the central UKHAS server if connected via GSM.

The Flight

As per the previous Pi Zero flight, this was under a 1600g balloon filled with hydrogen.  Predicted burst altitude was 42km, and I hoped that this time it might achieve that!  The payload was the same as last time:

image

except of course for the new Sony camera (manually focused for infinity, but not beyond) and a new set of batteries.

On the launch day the weather was overcast but forecast to improve a little, so I decided to wait for a gap in the clouds.  When that came, the wind did too (that wasn’t forecast!), which made filling the balloon interesting.

No my head hasn't turned into a giant clove of garlic

No my head hasn’t turned into a giant clove of garlic

Fortunately, the wind did drop for launch, and the balloon ascended towards the gap I’d mentioned in the clouds:

P1110657

The LoRa system worked well (especially once I remembered to enable the “missing packet re-send” software!), with the new camera acquitting itself well.  I used ImageMagick onboard to apply some gamma to the images (to replace contrast lost in the atmosphere) and to provide a telemetry overlay, including this one which I believe is the highest image sent down live from an amateur balloon.

Cjaear8WEAA1ENN

Burst was a few metres later, comfortably beating my previous highest live-image flight.

And this was the last image it sent.  I guessed why.  Remember the camera stuck to the outside?  My guess was that after burst – when the payload suddenly finds itself without support – the line up to the balloon found its way behind the camera which it then removed as the balloon remnants pulled on it.  So, I can’t show you any images from the descent, but I can show you this shot of the Severn Estuary (processed to improve contrast) from the ascent:

15_20_48_shopped

In the chase car, I stopped at a point with a good view towards the landing area, so I could get the best (lowest) last position I could.  With the payload transmitting both LoRa and RTTY, I had my LCARS Pi receiving the former, and a Yaesu 817 with laptop PC receiving the latter.  With no images, the LoRa side dropped to sending telemetry only, which was handy as I was able to receive a lot of packets as the balloon descended. Overall LoRa seemed to be much more reliable from the car than RTTY did, despite the much higher data rate, and I now would be quite happy to chase a balloon transmitting high bandwidth LoRa and nothing else.

With the final position logged, I carefully tapped that into the car sat nav and then drove off to get the payload back.  10 minutes later I remembered that I’d coded exactly that function into my LCARS program!  2 screen-taps later, I had on-screen navigation (via Navit); I would also have had voice navigation but I hadn’t connected a speaker yet.

Both Navit and the car sat nav took me to a hill with the payload about 300 metres away.  I waited for another HABber to arrive – his first time chasing – and meantime I updated the other enthusiasts online, and took some photographs of the scenery; Shropshire is very pretty.

P1110661

Once Andy arrived, we walked down to the payload, watched (as often the case) by the local populace:

Ewe Looking At Me ??

As expected, the camera was missing, so if anyone wants a free Sony Pi camera, I can give you a 5-mile radius area to search.

P1110664

You don’t need CSI to see what went wrong here …

A lot of the balloon was still attached, which helps to explain how the camera was forcibly removed:

P1110665

So, a nice flight and recovery.  The Sony camera worked well; 868 LoRa worked well; the LCARS chase car tracker worked well.  Next time, more duct tape!

Posted in Weather Balloon | 4 Comments

Birthday Balloon

This was my second test flight of my 868MHz LoRa fast SSDV (Slow Scan Digital Video) software, to celebrate my 58th flight and 56th birthday.

Fixes

I made some changes to fix some issues with the previous test flight:

  • Set RTTY baud rate to 300 to prevent RTTY Tx during LoRa Rx period
  • New MTX2 programming code
  • Replace the UBX GPS code with NMEA code

The RTTY overrun was due to accidentally leaving the tracker at to 50 baud after a brief test.  The timing had been set using 300 baud RTTY (ensuring that the RTTY sentence had finished before the LoRa uplink slot), so when set to 50 baud the RTTY was still sending when the tracker was trying to listen on the LoRa frequency.  Although the frequencies are very different, this still slightly deafened the LoRa receiver and meant that only 12 messages were uploaded during that flight.

When the Pi starts up, the MTX2 radio transmitter is programmed to the configured frequency, and this process failed under some circumstances (depending on Pi operating system version and PITS version).  This was resolved and extensively tested.

During the previous flight, the payload went silent for long periods (1 minute or more) a few times, as the new GPS UBX code failed to get an updated time and position.  I traced this to some very slow responses to UBX requests via I2C, but didn’t have time to resolve the issue so I reverted to tried and tested NMEA code instead.

Additions

I also made some changes to the SSDV code, storing telemetry in the JPEG file comment field, by using the EXIV2 program.  This information is then available (via EXIV2) to the image processing script which can then overlay the downloaded image with on-screen text and/or graphics.  I added such a script using ImageMagick for the rendering.

Payload

I re-used the same payload as my previous test flight – a Pi A+, PITS+, LoRa board with single 868MHz module, Pi camera and 4 (fresh!) AA batteries.

The 868MHz antenna was below the payload with a 434MHz stubby antenna above (not an ideal position, but usable, and avoids compromising the 868MHz antenna).

Total weight including 18″ Spherachute and cord is less than 250g.  Ascent rate was targetted at 4.5m/s with an expected burst altitude of 31-32km using a 350g Hwoyee balloon filled with hydrogen.

Flight

The launch was easy enough, with very little wind (good, as I was alone).  There was some thick and fairly low cloud cover, and once through that the payload mostly sent some fairly boring images of nothing but blue sky and white cloud.  After a while though it was high enough to see some better weather and so we started to see some better images:

Note the overlay with telemetry along the bottom (altitude, latitude, longitude and UTC time), plus an altitude graphic with the balloon on a translucent background.

As the flight approached peak altitude, the pictures improved markedly, with this probably being the best one.  For comparison, I’ve inserted a live image from my very first Pi flight, at the same scale in pixels.  Roughly, the new image has 10 times the number of pixels, and took about 1/10th of the time to transmit.

For this flight there were 2 other gateways set up by other HAB enthusiasts, as well as my too.  Even with this limited coverage we still lost very, very few packets.  I had my Python script running to check for missing packets, and creating uplink messages to request repeats of those packets.  Throughout the flight 35 such messages were uplinked to the flight, which is 3 times more than last time, but still I noticed that the uplink stopped working before the downlink stopped, so this is something to try and improve for next time.

With 3-4 gateways running we again saw an issue with SSDV uploads timing out.  I’d seen this before when running 3 gateways at my location, and assumed my internet connection was the cause, but now we were seeing the same thing with 3 gateways at 3 different locations.  Phil Heron checked the server and saw that it was, at times, struggling to keep up, so that’s something to look at for next time.

The balloon burst at an altitude of over 32km, and produced this image during descent (note, no missing packets which is impressive for the first image during descent):

Recovery

Since the flight was mainly about testing the radio side, I stayed at home checking the radio communications, aiming and swapping aerials, until the flight had descended beyond my range.  I then prepared the chase car and checked the final descent positions and landing predictions.  The landing area was just south of Avebury, near Cherhill White Horse, and about 1 mile from the nearest road.  From the Ordnance Survey mapping I could see that the area was hilly and that unless the payload happened to land on top of a hill then I was unlikely to receive a signal from the road.  I made sure to pack walking boots, backpack and mobile tracking gear as this wasn’t going to be a quick and easy recovery!

The landing area was about 90 minutes drive from home, and when I got there I set up a rooftop aerial and drove along the nearest road hoping to hear a signal from the payload.  Nothing.  As expected the area was hilly and I could see a bridleway up to a monument at the top of a hill, so I parked up, packed my backpack, and walked up the hill with the radio on, listening for the payload.

As I got near the top, I had a choice of taking the path up to the monument, or a short walk across a field to a ridge overlooking the valley the other side of the hill.  That sounded like a better (easier!) bet, especially as I thought the payload would be in that valley.  Sure enough, as I got closer, the radio burst into life with that familiar RTTY sound.  I sat down to get the laptop set up, and the signal almost disappeared – it really made a huge difference how high the aerial was.  So, with laptop and radio on the ground, I held the aerial up to get a decoded position.

Unsurprisingly then, the payload position turned out to be in the valley below:

listening

I then had a choice of a direct route down a very steep hill (see those contour lines!) or a more leisurely, slightly longer and rather safer walk across the ridge and down a more gentle slope:

choice

On the way I caught my first glimpse of the payload below (parachute on left; payload on right):

25380800024_a640c33646_k

So in the end, not a difficult recovery if we ignore the steep climbs!

For more photos, click this image:

26013649245_87bafab256_h

Posted in Weather Balloon | Leave a comment

Fast HAB Imaging

It’s now quite common for high altitude balloon flights to send down live images during the flight, as well as the usual telemetry.  However data rates from balloons are rather low, so each image can take several minutes to send even for rather low resolutions.

"It's currently a problem of access to gigabits through punybaud"

Maximum data rates are a function of several things – emitted power, receiver sensitivity, path loss, aerial gain, duty cycle (proportion of time that the transmitter is active), bandwidth (amount of the radio spectrum used by the signal) and the type of modulation – and these items have legal and practical limits.

For UK flights we use licence-exempt radio transmitters and so operate within the limits defined by IR2030,  For almost all flights, operators choose the band from 434.04-434.79MHz, because this range allows for continuous transmission (100% duty cycle) and is shared with the amateur radio 70cm band, meaning that receiving equipment is readily available.  Maximum power in this band is 10mW e.r.p. (effective radiated power), and the modulation scheme most often used is RTTY.  To allow reception by ham radios, the modulation has to fit within a frequency range that those radios will pass, which is about 4kHz.  Historically radio transmitters drift in frequency considerably, so if the modulation uses a large proportion of this bandwidth then receivers will need to re-tune almost continuously.  With this, and the increased packet loss at higher baud rates, 600 baud is a practical limit for transmission speeds with RTTY, and most flights with live imaging settle for 300 baud.  With modern temperature-compensated radio transmitters this could probably be pushed to 1200 baud with fair success.

LoRa Modulation

Anyone who follows this blog will be aware that I’ve been experimenting with LoRa modules, which use their own (patented, sadly) modulation scheme.  However LoRa modules are cheap and work well, so until something else comes along that is as good and open-source, then I’ll continue flying them.

LoRa chips offer bandwidths up to 250kHz, which is way beyond the practical limit with most ham radio receivers and indeed beyond that allowed in the 434MHz band that I mentioned.  Higher bandwidths can allow for higher throughput, though the receiver will then see more noise (as it has a wider frequency range to listen to) so the signal-to-noise ratio is worsened, meaning that range is compromised.

Some bands around 434MHz do allow for wider bandwidths, but only at limited duty cycles of 10% or less.  There’s not much point in using a bandwidth 10 times wider if you can only transmit for 10% of the time, as the throughput is back where you started!  However there’s a section of the 868MHz range that allows for both high bandwidth (300kHz) and continuous operation.  The downside (there is always a downside) is that transmitted power is even lower, at 5mW ERP.

LoRa devices operating within the 434MHz band mentioned above can use up to 20.8kHz bandwidth, giving a data rate equivalent to about 1400 baud RTTY.  Going from 20.8KHz to 250kHz gives nearly 17,000 baud equivalent.  This is still pathetically slow compared with 3G or home broadband, but it’s much, much faster than the 300 baud that we’re used to.  If, of course, it works.

Need For Speed

Higher data rates mean that, for example, instead of taking 5 minutes for a low resolution (about 600 x 300 pixels) image, we can send a 1280×640 image in about 70 seconds.  Here’s an example image being transferred with a bandwidth of 250kHz:

Packet Loss

As discussed, wideband modulation reduces the SNR seen by the receiver, so range is limited compared to narrowband modulation.  The lower tranmission power (5mW vs 10mW) makes SNR a little worse, as does the path loss of 868MHz vs 434MHz.  The end result will be increased packets loss as the signal level drops, through the balloon payload swinging around and as it gets further away.

We can mitigate these factors somewhat by using a Yagi aerial at the receiver and a filtered pre-amplifier.  Even so, and with error correction in the image packets, some packets will be lost resulting in blocks missing from the received images.  What can we do if that happens?

Play It Again

Another nice feature of LoRa modules is that they are transceivers, so we have the option of sending messages back up to the payload from the ground.  So, why not have a ground station take note of any missing packets, and then send a message to the payload asking for those packets to be sent again?  All we need is a way of spotting missing packets, and a scheme (e.g. TDM) that provides an uplink slot where the payload stops transmitting and starts listening for a short time.

It’s not difficult for a listening station (LoRa gateway) to build a list of missing image packets – it just needs to take note of which packets have been received.  However there may be several listening stations – this is a key feature of the UKHAS listening network – and there’s no point asking for a packet to be re-sent if it was already received by another station.  So, this logic needs to be done centrally.  With this in mind I spoke to Philip Heron who invented the SSDV (Slow Scan Digital Video) standard, wrote the encoding and decoding software that converts between JPEG and SSDV, and wrote the code on the SSDV server that accepts packets from listening stations and combines them into JPEG files which it displays on web pages.  Philip very kindly wrote a web API for the server, providing functions which a LoRa gateway can use to produce a list of missing image packets.

I had already written code in my LoRa gateway to produce this list locally, so I removed most of that code and instead created some new code that queries the SSDV server and produces a list of missing packets for the latest 2 SSDV images, for a particular payload.  I chose 2 because if the payload has recently started transmitting a new image, we need to know if it has to go back and re-transmit any missing packets from the previous image.

Test flight will happen when the weather is a bit better!

Posted in Weather Balloon | 2 Comments

Portable LoRa Gateway

This is a packaged version of my LoRa gateway, for use when chasing high altitude balloons.  Based a a Pi V2 and official Pi screen, it currently features:

  • Receipt and upload of LoRa telemetry messages to http://tracker.habhub.org/
  • Receipt and upload of LoRa SSDV imagery to ssdv.habhub.org
  • Local storage of telemetry log and SSDV images
  • Chase car position upload to http://tracker.habhub.org/
  • LCARS (Star Trek) user interface with display of balloon position and images
  • WiFi connection to internet (e.g. via MiFi or mobile phone WiFi hotspot)
  • Approx 24 hours of run time from powerbank

Future plans include display of balloon position on a map, and navigation to the balloon position include voice guidance.

P1110312

The parts are all readily available:

  • Raspberry Pi V2 (B+ or A+ will also work, but the extra speed is useful)
  • Raspberry Pi touchscreen display
  • Hofbauer XtraBag 200 Case, Black
  • LoRa board for the Pi
  • Powerbank
  • 2 Micro USB cables
  • Double-sided tape
  • Door trim
  • SMA plug-socket cable
  • 70cm aerial

There are instructions here for building and installing the LoRa gateway.  I will post again shortly with instructions on installing the LCARS interface.

I used a Dremel with cutting tool to cut a hole in the case, then stuck the display down with double-sided tape.  A length of rubber door insulation was then cut and placed around the display to provide some protection.  The powerbank was held down with Velcro, and connected to the Pi and display using short micro USB cables.  Finally, a short SMA cable was used so that aerials can be connected externally.

P1110304

The Pi is set up to auto-start the LoRa gateway and LCARS program.  These two programs talk via a socket so that the LCARS UI can display the current payload position:

P1110314

Posted in Weather Balloon | 2 Comments

Astro Pi Flight – Update

I’ve made some progress on my “tweet uplink” software, and now all stages in the process are fully automated except for a required manual approval step, in case anyone tries to spam the flight!

The key new element is a Windows program that lists incoming tweets and offers Accept and Reject options for each tweet that mentions a particular hashtag, for example:

tweet

The tweets are received via a simple Python script using the tweepy library, which saves each as a separate file which the Windows program then sees and displays:

incoming

Each accepted tweet is then moved to an accepted list (the tweet file is renamed from <Twitter ID>.tweet to <Twitter ID>.accepted):

accepted

The next step is a bit more complex.  To make the most of the available radio bandwidth, tweets are combined together into radio packets.  So whenever there are enough tweets to combine, or the uplink queue is empty, the program seeks to find the best combination of tweets to join together into a single radio packet (max 255 bytes).  These packets are then placed in a queue on a Raspberry Pi running my LoRa gateway:

queue

Here we just have a single tweet, because only one was generated in the above example.

Periodically, the balloon tracker stops transmitting down to the ground, and starts listening for an uplink from the gateway.  If the queue has at least one entry then the gateway program will send one entry to the balloon.  In turn, the balloon tracker will receive the packet and save it as a file.  Meanwhile, a small Python script will see that file and start displaying it on the Astro Pi LED.

The gateway needs to know if the uplink was received OK or not, so the tracker includes a “last message ID received” value in the telemetry packets that it sends to the ground:

downlink

The gateway then parses this information and removes the matching message from the queue (renames <ID>.sms as <ID>.ack).  The final step is for the Windows program to then remove the message from its list of queued messages and add it to the list of acknowledged messages:

acked

Posted in Weather Balloon | Leave a comment

Tweeting Above The Clouds

Following my recent successful test of balloon-to-balloon communications, I had the idea of uploading messages from the ground to a balloon (via LoRa radio), and then have those messages displayed on the LED matrix of an “Astro Pi” Sense HAT, as will be used by Tim Peake during his stay on the International Space Station.

You may well be asking who is likely to see those messages, so here’s the plan:

  • Launch a weather balloon before Tim flies to the ISS on Soyuz TMA-19M
  • Encourage people to send messages to Tim Peake via tweets to a specific hashtag
  • Those tweets will be automatically uploaded to the balloon via a radio link
  • Tweets will then be scrolled on the Astro Pi LED matrix
  • A video camera which will record the entire flight and the scrolling messages
  • Download sense HAT data during the flight
  • After the flight is recovered, selected camera footage will be uploaded to YouTube and sent to Tim.

There’s nothing particularly complicated in the above, but there are quite a few steps involved to make it work.

Astro Pi + Pi In The Sky + LoRa Board

For the balloon tracker to perform the above tasks, it needs an Astro Pi of course, plus a Pi In The Sky board for GPS and power, plus a LoRa board to allow for uploads from the ground.  The first thing to do then was check to see if there are any I/O conflicts between the above.

The only conflicts were to do with one of the 2 LoRa modules on the LoRa board.  Since we only need 1 LoRa module, we can just put that in the non-conflicting position (CE1).

So, I built a stack with a Pi B+ on the bottom, then a Pi In The Sky (PITS) board, LoRa board and finally an Astro Pi board which, of course, has to be on top otherwise the LED matrix won’t be visible!

astro2

Reading Tweets

The first part of the sequence is to search Twitter for messages to upload, and for this Iwrite a short Python script using the Tweepy library.  The following function and main code show the process:

def SearchHashtag(HashTag, LastID, Count):
  c = tweepy.Cursor(api.search, since_id=LastID, q=HashTag).items(Count)
  for tweet in c:
    text = tweet.text.encode('ascii',errors='ignore').decode("utf-8")
    print(str(tweet.id) + " - @" + tweet.user.screen_name + ": " + text)
    if tweet.id > LastID:
      LastID = tweet.id
  return LastID

 LastID = 0
 Count = 10
 HashTag = '#AstroPiTest'
 while 1:
   LastID = SearchHashtag(HashTag, LastID, Count)
   print ("LastID = ", LastID)
   time.sleep(5)

The complete script reads each matching tweet:

astro1

and creates a separate text file for each such tweet:

@daveake: Just testing for a project ....

For the actual flight then will be more filtering, both programmatic and human, to ensure that only real/polite/sane messages are uplinked!

Uplink

For the radio uplink I have modified my LoRa Gateway, which is normally tasked with receiving LoRa transmissions from balloons and then uploading the data (telemetry and/or images) to a web server.  For this flight though we need it to be able to send messages up to the balloon.  That’s a straightforward task, using GPS timing to decide when the balloon can transmit and the gateway should listen, and then when the gateway can transmit and the balloon should listen.  For testing I’ve set a short period each minute for the uploads, but this may change for the flight (to allow more messages to be uploaded).

The gateway has to monitor a folder, looking for messages to upload.  Those messages are produced by the Python script mentioned earlier, so the gateway just has to read the messages, and send them to the balloon.  Sometimes tweets may come in faster than they can be uploaded, so the code will need to be able to cope with that.

Here’s a screenshot of the gateway uploading the above message:

astro3

Receiving Messages At The Tracker

For this I modified the PITS software so that it can accept and process these uplinked messages.  To keep the PITS changes simple, all it does is receive the message:

astro4

and then create a small file containing the text to display:

Just testing for a project ....

 

Displaying The Message

This is done by a simple Python script that uses the Astro Pi library.  The following snippet shows how it works:

def process_file(file):
  print ("File found: ", file)
  f = open(file, 'rt')
  line = f.read()
  f.close()
  os.remove(file)

  sense = SenseHat()
  sense.show_message(line)
 
while 1:
  for file in os.listdir('.'):
    if fnmatch.fnmatch(file, '*.sms'):
      process_file(file)
      time.sleep(1)
  time.sleep(1)

 

The Result

 

 

Posted in Weather Balloon | Leave a comment

LoRa LoRa Packets

One of the reasons for me experimenting with LoRa modules was that they are transceivers and should allow uplinks from the ground to a balloon, or communications between balloons.  Uplinks I will try on another flight, but for now I’m working on inter-balloon communications.  The eventual aim for this is to fly a series of balloons across Europe, with data passing from balloon to balloon, thus considerably extending the radio range which would otherwise be limited by the Earth’s curvature:

LOS

On previous flights my LoRa trackers have transmitted continuously, but this obviously won’t work if they are meant to listen to other trackers.  I opted for a very simple and widely used technique called TDMA (Time Division Multiple Access), with all trackers taking turns to transmit on the same frequency.  Timing was taken from the GPS which every tracker has anyway.  Time slots are static and written into the code for each tracker; during non-Tx periods, each tracker listens for packets from other trackers.

I set the frame time to 20 seconds, which conveniently divides exactly into 1 minute, making it much simpler to mentally convert from a time to a slot number.  Within those 20 seconds there are 10 usable 1-second slots and 10 1-second guard periods (to prevent transmissions from overlapping).  The frame begins on the minute, and there are 3 frames per minute.

I programmed 3 trackers for the flights, with each tracker having 1 slot to transmit its own position, and 2 slots to re-transmit packets from the other 2 trackers.  So together they can use up to 9 slots (3 direct, 6 repeats) out of the 10 available.

Slots

Here’s an SDR screenshot showing packets being transmitted every 2 seconds; the packets occupy a bit less than 1 second so there is slightly more than 1 second between packets:

Image1

On my previous LoRa flights the packets have taken rather more than 1 second.  This time I opted for a wider bandwidth (62.5kHz instead of my usual 20.8kHz) to reduce the packet time to about 1/3rd.

There’s another reason for going to 62.5kHz.  The LoRa modules that I’ve used have been offset from each other up to 4kHz which, if using a 20.8kHz bandwidth, is enough to stop packets being received.  Since the allowed offset is a proportion of the bandwidth, then using a wider bandwidth reduces or eliminates the problem.

The downside of using any bandwidth > 20.8kHz, on the 434MHz band in the UK at least, is that transmissions must be limited to a duty cycle of 10%; at least it is according to my reading of IR2030.  I measured the Tx time of my tracker’s transmissions and, with 3 slots in 20 seconds, it works out at a duty cycle of just over 8%, so comfortably the right side of legality.

Another downside is that the available power is now spread across a wider bandwidth, so reducing the S/N ratio at the receiver, and thus the link budget.  Whether this is an issue or not would become clear during the flights.

For the flights, I programmed 3 trackers provided by Anthony Stirk.  Each has an ATmega 328P, UBlox MAX M8Q, HopeRF RFM98W,  and cutdown circuitry (not used this time).

tracker

Each ran the same code but with different settings for payload ID, primary slot number, and secondary (repeater) slot numbers.  Each went into a Hobbycraft foam egg, total weight with a plastic Estes 18″ parachute was about 70 grams.

LORA1 went up with a 500g balloon.  I then watched the incoming packets and saw that is was still happily repeating LORA2/3.  At about 4km altitude the first of the other ground stations (Phil Crump‘s LoRa gateway at his WebSDR site) started to receive LORA1 directly, and LORA2/3 indirectly; in fact the first packet received there was LORA2 –> LORA1 –> Phil’s gateway:

11:52:31 $$LORA2,161,11:52:27,51.95024,-2.54456,00141,0,0,12*C46E
11:52:35 $$LORA3,161,11:52:33,51.95029,-2.54451,00142,0,0,11*9985
11:52:41 $$LORA1,164,11:52:41,51.96063,-2.57614,03953,7,0,12*99C2

Next up was LORA2 under a 350g balloon.  Very impressively, this was received by Phil’s gateway when at just over 1.1km altitude, which is rather below his radio horizon:

12:23:47 $$LORA2,255,12:23:47,51.94375,-2.53650,01190,1,0,12*2AA3

I think that pretty much puts to bed any worries about LoRa range at this bandwidth.

I then checked my LCARS LoRa receiver, which was happily showing the position of both airborne trackers as well as LORA3 (still on the bench):

P1110168

Finally, I launched LORA3, again under a 350g balloon.  The planned burst altitude for this one was about 28.5km but, as sometimes Chinese latex completely ignores specifications and goes rather higher.  Usually that’s just an extra 2km or so, but this time it was 10km higher than calculated!

lora3_altitude

After the flight I received several receiver log files, and so far I’ve only had time to do some analysis on Phil’s.  From that file, the following chart shows the altitude plots for LORA1 and 2 (100 on the chart = max altitude for LORA1) and fraction of packets received (10 on the chart = 100%) directly from LORA1, or indirectly via LORA2:

Image7

During the portion of the flight where both LORA1 and LORA2 were high enough to be in range of Phil’s gateway, 82% of LORA1’s packets were received directly, and 58% were received indirectly via LORA2.

LORA1 was heading for a field as it came into land.  Now, normally the actual landing position isn’t known because the range of a landed tracker is typically about 1 mile.  There have been exceptions, where either the chase car is close or the payload lands in a tree or on the side of a hill, but for the vast majority of flights the actual landing position is not known till later when the chase car arrives (and then only if the car receiver is uploading via GSM).  One of my aims, or at least hopes, for these flights was for one or both of the still-flying trackers to continue to repeat packets from the remaining tracker after it has landed.

So as LORA1 approached that field, all eyes were on the telemetry to see “how low can we go?”.  As the flight gets lower, static receiving stations start to drop out because the tracker is below their line-of-sight, till finally the closest station gets the last packet when the flight altitude is at maybe 500 metres or so (LORA3 for example was lost at 998m).  Of course this time we also had 2 mobile repeater stations in the form of LORA2 and LORA2, in good position to relay LORA1’s telemetry.  Here’s part of the conversation on our IRC channel which, to me at least, felt like waiting for Apollo 13 to come out of radio blackout!

[15:14] <daveake> 861 repeated 
[15:15] <daveake> 639m repeated 
[15:15] <daveake> suspense is killing me lol
[15:17] <daveake> 344m repeated 
[15:17] <fsphil> .... 
[15:17] <Upu> go on :) 
[15:17] <fsphil> *tension* 
[15:17] Action: fsphil puts on dramatic music 
[15:17] <Upu> jcoxon - LORA1 is about to get repeated
              on the ground from a flying balloon 
[15:17] <daveake> this is like watching apollo 13 re-enter 
[15:17] <daveake> we hope 
[15:17] <daveake> 146m 
[15:17] <Upu> haha 
[15:17] <Upu> nice 
[15:17] <Laurenceb__> woot 
[15:18] <jcoxon> Upu oooo thats amazing 
[15:18] <Upu> nice one daveake 
[15:18] <Upu> have a beer :) 
[15:18] <craag> 80 
[15:18] <daveake> 80m WOOOO 
[15:18] <fsphil> lol 
[15:18] <craag> next one will be ground 
[15:18] <craag> 46!!! 
[15:18] <Laurenceb__> yes 
[15:18] <daveake> Exccellent :) 
[15:20] <craag> and another to confirm! awesome work 
[15:20] <jcoxon> the dream of hunting payloads with other payloads
[15:20] <fsphil> hah, that was definitly on the ground 
[15:20] <DL1SGP> Lora1 still being rxed 
[15:20] <craag> getting repeated by both too it seems 
[15:21] <daveake> hah 
[15:21] <daveake> Wow, this is great :) 
[15:21] <daveake> Can anyone confirm defintely repeated by both ? 
[15:22] <craag> I've received two copies of the same sentence... 
[15:22] <dbrooke> me too 
[15:22] <daveake> excellent 

And just to prove it, here’s a screenshot from the tracking map, showing a large list of receivers all receiving LORA1 after the latter has landed:

lora1_landed

Back to Phil’s gateway’s log, here’s the section before and after LORA1 (altitude in red) lands.  The direct packets (yellow) stop before landing, but the repeated packets (blue) continue until shortly before LORA2 lands (green):

Image8

 

Not shown here, but LORA3 also repeated the landing position.  An excellent result.  And even better, the same happened when LORA2 landed – it was repeated by LORA3.

Well, I say “landed”, but LORA2 managed to stop on the edge of an office roof, where it currently remains until I can organise recovery:

LORA3 landed without airborne support of course, but was easily picked up from the chase car from over a mile away – a similar result to that which I’m used to with RTTY.

LORA1 however is missing – no signal and no payload at the landing position.  Hopefully whoever found it will get in touch.

UPDATE 1: LORA2 now recovered.  The payload was exactly where the GPS reported (see satellite image above), with the line/chute/balloon dangling down to about head height.  Thanks to helpful people at the site it was recovered in minutes.

UPDATE 2: LORA1 now recovered.  I received a phone call several weeks after the flight, from the landowner who found the payload in a field.  I think a sheep must have been holding it hostage when I looked for it, as the aerial had obviously been chewed!

Posted in Weather Balloon | 1 Comment

Raspberry Pi “Skycademy”

If you …

  1. Are a teacher or youth leader (e.g. scout group)
  2. Are interested in applications for the Raspberry Pi
  3. Would love to help your class or group send a weather balloon into the stratosphere and take live images throughout

… then read on.

skycademy

In August, the Raspberry Pi Foundation are running a “Skycademy” aimed squarely at people like you.  Unlike other Picademys this will not focus on programming, but instead will cover all the vital elements you need to know in order to safely and successfully run your own near-space project.

The course will be run over 2.5 days:

  1. Overview of high altitude ballooning, with practical sessions (e.g. building your payload, setting up the balloon tracker and ground receiver, running flight predictions)
  2. Launch day (1 flight per 6 attendees)
  3. (half day) share photos and experiences from your flights
There is no single part of High altitude ballooning that is particularly complex, however it does cover a lot of separate activities and it’s vital that anyone launching a balloon has an understanding of them all.  Too many flights are lost or only found through luck, typically because the launchers concentrated on some aspects of the subject and did not think about others.  The primary aim of the course is to make sure that you have a good basic understanding of everything that you need to make sure your flight has the best chance of success.

So, if you want to inspire your kids to be engineers or scientists, or just open their eyes to how, with a small budget and a lot of duct tape, they can send their own payload up into the stratosphere, then apply here, and read more on the Raspberry Pi blog.

Applications for #skycademy close on Friday 10th July so hurry up!

 

 

Posted in Weather Balloon | 2 Comments