Tag Archives: GPS tracker

Raspberry Pi Pico balloon tracker

Post Syndicated from Ashley Whittaker original https://www.raspberrypi.org/blog/raspberry-pi-pico-balloon-tracker/

Dave Akerman of High Altitude Ballooning came up with a stratospherically cool application for Raspberry Pi Pico. In this guest blog, he shows you how to build and code a weather balloon tracker.

Balloon tracking

My main hobby is flying weather balloons, using GPS/radio trackers to relay their position to the ground, so they can be tracked and hopefully recovered. Trackers minimally consist of a GPS receiver feeding the current position to a small computer, which in turn controls a radio transmitter to send that position to the ground. That position is then fed to a live map to aid chasing and recovering the flight.

system-1024x813-500x396
How it all works

This essential role of the tracker computer is thus a simple one, and those making their own trackers can choose from a variety of microcontrollers chips and boards, for example Arduino boards, PIC microcontrollers or the BBC Microbit. Anything with a modest amount of code memory, data memory, processor power and I/O (serial, SPI etc depending on choice of GPS and radio) will do. A popular choice is Raspberry Pi, which, whilst a sledgehammer to crack a nut for tracking, does make it easy to add a camera.

Raspberry Pi Pico

When I see a new type of processor board, I feel duty bound to make it into a balloon tracker, so when I was asked to help test the new Raspberry Pi Pico, doing so was my first thought. It has plenty of I/O – SPI ports, I2C and serial all available – plus a unique ability (not that I need it for now) to add extra peripherals using the programmable PIO modules, so there was no doubt that it would be very usable. Also, having much more memory than typical microcontrollers, it offers the ability to add functions that would normally need a full Raspberry Pi board – for example on-board landing prediction. More on that later.

Tracker components

So a basic tracker has a GPS receiver and radio transmitter. To connect these to the Raspberry Pi Pico, I used a prototyping board where I mounted a UBlox GPS receiver, LoRa radio transmitter, and sockets for the Pico itself.

I don’t use breadboards as they are prone to intermittent connections that then waste programming time chasing a “bug” that’s actually a hardware problem. Besides, trackers need to be robust so I would need to solder one together eventually anyway.

Pico top, GPS bottom-left; LoRa bottom-right

The particular UBlox GPS module I had handy only has a serial port brought out, so I couldn’t use I2C. No matter because, unlike most Arduino boards, the Raspberry Pi Pico isn’t limited to a single serial port.

The LoRa module connects via SPI and a single GPIO pin which the module uses to send its status (e.g. packet sent – ready to send next packet) to the Raspberry Pi Pico.

Finally, with the tracker working, I added an I2C environmental sensor to the board via a pin header, so the sensor can be placed in free air outside the tracker.

Finally, with the tracker working, I added an I2C environmental sensor to the board via a pin header, so the sensor can be placed in free air outside the tracker.

Development setup

I decided to use C for my tracker rather than Python, for a variety of reasons. The main one is that I have plenty of existing C tracker code to work from, for Arduino and Raspberry Pi, but not so much Python. Secondly, I figured that most of the testers would be using Python so there might be more of a need to test the C toolchain.

The easiest route to getting the C/C++ toolchain working is to install on a Raspberry Pi 4. I couldn’t quite get the VSCode integration working (finger trouble I think) but anyway I’m quite happy to code with an editor and separate build window. So what I ended up with was Notepadd++ on my Windows PC to edit the code, with the source on a Raspberry Pi 4. I then had an ssh window open to run the compile/link steps, and a separate one running the debugger. The debugger downloads the binary to the Raspberry Pi Pico via the latter’s debug port.

For regular debug output from the program I connected a Raspberry Pi Pico serial port to an FTDI USB Serial TTL adapter connected back to my PC – see the image below.

At some point I’ll revisit this setup. First, it’s now possible to printf to a virtual USB serial port, so that frees up that Raspberry Pi Pico serial port. Secondly, I need to get that VSCode integration working.

Tracker code

My Raspberry Pi and Arduino tracker programs work slightly differently. On the Raspberry Pi, to separate the code for the different functions (GPS, radio, sensors etc) I use a separate thread for each. That allows for example a new packet to be sent to the radio transmitter without delay, even if a slow operation is running concurrently elsewhere.

On the Arduino, with no threads available, the code is still split into separate modules but each one is coded to run quickly without waiting in a loop for a peripheral to respond. For example some temperature sensors can take a second or so to take a measurement, and it’s vital not to sit in a loop waiting for the result.

The C toolchain for Raspberry Pi Pico doesn’t, by default, support threaded code unfortunately. Rather than rebuild it with support added, I opted for the approach I use with Arduino. So the main code starts with initialising each module individually, and then sits in a tight loop calling each module once per loop. It’s then up to each module to return control swiftly so that the loop keeps running quickly and no module is kept waiting for long.

Code modules

The GPS code uses a serial port to receive NMEA data from the GPS. NMEA is the standard ASCII protocol used by pretty much every GPS module that exists, and includes the current date, time, latitude, longitude, altitude and other data. All we need to do is confirm that the data is valid, then read and store these key values. The other important function is to ensure that the GPS module is in the correct “flight mode” so that it works at high altitude – without this then it will stop providing new positions about 18km altitude.

View NMEA Data Log

The LoRa radio code checks to see when the module is not transmitting, then builds a new telemetry message containing the above GPS data plus the name of the balloon, any other sensor data, and the landing prediction (see later).

This message is passed to the LoRa chip via SPI, then the chip switches on its radio and modulates the radio signal with the telemetry data. Once the message has been sent then the chip switches on its DIO0 output which is connected to the Raspberry Pi Pico so it knows when it can send another message.

All messages are received on the ground (in this case by a Pi LoRa receiver) and then uploaded to an internet database that in turn drives a live Google map (see image below).

Sensors

Usefully for balloon trackers, the Raspberry Pi Pico can be powered directly from battery via an on-board buck-boost converter.

The input voltage connects through a potential divider to an analog sense input (ADC3) to allow for easy measurement of the battery voltage. Note that the ADC reference voltage is the 3.3V rail, which is noisy especially when used to power external devices such as the GPS and LoRa both of which have rather spiky power consumption requirements, so the code averages out many measurements.

An alternative would be to add a precise reference voltage to the ADC but I went for the zero cost software option.

The board temperature can also be measured, this time using ADC4. That’s less useful though for a tracker than an external temperature measurement, so I added a BME280 device for that. The Raspberry Pi Pico samples include code for the BME connected via SPI, but I chose I2C so I needed to replace the SPI calls with I2C calls. Pretty easy. The BME280 returns pressure – probably the most interesting environmental measurement for a balloon tracker – and humidity too.

Landing prediction

So far, everything I’ve done could also be done on a basic AVR chip e.g. the Arduino Mini Pro, with some spare room. However, one very useful extra is to add a prediction of the landing point.

We use online flight prediction prior to launch, to determine roughly where the balloon will land (within a few miles) so we know it’s safe to launch without landing near a city for example. This uses a global wind prediction database plus some flight parameters (e.g. ascent rate and burst altitude) to predict the path of the balloon from launch to landing. It can be very accurate if those parameters are followed through on the flight itself.

Of course the actual flight never quite follows the plan – for example the launch might be later than planned, and in changing wind conditions that itself can move the landing point by miles. So it’s useful to have a live prediction during that flight, and indeed we have that, using the same wind database.

However, since it’s online, and 3G/4G can be patchy when chasing a balloon, it’s useful to have an independent landing prediction. This can be done in the tracker itself, by storing the wind speed and direction (deduced from GPS positions) on the way up, measuring the descent rate after burst, applying that to an atmospheric density model to plot the future descent rate to the ground, and then calculating the effect of the wind during descent and finally producing a landing position.

Typical Arduino boards don’t have enough memory to store the measured wind data, but the Raspberry Pi Pico has more than enough. I ported my existing code which:

  1. During ascent, it splits the vertical range into 100 metres sections, into which it stores the latitude and longitude deltas as degrees per second.
  2. Every few seconds, it runs a prediction of the landing position based on the current position, the data in that array, and an estimated descent profile that uses a simple atmospheric model plus default values for payload weight and parachute effectiveness.
  3. During descent, the parachute effectiveness is measured, and the actual figure is used in the above calculation in (2).
  4. Calculates the time it will spend within each 100m section of air, then multiplies that by the stored wind speed to calculate the horizontal distance and direction it is expected to travel in that section.
  5. Adds all those sectional movements together, adds those to the current position, and produces the landing prediction.
  6. Sends that position down to the ground with the rest of the telemetry.

Phew. Now we know pretty much everything about how balloon trackers work. Thanks Dave! Also, if you want to go on your own near-space flight, check out High Altitude Ballooning.

The post Raspberry Pi Pico balloon tracker appeared first on Raspberry Pi.

Tracking the Brecon Beacons ultramarathon with a Raspberry Pi Zero

Post Syndicated from Helen Lynn original https://www.raspberrypi.org/blog/tracking-the-brecon-beacons-ultramarathon-with-a-raspberry-pi-zero/

On my holidays this year I enjoyed a walk in the Brecon Beacons. We set out nice and early, walked 22km through some of the best scenery in Britain, got a cup of tea from the snack van on the A470, and caught our bus home. “I enjoyed that walk,” I thought, “and I’d like to do one like it again.” What I DIDN’T think was, “I’d like to do that walk again, only I’d like it to be nearly three times as long, and it definitely ought to have about three times more ascent, or else why bother?”

Alan Peaty is a bit more hardcore than me, so, a couple of weekends ago, he set out on the Brecon Beacons 10 Peaks Ultramarathon: “10 peaks; 58 kilometres; 3000m of ascent; 24 hours”. He went with his friend Neil and a Raspberry Pi Zero in an eyecatching 3D-printed case.

A green 3D-printed case with a Raspberry Pi sticker on it, on a black backpack leaning against a cairn. In the background are a sunny mountain top, distant peaks, and a blue sky with white clouds.

“The brick”, nestling on a backpack, with sunlit Corn Du and Pen y Fan in the background

The Raspberry Pi Zero ensemble – lovingly known as the brick or, to give it its longer name, the Rosie IoT Brick or RIoT Brick – is equipped with a u-blox Neo-6 GPS module, and it also receives GPS tracking info from some smaller trackers built using ESP32 microcontrollers. The whole lot is powered by a “rather weighty” 20,000mAh battery pack. Both the Raspberry Pi and the ESP32s were equipped with “all manner of additional sensors” to track location, temperature, humidity, pressure, altitude, and light level readings along the route.

Charts showing temperature, humidity & pressure, altitude, and light levels along the route, together with a route map

Where the route crosses over itself is the most fervently appreciated snack van in Wales

Via LoRa and occasional 3G/4G from the many, many peaks along the route, all this data ends up on Amazon Web Services. AWS, among other things, hosts an informative website where family members were able to keep track of Alan’s progress along windswept ridges and up 1:2 gradients, presumably the better to appreciate their cups of tea and central heating. Here’s a big diagram of how the kit that completed the ultramarathon fits together; it’s full of arrows, dotted lines, and acronyms.

Alan, Neil, the brick, and the rest of their gear completed the event in an impressive 18 hours and one minute, for which they got a medal.

The brick, a small plastic box full of coloured jumper leads and other electronics; the lid of the box; and a medal consisting of the number 10 in large plastic characters on a green ribbon

Well earned

You can follow the adventures of this project, its antecedents, and the further evolutions that are doubtless to come, on the Rosie the Red Robot Twitter feed. And you can find everything to do with the project in this GitHub repository, so you can complete ultramarathons while weighed down with hefty power bricks and bristling with homemade tracking devices, too, if you like. Alan is raising money for Alzheimer’s Research UK with this event, and you can find his Brecon Beacons 10 Peaks JustGiving page here.

The post Tracking the Brecon Beacons ultramarathon with a Raspberry Pi Zero appeared first on Raspberry Pi.

Rosie the Countdown champion

Post Syndicated from Alex Bate original https://www.raspberrypi.org/blog/rosie-the-countdown-champion/

Beating the contestants at Countdown: is it cheating if you happen to know every word in the English dictionary?

Rosie plays Countdown

Allow your robots to join in the fun this Christmas with a round of Channel 4’s Countdown. https://www.rosietheredrobot.com/2017/12/tea-minus-30.html

Rosie the Red Robot

First, a little bit of backstory. Challenged by his eldest daughter to build a robot, technology-loving Alan got to work building Rosie.

I became (unusually) determined. I wanted to show her what can be done… and the how can be learnt later. After all, there is nothing more exciting and encouraging than seeing technology come alive. Move. Groove. Quite literally.

Originally, Rosie had a Raspberry Pi 3 brain controlling ultrasonic sensors and motors via Python. From there, she has evolved into something much grander, and Alan has documented her upgrades on the Rosie the Red Robot blog. Using GPS trackers and a Raspberry Pi camera module, she became Rosie Patrol, a rolling, walking, interactive bot; then, with further upgrades, the Tea Minus 30 project came to be. Which brings us back to Countdown.

T(ea) minus 30

In case it hasn’t been a big part of your life up until now, Countdown is one of the longest running televisions shows in history, and occupies a special place in British culture. Contestants take turns to fill a board with nine randomly selected vowels and consonants, before battling the Countdown clock to find the longest word they can in the space of 30 seconds.

The Countdown Clock

I’ve had quite a few requests to show just the Countdown clock for use in school activities/own games etc., so here it is! Enjoy! It’s a brand new version too, using the 2010 Office package.

There’s a numbers round involving arithmetic, too – but for now, we’re going to focus on letters and words, because that’s where Rosie’s skills shine.

Using an online resource, Alan created a dataset of the ten thousand most common English words.

Rosie the Red Robot Raspberry Pi

Many words, listed in order of common-ness. Alan wrote a Python script to order them alphabetically and by length

Next, Alan wrote a Python script to select nine letters at random, then search the word list to find all the words that could be spelled using only these letters. He used the randint function to select letters from a pre-loaded alphabet, and introduced a requirement to include at least two vowels among the nine letters.

Rosie the Red Robot Raspberry Pi

Words that match the available letters are displayed on the screen.

Rosie the Red Robot Raspberry Pi

Putting it all together

With the basic game-play working, it was time to bring the project to life. For this, Alan used Rosie’s camera module, along with optical character recognition (OCR) and text-to-speech capabilities.

Rosie the Red Robot Raspberry Pi

Alan writes, “Here’s a very amateurish drawing to brainstorm our idea. Let’s call it a design as it makes it sound like we know what we’re doing.”

Alan’s script has Rosie take a photo of the TV screen during the Countdown letters round, then perform OCR using the Google Cloud Vision API to detect the nine letters contestants have to work with. Next, Rosie runs Alan’s code to check the letters against the ten-thousand-word dataset, converts text to speech with Python gTTS, and finally speaks her highest-scoring word via omxplayer.

You can follow the adventures of Rosie the Red Robot on her blog, or follow her on Twitter. And if you’d like to build your own Rosie, Alan has provided code and tutorials for his projects too. Thanks, Alan!

The post Rosie the Countdown champion appeared first on Raspberry Pi.

MagPi 59: the Raspberry Pi PC Challenge

Post Syndicated from Lucy Hattersley original https://www.raspberrypi.org/blog/magpi-59/

Hey everyone, Lucy here! I’m standing in for Rob this month to introduce The MagPi 59, the latest edition of the official Raspberry Pi magazine.

The MagPi 59

Ever wondered whether a Pi could truly replace your home computer? Looking for inspiration for a Pi-powered project you can make and use in the sunshine? Interested in winning a Raspberry Pi that’s a true collector’s item?

Then we’ve got you covered in Issue 59, out in stores today!

The MagPi 59

Shiny and new

The Raspberry Pi PC challenge

This month’s feature is fascinating! We set the legendary Rob Zwetsloot a challenge: use no other computer but a Raspberry Pi for a week, and let us know how it goes – for science!

Is there anything you can’t do with a $35 computer? To find out, you just have to read the magazine.

12 summer projects

We’re bringing together some of the greatest outdoor projects for the Raspberry Pi in this MagPi issue. From a high-altitude balloon, to aerial photography, to bike computers and motorised skateboards, there’s plenty of bright ideas in The MagPi 59.

12 Summer Projects in The MagPi 59

Maybe your Pi will ripen in the sun?

The best of the rest in The MagPi 59

We’ve got a fantastic collection of community projects this month. Ingmar Stapel shows off Big Rob, his SatNav-guided robot, while Eric Page demonstrates his Dog Treat Dispenser. There are also interesting tutorials on building a GPS tracker, controlling a Raspberry Pi with an Android app and Bluetooth, and building an electronic wind chime with magnetometers.

You can even enter our give-away of 10 ultra-rare ‘Raspberry Pi 3 plus official case’ kits signed by none other than Eben Upton, co-creator of the Raspberry Pi. Win one and be the envy of the entire Raspberry Pi community!

Electronic Wind Chimes - MagPi 59

MAGNETS!

You can find The MagPi 59 in the UK right now, at WHSmith, Sainsbury’s, Asda, and Tesco. Copies will be arriving in US stores including Barnes & Noble and Micro Center very soon. You can also get a copy online from our store or via our Android or iOS app. And don’t forget: there’s always the free PDF as well.

Get reading, get making, and enjoy the new issue!

Rob isn’t here to add his signature Picard GIF, but we’ve sorted it for him. He loves a good pun, so he does! – Janina & Alex

The post MagPi 59: the Raspberry Pi PC Challenge appeared first on Raspberry Pi.

Apply for Skycademy 2016

Post Syndicated from Dan Fisher original https://www.raspberrypi.org/blog/apply-skycademy-2016/

Before humans took to the skies in metal tubes powered by jet engines, there was a gentler mode of transport that we used to conquer the skies: the humble balloon.

The Montgolfier brothers' first human-crewed balloon takes off at the Bois de Boulogne, Paris, on November 21, 1783

The Montgolfier brothers’ first human-crewed balloon takes off at the Bois de Boulogne, Paris, on November 21, 1783

After the success of last year’s launches, we are giving you another opportunity to blaze a trail across the sky and become a pioneer of aviation with the return of Skycademy, our High Altitude Ballooning (HAB) training programme.

Skycademy is a FREE, two-and-a-half day CPD event that provides experience of HABing to UK-based educators, demonstrating how it can be used as an engaging teaching tool. We’ll help you take ballooning to a whole new level (literally), where the hot air of Victorian era ballooning is replaced with space-age Helium to send your balloon soaring into the stratosphere at altitudes of up to 35 km. Fun fact: that’s around three times the cruising altitude of a Boeing 747!

IMG_20151009_090006446_HDR

Attached to the HAB is the payload consisting of a Pi-In-The-Sky GPS tracker board (developed by the wonderful Dave Akerman and Anthony Stirk), and a camera module, both controlled by a Raspberry Pi. You will use these elements to capture the balloon’s epic voyage and collect data to use back in your classroom.

Read more about last year’s adventures, mishaps, and balloons that were lost somewhere over the North Sea here.

vlcsnap-2015-09-03-08h25m55s123

See the earth from a whole new perspective.

At this point you might be thinking: “That sounds pretty cool, but I’m new to ballooning and nervous about launching into our airspace. Do we just get the kit and roll with it or do we get training?”

Enter Skycademy. Thirty lucky attendees will be guided through the steps to running a launch and, weather permitting, get hands-on experience of a real flight, so you’ll have all the experience you need before taking it back to the classroom. The event is free to attend and will be held from 8–10 August 2016. While the course is based in Cambridge, launch day will require you to travel to the launch site and then drive to recover your payload.

Training Itinerary

Day 1: Planning and workshop sessions on all aspects of HAB flights.

Day 2: Each team launches their payload, tracks, follows and recovers it.

Day 3: Teams gather together for plenary morning.

Skycademy team

A team prepares their HAB for launch.

Sharing the fun

Attendees are supported throughout the course by experienced HAB enthusiasts and the Raspberry Pi Education Team. However, the 2.5 days of training is only the start of a longer process where educators are expected to run launches at their own schools. Skycademy attendees will therefore receive the support and equipment needed to achieve this as part of a twelve-month programme.  The ultimate aim is to get young people excited and inspired by the project, and about all the STEM skills around it. A great example of this came from a successful launch by Queen Margaret’s School for Southbank Centre’s Women of the World Festival 2015:

WOW Near Space Programme – WOW 2016

As part of WOW 2016, a girls school will use weather balloons to send a small payload into near space, at altitudes of around 30km, where atmospheric temperature drops to -50C. The satellite carries a Raspberry Pi computer transmitting images of the WOW hash tag and the curvature of our planet.

Launch Day Butterflies

Seeing your HAB ascend majestically into the sky is both exciting and nerve-wracking. Skycademy graduate Sue Gray knows this feeling all too well after she launched at Elsworth, Cambridgeshire in May 2016:

“It was quite scary letting it go! Once it was let loose, there was no turning back.  If anything had been forgotten, it would stay that way! The balloon and payload sailed off into the bright blue sky and grew smaller and smaller as it flew away. A fantastic sight indeed.

Then it was time to pack up the launch box, wish the other teams good luck and set off on the chase.  A quick phone call to Mr Verma confirmed that he was receiving the telemetry from the payload and could see it moving across the map.

We got to Bourne a little ahead of the payload but…something was wrong.  It seemed to be hanging in the air just to the east of Peterborough and we hadn’t received any telemetry for over twenty minutes.  We stopped to take stock (and grab some food and drinks), Mr Verma confirmed that he too was not seeing any movement although he’d seen the balloon change to a parachute on the tracker – indicating a burst!”

After tracking the payload to a general area and searching the surrounding farmland, the team had to give up the search. As luck would have it, someone continued searching on their behalf and tracked it down!

Sue on Twitter

FANHAB is found!! Our payload stopped completely but it was joined wiv Steve’s & his sprung into action again & he tracked it! @LegoJames

These are just some of the ups and downs you can expect from a launch. Sounds like fun right? Ready to get involved?

People we are looking for:

  • UK-based educators who want to run their own High Altitude project with young people should apply.
  • Community members who want to help or support the educator launches, please comment below.

APPLY FOR SKYCADEMY

The post Apply for Skycademy 2016 appeared first on Raspberry Pi.

Marathon man

Post Syndicated from Liz Upton original https://www.raspberrypi.org/blog/marathon-man/

This Sunday, Lee Bowyer will be running the Liverpool Marathon. He emailed me a few months ago with an idea about doing it with some additional hardware on board.

Lee. Photograph taken while not running.

This is Lee. Photograph taken while not running.

Lee is running to raise funds for a charity called Addaction. He says:

I am supporting Addaction because of all the wonderful work they do with those who have alcohol and drug misuse problems. Thanks to wonderful people like those at Addaction I haven’t touched alcohol for nearly three years.

We got him talking to fellow marathon-runner Pete “Mythic Beasts” Stevens, they subsequently had long discussions about the corrosive nature of sweat, and things went quiet for a bit.

Lee bounced back into my inbox yesterday with a device to unveil. Meet the Raspberry Kiss.

Raspberry Kiss. Note little pancake motor.

Raspberry Kiss. Note little pancake motor.

Raspberry Kiss in sweat-proof housing for marathon

Raspberry Kiss in sweat-proof housing

What’s it do? Dead simple: the device is strapped around Lee’s waist, and allows people to track him on a map as he runs the marathon. There’s a GPS tracker attached to the Raspberry Pi, along with a little portable modem and a battery pack. The modem uploads information from the GPS module to a database on his webserver (hosted on a Raspberry Pi, natch), so you can see where he is on a map on his website.

how-does-it-work-black

But there’s more! You’ll have spotted the little pancake motor in the first picture – it’s the same sort of motor that makes your phone vibrate. Every time someone makes a donation, the motor buzzes to let Lee know – motivating and massaging all at once.

Everybody who donates will be entered into a prize draw. At Raspberry Pi, we don’t normally sponsor prizes like this (simply because we get asked to do so several times a day, and saying yes to everybody would cripple us financially), but we’re breaking our own rule for Lee’s marathon. The winning name picked out of a (sweaty) hat will win a Raspberry Pi 3 with a case signed by Eben, a Sense HAT and a camera board; we might pop some other goodies in the bag too.

We recommend waiting until Sunday to donate (you can fill out a form on Lee’s website that’ll send you an email to remind you when the marathon starts), so that you can motivate Lee with charitable giving. Good luck Lee. We really hope the thing doesn’t chafe.

 

 

The post Marathon man appeared first on Raspberry Pi.