Category: ADS-B tracker
A DC-3 landing in Hong Kong
Another interesting catch by my ADS-B trackers in Hong Kong has been a Douglas DC-3 with tail number N41CQ on December 4th, 2019. This rare aircraft made a special trip from Hong Kong to Beijing via Guangzhou and Shanghai, to celebrate the 70th anniversary of the CNAC (China National Aviation Corporation) initial flight.
DC-3 details
Hex code | A4D208 |
Tail Number | N41CQ |
Type | Douglas DC-3 |
US NAVY using ADS-B code hopping

Recently, I started to detect many P8 Poseidon aircraft above South China Sea, like if a dozen of different P8 were flying in the area each day. The only explanation I see is that they are doing ADS-B code hopping, switching to a new TACTICAL code every few minutes.
Here are some of the codes I detected in the past few days: AE686A, AE6879, AE6889, AE67B3, AE6784, AE687D, AE6850, AE6854, AE6809, AE6793, AE6807, AE6845, AE6819, AE6836, AE67C2, AE67DC, AE6885, AE67D6, AE6813, AE687E, AE689E, AE6884, AE67DE, AE6803, AE682D, AE687C, AE6849, AE68A2.
Few more codes detected recently: AE6848, AE67DF, AE6870, AE6883, AE683D, AE6822, AE6814
3 tips to optimize PHP code
How I divided my server errors by 40 with PHP code optimization
I have been running several Raspberry Pi based trackers for a while, and I wanted to create a common database of detected aircraft and their positions. I looked for online database solution and how I could connect my Pi to them directly in Python, but that was not convenient.
I finally decided to get an hosting plan at OVH and create my own databases, with API to add more aircraft and positions. I wrote all the APIs of my server in PHP, as it was pretty straightforward. I got it work pretty well, but I was still having quite a lot of errors. At first, it was simple, I played a little with the timeout, I add retries, but I was still not able to go below 2% of errors. For a long time I lived with that, my system still worked well, but I finally decided to work on that and optimize PHP code.
The usual PHP tips to optimize PHP code…
A quick search on php optimization got me a list of things to do:
- use single quote instead of double one:
'text'
is better than"text"
- calculate variable only once in a loop
- close databases
- order
switch
by order of use - select specific columns instead of * in mySQL
SELECT
queries - use
foreach
instead ofwhile
- use
echo $a,$b,$c
instead of echo$a.$b.$c
- use sprintf to add strings:
$string = sprintf('today is %s', $date)
- use === instead of == in if:
if ($a===$b) { action}
- INSERT multiple values in database instead of multiple single INSERT
It seems that many of them were useful for older PHP versions, but not really for PHP versions over 7…
… and what really worked for me!
The 3 actions that had a tremendous effect on my API have been around database optimisation: first, I rewrote the few INSERT loops in order to INSERT multiple values at once. This was already much better. Then I checked my databases structures, to make sure I had all the right indexes corresponding to my SELECT queries. And finally, I switched all the heavy ones to InnoDB (I am not sure why OVH use MyISAM as default structure…).
These 3 actions reduced my error rate from 2% to 0.05% by reducing the load of my server (I am using a very basic hosted configuration, nothing fancy here). On the other tips I found, most of them had no or only very marginal impact. The only one I will keep, is the sprintf function to create my strings with variables as this makes my code much easier to read (it was easy to get lost in the quotes when you write mySQL queries with all that ‘ and ” and .).
How did I find that was my issues? What is important is to find where you PHP requests are spending time. For that, I simply implemented some time measurement inside the code (with the microtime function: $start_time=microtime(True); $stop_time=microtime(True); phpduration = $stop_time-$start_time;
), that is coming back to my Pi with the result of the API. I could then dig into the one loading the server for more than 1s and reduced their load. I did the same in my Pi, to track which mySQL queries were taking more than 0.001s to run, and that was very efficient.
I was able to focus on optimising the most important ones (mainly those on huge database, such as positions, which rapidly contain millions of entries), and optimise their structure and indexes. There are many tools available to profile your PHP code, but I didn’t find any that was easy enough to start with compared to what I needed them for.
With 0.05% error rate, I can think about adding more trackers and maybe even have a way for others to share their tracking data with me! Let me know if you would share yours or if you have more tips to optimise PHP code…
What else can help reduce connection errors?
I also did several actions to reduce connection errors to my API server:
– make sure you don’t have any redirection
– make sure you updated requests and certifi on the Raspberry Pi, specially if you are using a secured connection. It can easily be done by:pip install --upgrade requests certifi urllib3 idna chardet
– use session if you are calling the API regularly:api_session = requests.Session()
will replace
resp = api_session.get([request])requests.get([request])
– set a different timeout for connection and response:api_session.get([request], timeout=(5,10))
Breitling Jet Team
Breitling Jet Team, operated by Apache Aviation is based in Dijon, a city in France few hundreds kilometres south east of Paris. My mobile tracker picked most of the team when I spent few weeks in Chalon our Saone early this year.
Breitling Jet Team is flying on Aero L39C Albatros, with tails ES-YLX, ES-YLN, ES-YLF, ES-YLP, ES-YLR, ES-TLF, ES-TLG and ES-YLI. You can see more details in the search page.
Breitling has decided in 2019 not to renew its sponsorship as sole and exclusive partner of Apache Aviation, but is open to staying on board as co-sponsor. Apache Aviation and Breitling are in search of co-sponsors to operate Jet Team around the globe.
Founded by Jacques Bothelin in 1980, the team had several sponsors (and names) during the years: Patrouille Martini, Patrouille Ecco, Patrouille Addecco, Khalifa Jet Team before to be named Breitling Jet Team in 2003.
Let’s hope they will find a new partner to continue this adventure!
US military planes in South China Sea
There are a lot of US military activity in the area between Taiwan, Hong Kong and the South China Sea. Transports, SIGINT, reconnaissance, protection of US carriers in the area… mainly conducted by the US Air Force and the US Navy. Here is a list of planes seen in past few months (click on the link to see the radar map when the trackers got a MLAT position – these aircraft generally do not broadcast their position on ADSB):
AE049B – Tail number: 61-0313 – Boeing KC-135R – US Air Force
AE1492 – Tail number: 96-0042 – Boeing E-8C Joint Stars – US Air Force
AE1D8A – Tail number: 15-6511 – Lockheed EP-3E Aries 2 Orion – US Navy
AE1D95- Tail number: 15-9893 – Lockheed EP-3E Orion – US Navy
AE1D91- Tail number: 15-7318 – Lockheed EP-3E Aries2 Orion – US Navy
AE1D5D – Tail number: 16-1586 – Lockheed P-3C-II.2 Orion – US Navy
AE17EF- Tail number: 05-0730 – Boeing C-40C – US Air Force
AE04FD – Tail number: 58-0095 – Boeing KC135T – US Air Force
AE01CE – Tail number: 62-4134 – Boeing RC135W Stratotanker SIGINT – US Air Force
You also can see the latest detected military and other aircraft of interest and the pick of the day or search my database on foxtrotcharlie.ovh.
SAM727 flying over Guangzhou with Secretary Pompeo
Today (2020-10-30), the Boeing C-32A with tail 99-0003 was spotted by my trackers over Guangzhou with the CallSign SAM727.
A quick search shows a departure from Hanoi, and a current position over Japan. Probably used by Secretary Pompeo who was visiting Hanoi yesterday.
Having fun with my ADS-B tracker project
How it started
Some years ago, I bumped into an article on Mashable about Jeremy Merrill using a Raspberry Pi ADS-B tracker to detect aircraft flying over his house and display the origin or destination of that plane (see article here and github there). As my place is just on a busy plane corridor, that gave me an idea. I decided to work on a similar project based on Piaware. Looking at how he did it and at the long literature you can find on the web on ADS-B, I created this site, my own software in Python to run on my Pi and other fun stuffs. I also ran into this site by SonicGoose and that gave me many new ideas (including the basic structure of this site – I never had any experience of html or php before).
One key part is getting access to aircraft databases to get more info from the ModeS hex code you get from the Piaware tracker. I am sharing my own database of planes, airports and routes I detected with one of my trackers (I have a fixed one at home, another one in Briancon in France (solar powered and connected by SigFox!) and a mobile one I take with me during my trips over the world).
When I started few years ago, I didn’t know that it will become such a fun project!
Updates
[2019/02] Update of installation script and new links
[2019/05] Update of the Radar page that now use my own positions database. Added aircraft silhouettes and Airlines logo.
[2019/05] Changed the domain to FoxtrotCharlie.ovh !!!
[2019/06] Changed landing page and reworked index for Google
[2019/07] Added Great Circle tracks between origin, destination and seen positions on Radar
[2019/09] Added Airports data, API page, better sitemap for Google index
[2020/01] Added a solar powered ADS-B tracker in Briancon, with a SigFox interface by SNOC to send new / special planes to this database when Wifi is off – works great!
Running an ADS-B tracker on a solar panel is quite challenging. After some research, I believed a 20W solar panel would be enough, but the stick consumption is very high, and solar energy production is far from stable… after few month using it, I would need about 80W to be able to power the system for 24h (Raspberry Pi 4 + Flightaware Pro Stick Plus + SNOC SigFox). SigFox is a great solution to replace a 4G modem which would also take too much energy. The limitation to 6 messages per hour is manageable, as I am only reporting new or special planes to this website, while the detailed data are stored and shared when the device has access to wifi.
The biggest issue I didn’t plan for was that the Pi doesn’t have a RTC, so time was wrong (it only progress when the Pi is on, about 8 to 12h per day… after few days, it was completely off). Hopefully, I could also use the downlink SigFox messages to get the network time and update the Pi time at each boot. Here the limitation is at 4 messages per day. It is controlled by the callback feature so it is quite easy to be sure you will not exceed the budget, even with a Pi with no idea what is current date or time. Next step is to work on shuting down properly the Pi when battery is low in order to avoid memory issue. So far it works with multiple wild shutdowns per day, but I don’t know for how long.
[2020/02] Updated the stats page to show more details
[2020/03] Added tweets on Sigfox interface with Briancon tracker
[2020/07] Working on adding MoPi-2 on the solar powered tracker to allow clean power down. Changed all the time in UTC. With trackers everywhere, it doesn’t make sens anymore to be on Hong Kong time.
[2020/09] Added a new blog. Let’s hope I will post regularly from now on![2020/10] API optimisation – reduced the errors from 2% to 0.05%
[2020/11] New landing page with a RSS feed reader to get up to date links to my blog posts. Let’s see the impact on Search ranking!
[2020/12] Upgraded all my Raspberry Pi code to Python3. I have been delaying that for a long time, but it was much easier than expected. Further optimisation of the API to reduce the error rate further. Some trackers are now at 0 errors, some still at 0.05%, still struggling to understand why.
Interesting links on ADS-B trackers
The Mashable article that started everything.
Flyover github, a great place to start.
Piaware from Flightaware.
Raspberry Pi
SonicGoose, that inspired me to create my own database of aircraft, flights, airports…
ADSB-Exchange which has great APIs
The very good adsb-receiver on github
The awesome OpenSky, with it’s great interface
The excellent AboveTustin, if you want to tweet the planes flying over
And for sure Foxtrotcharlie!
Will airlines recover from COVID-19 crisis?
I have been tracking planes in Hong Kong for few years now with my Raspberry Pi based ADSB trackers. There are few airports in range (Hong Kong, Macau, Guangzhou, Shenzhen, Zhuhai, Huizhou), which was giving me quite some traffic (about 2000-2200 different aircraft per day).
Then came COVID-19. Many international airlines stopped to come to China. Many domestic flights were cancelled too. And then the crisis went worldwide. Daily traffic dropped to 600 aircrafts per day at the peak of the crisis.
Since then, it has been slowly recovering. As China domestic traffic went back almost to normal, I am now at 1300-1400 aircraft per day, still far away from where it was.
Bad news are coming from everywhere… Cathay Pacific just announced they will suppress 6000 positions and stop Cathay Dragon. Many smaller airlines have been bankrupt. Most of the others have retired their old or not efficient aircraft earlier than initially planned (B747 and A380 are the most iconic ones).
And restrictions to international travels are still in place in many countries, while the epidemic is restarting in Europe, and never really slow down in US. Can the industry recover from such an unprecedented crisis? I wish it will! My bet is that it will take time and that it will have deeply modified the industry. 2020 will be a turning point in any case and resilience now has to be in every airline strategy.