ADS-B Range Testing – Part 2

I ordered the Flightaware bundle from WiFi Expert (antenna, USB pro stick dongle, cable and filter) via there eBay store The idea was to compare it my homemade antenna and NooElec dongle setup. While I know this is not the ideal setup with the LNA inside the dongle it is a worth testing to see what the results can be with a simple off the self setup.

I initially set it up in the backyard, to verify that it was indeed in operating order – it was. Always better to find out before you install it on the roof 🙂 Two days running it there indicated that the performance was no worse than my current setup. This was promising as my backyard isn’t ideally suited for line of sight to anything and to pretty much get the same response as the antenna on my roof indicated the results should be good.

Update 2016-06-04 & 06-25

Roof installation happened today. Quite painful with the high pitched roof and plenty of bird shit under the TV antenna. I removed the old home made antenna and replaced it with the Flightaware one. It’s nice to use proper pole clamps and fixings rather than my hacked up pipe clamps and cable ties – the result felt much more solid.

The old antenna also showed signs of rusting at the F connector – I wonder how long it would have survived in working order? Maybe I should tape up the connectors using self amalgamating tape? Something to look into I guess.

So one day later here are the results.

Range: Generally much better, the long range detection stretching out towards 500 km. I still have issues with detection towards the east sue to the hills which is expected. Range isn’t everything of course.

Message Count: The other major difference I can see is many more messages per second.

I have been able to detect planes landing and tacking off Adelaide airport while they are still located within the airport grounds. Previously I wouldn’t detect them until they were much further out/higher in altitude. A similar result can be seen at Parafield airport. The updated ModesDeco2 map really shows the extended range.

adsb-range-2016-06-25 adsb-adelaide-takeoff adsb-range-modesdeco2-2

Conclusion – is it worth it?

If I was just starting and wanted something simple that just works then yes I’d probably pay for the bundle and it would be job done. The range and performance is very good.

However if you prefer to make your own then you can get almost the same results with a $10 dongle, some coax cable and a bit of handy work.

If you add an LNA and ADS-B filter to your home brew setup I think you would get the same if not better results than the Flightaware bundle – and this might be my next test.

ADS-B Range Testing – Part 1

Long ago I set up and ADS-B receiver with the standard RTL SDR dongle and Raspberry Pi. It runs a combination of modesdeco2 and modesmixer2. The default web interface has a nice radar range graph, but each time you reboot the Pi the range data is gone. I have a piece of software that decodes the ADS-B stream and calculates range and azimuth data for current planes (i.e. location data updated within the last 10 seconds) among other things.

I thought I’d add the ability to save this data to a database so I can graph it and perhaps compare different setups, receivers, antenna, LNA’s and filters.

Here is the baseline graph for about a week ending 2016-04-25. My location is on the slope of a plain that runs north to south and up hill to the east. You can clearly see I have less line of sight visibility in that direction. However to the west the range is pretty good.

The setup is

  • NooElec NESDR Mini 2
  • Hand made 12 (or 13?) element coaxial cable antenna located on the roof
  • Perhaps 15 meters of RG6 between the antenna and the Raspberry Pi


UPDATE 2016-05-06

While waiting for parts to arrive I decided to try shielding the dongle with copper tape. To make it look somewhat neat I opened the case of the dongle and put the tape in the inside. The plan worked but the plastic and copper on the bottom of the dongle is quite close to the PCB so I added a layer of normal tape to the bottom of the PCB to stop shorts. The copper connects to the shield of the USB connector and the surround of the RF connector and encases the entire inside of the dongle. (I’ll add a photo of it later)

Anyways does it help with range? Perhaps, its hard to tell with ADS-B here in Adelaide as we don’t see a huge amount of traffic, and week to week variations could account for changes – who knows – anyway here is the update range graph with data up to 2016-05-06 including the baseline data.


In general, a small increase in range in all directions, with a larger increase to the west, pushing out towards 500 km.

UPDATE 2016-05-28

It turns out I forgot to order the new parts … too busy I guess … so it still will be a while before I get the new parts delivered and installed. In the mean time the shielded dongle has been running for almost a month so we can now get an updated range graph. It generally shows the same as the last update but this time you can see the improvement more easily.  For reference I’ve include my current modesdeco2 range so you can get an idea of the area around Adelaide I can see.


Ubuntu and USB Serial Devices

So I had to reboot the Linux server today, and I ran into the problem of it randomly assigning /dev/ttyUSB? devices to my two USB serial cables. With randomly assigned devices my CAN and SMS interface serial port names happened to get reversed – grrr.

So the task is to get Linux to assign the same name when rebooting.

First find out the device serial numbers, use this command and serach for the devices. Luckily in my situation the two cables I have are both FTDI cables with different serial numbers. Here is one

Next is to create or edit /etc/udev/rules.d/50-serial-devices.rules, and add a line for each device using the serial number, and in this case create a symlink to ttynasco0/1.

Restart udev, (reload?,  and trigger?) and magically the new files /dev/ttynasco0 and /dev/ttynasco1 will get created and assigned to whatever /dev/ttyUSB? file the kernel assigns.

Lastly I changed my config.ini file to point to the new nasco tty files.


Update 26/12/2014 – I replaced a cable and needed to update the configuration – It didn’t seem to take effect until I rebooted the machine for some reason.


Ubuntu Services

Now that the CAN and SMS MQTT gateways are working on the proper Linux server I figured it would be better to run them as services instead of having to log in and run them both manually.

In the end it was pretty simple (yay for Google). Here is the script template I have used, modified for each app with proper description, paths and user/group settings.

I think it will run the app, if it does crash then only try to restart it after 60 seconds.

So far so good.

Next up is to start decoding the other CAN messages (calls and cancels) and something like a messaging/allocation app that can use the call/cancel messages and push message out to SMS.

Example Use Case

  • Door bell gets pressed
  • CAN app takes the CAN message and puts it into /messages/can/incoming
  • Allocation app takes that message and figures that a message should be sent as an SMS, then SMS message put into /messages/sms/outgoing
  • SMS app takes that message and sends the message


Wireless Problems vs Wired Alternatives

Wireless Problems

Anyone looking at my sensor data will notice that there are a lot of gaps where data has not been recorded. It’s was hard to know exactly what the issue is as the Arduino is running headless. If I see the data has stopped I just rebooted the Arduino by unplugging the USB and plugging it back it. Yes it fixes the problem but it is not a real solution.

I ran it locally the other day and noticed that it was stuck in a loop thinking it had received a new message, but of invalid type, over and over again. I didn’t catch the moment of transition from normal operation to error, maybe another logged test next time. Anyways it was just printing this

All the type numbers seemed random. Here is the code snippet. Nothing looks like it should cause a a problem. And the problem occurs at random times after reboot. Maybe a problem with the nRF library perhaps.

Update – I got tired of trying to find the problem so I changed the code to force a software reset when the unknown type message was detected.

 Wired Alternatives

In a previous post I went through all the iterations of a CAN Input Module design. The latest design includes 8 analog input channels. The inputs can be left floating or internally biased with 10K resistors to GND or VCC.

Input Schematic

That’s handy because if I use the internal 10K pull up I get the same circuit I use in the Arduino sensors. Time to test that theory. I’m using the first three inputs, set the channel IDs (1, 2, 3), set them to analog mode, and added a delay of 10 seconds.

Input Module Programming

With this setup (and the current firmware) I get a new analog reading for each channel at most once every 10 seconds – if the reading has actually changed. The delay is really to stop a deluge of data. The PIC has a 12 bit A2D so the readings range from 0 to 4095. The firmware does 32 sample averaging.

The device programmer software has a logging mode so I have extended the logging to print the analog reading and convert it to a temperature. Here are the logging results – slightly verbose but you get the idea. The sensors are all withing a few centimeters of each other and the values returned seem to be within spec for components I’m using.

  • The 10K bias resistors are probably +/- 5%
  • Channel 1 is a small NTC resistor from Element 14.
  • Channel 2 & 3 are cheapy Aliexpress sensors.

Logging Results

Those paying attention will note that my anticipated 10 second delay seems to evaluate to only 8 seconds … oops … the RTC timer based code in the PIC is probably running a tad too fast.

I have had this running for the last week, logging away, all is good.

CAN/MQTT Gateway

Next step is to write a CAN/MQTT gateway application. My CAN bus is accessed via a CAN to USB device so it should be a simple matter of writing some code to open a connection to the CAN bus, wait for incoming CAN messages and publish a message to an MQTT topic, similar to what the wireless sensors do.

This will also serve as a foundation for working in the opposite direction, subscribing to an MQTT topic, receiving messages and sending them out via CAN.

(more to come)

You Can Never Have Enough Sensors

Day 1

What to do today now the lawns weeds have been mowed? The solar powered sensor is back out in the garden and seems to be working and recharging its battery in the sun today. The receiver is pumping the data into Xively nicely. I have these bits laying about …

  • 2 x Arduino TwentyTens
  • 2 x nRF24L01 modules
  • 2 x ProtoShields
  • 2 x 10K NTC sensors
  • 2 x Dallas 18B20 temperature sensors
  • 2 x Light sensors
  • 1 x DHT11 humidity sensor
  • 1 x BMP085 pressure sensor
  • Plenty of time

Parts Please

Yes its pretty obvious – more RF sensors. Might also be handy to do some indoor range testing and a network/mesh of the nRF modules.

Day 2

Today I partially assembled the two prototype boards. So far the LDR and DS18B20 are fully functional, and the nRF module is soldered in place but not yet wired up. Looks neat and tidy.

Partially Assembled

Of course now it is partially assembled its always nice to know if everything is working. So here is some simple test code. Same story and usual, Google for some existing libraries, no need to write your own.

I ended up with these OneWire and Dallas Temperature

And the output (including other debugging not in the code)

Day 3

Another day with progress. Today I wired up the nRF modules and added some more code to send the readings to the receiver. Other than a snafu with one incorrectly wired pin, it all went without other issues.

Here is what the protoshield looks like now. Still pretty neat. I added the 10uF cap to the 3.3V line, cant remember why or if it is really needed, but my receiver has one so I figured it can’t hurt to have it installed. Yes the wires I have used (single cores from security cable) are really too think for anything too elegant but it was all I had laying about.

Radio Installed

Latest is now live on the Xively Stream.

  • 1000 is the external sensor in the garden
  • 07f3 & d1ad are the new internal sensors

Next up, Add the screw terminal and send readings for the remote NTC temperature sensor …

RF Sensor Ethernet receiver

Feeling inspired by writing up the last post I decided it cant be that hard to convert my USB receiver into an Ethernet based one.

My USB implementation was using an old Freetronics Twenty Ten (the Eleven seems to be the latest equivalent) with one of the nRF modules soldered onto a ProtoShield Short.

I didn’t want add more shields as things start to look ugly so I happened to have an EtherTen in my Arduino parts box so in theory its just swap the shield to the new base board, change the code to add the ethernet connection and all done! That’s the theory anyway.

Like all good theories it wasn’t that simple. The pins I happened to choose for the nRF module conflicted with the pins used for the Wiznet chip for Ethernet connectivity. No matter, I rewired the offending pins and changed the code to suit – fixed.

So the firmware connects to network and the sensor readings are being received, all working great – but where to send the data to?


While I’d eventually like to have the data stored and processed locally, Xively seems like a choice to get things up and running with little fuss. I can let the receiver run 24×7 for testing while I sort out something more permanent locally – or if Xively does all I need that it can stay there – meh at this stage who knows.

Anyway, the developer section of the Xively site is pretty simple, find and download the Arduino library from git add it the the Arduino libraries folder and your away.

Total integration time was less that one hour including some optimizations.

Here is the public link for the prototype.

  • 1000.01 Temperature Sensor 1
  • 1000.02 Temperature Sensor 2
  • 1000.03 Light Sensor
  • 1000.08 Battery Voltage

The format is of the channel is XXXX.YY, where XXXX is the transmitters serial number, and YY is the sensor input number on that particular device.

Xively Test Data RF Ethernet Receiver


You can see the setup is nice and compact but I don’t like that I cant use the POE adapter board and a shield on the EtherTen at the same time so I still need to power the device from USB or the DC jack.

The nRF module is pretty much sitting over the shielded RJ45 connector which is probably acting as a ground plane – so not ideal.

Anyway for now I have a handy 12VDC source readily available so I’ll hook up the DC jack. Then I don’t need to have it connected to my desktop PC all the time – except for debugging.

Update: Things have gone fine expect for an outage at exactly 9 PM one night. Not sure why – but the timing seems to perfect, perhaps the DHCP lease expired?

I changed the code to renew the DHCP lease and left the debugging output running to hopefully catch something. Could have been a random power issue resetting the Wiznet chip – who knows.


Whats The Temperature?

What is the temperature outside now? In the pool? Inside the garden bed? How much light did we get today?

To answer these marginally useful questions the obvious solution is to build a solar powered, RF transmitting sensor – paired up with an RF receiver to act as an interface to the computer.

First thing some basic requirements

  • Multiple temperature sensors
  • Simple light sensor
  • RF transmitter/receiver pair or transceivers
  • Solar powered – implying battery powered
  • Able to run 24×7
  • Weather proof/resistent
Sourcing the Parts

Again better not reinvent the wheel so after a few Google searches and numerous distractions I found the Seeeduino Stalker.

Seeeduino Stalker

A nice starting point to get the main things I needed. In particular the Arduino board with solar input, lipo battery charger circuits, a cheap solar panel, a lipo battery and importantly a waterproof case ready to go.

I got a Bluetooth XBee module for quick testing as I already had a USB Bluetooth dongle so I could get something up and running pretty quickly without needed to prototype the receiver.

Now some cheap temperature sensors – Aliexpress has many options here. I went with some cheap 10K NTC resistor based items. I didn’t hold much hope about sticking these particular ones in the pool (salt water / chlorine) on inside the garden bed (moisture in general) but its a start and at the price  they were cheap enough to be disposable.

The light sensor was just an LDR I already had in my parts draws.

Cheap 10K NTC Sensor

 Initial Setup and Results

I put some quick firmware together and as it was summer time with plenty of sun around I stuck with using Bluetooth as the communications put it all together and installed in by the pool with one temperature sensor dangling in the pool and the other just in free air.

Setup 1


Unfortunately I don’t have an image of the sensor that was in the pool – it lasted maybe a month before the temperature readings starting dropping – it appeared that the potting compound wasn’t really adhered to the wires and eventually the salt / chlorine / heat got into it – not unexpected.

The Bluetooth was marginal from the pool to the office – maybe 17 meters away and through a few walls and metal window shutters – not unexpected.

The battery recharging worked quite well – it was full Adelaide summer after all, weeks of 35+ degree days with no clouds. The graphs of battery voltage did indicate that the battery was pretty much marginal as is each night it almost expired only to be saved by the sun the next day.

Happy with the initial results none the less as I hadn’t done any power optimization at all.

 Autumn Radio Upgrades

The initial prototype was retired after summer as the battery drain from the Arduino and Bluetooth modules running 24×7 was just too much. Plus the pool isn’t heated and there was little interest in the water temperature – you already know its cold. Naturally it was time for an upgrade.

I have no idea how much power the Bluetooth module required as I didn’t measure it properly but my assumption of power usage and the range being quite poor I decided to upgrade the to some RF modules. An obvious and cheap choice was one of the numerous nRF24L01 modules you can source just about anywhere these days. $10 for 10 transceivers is very hard to beat so its worth a try.


There are plenty of Arduino libraries out there for these modules so changing the code over was also pretty straight forward. I also needed to make a receiver in the office to get the data sent from the sensor.

Here is the sensor at the bottom and receiver at the top as it is now.

The winter kit

It was now autumn and there was still enough sun during the day to keep things running overnight even though the Arduino was still running 24×7 at full speed (8Mhz). At this point I was already powering down the nRF module in between transmissions to save power.

Winter Firmware Upgrades

Winter comes along and the amount of sun during the day – assuming there is any at all – is just way too short. So time to finally get the firmware to do proper power management.

Lucky for me the Stalker board had an on board RTC. The firmware basically uses the RTC to set an interrupt/alarm every minute, wakes up, takes the readings, sends the message, and goes back to sleep.

The results were much better – lasting over a week with little sun and the panel flat of the ground – less than ideal. Here is the graph for the last week.

Weekly data

Something Still Obviously Wrong

You will notice the graph is quite sparsely populated – to say the least. The sensor is pretty much outside my office window about 4 meters in the garden bed. The receiver is on my desk. At night the metal window shutters get closed and the sensor readings tend to disappear – not unexpected but annoying.

I think this is a problem with using the nRF modules, at least these ones with the PCB antenna. Some problems I have seen

  • The angle at which I have the transmitter and receiver matters. Flat seems worse than upright.
  • The range I get from the modules, while good, just isn’t good enough to reliably have communications from outside to inside, let alone from one side of the house to the other.
Future Upgrades

For now it will suffice but some future upgrades will include …

  • Using a receiver with the nRF module that has the built in amplifier and normal antenna.
  • Mounting the receiver on an outside wall to eliminate the metal window shutter problem.
  • Using an POE powered + Ethernet enabled Arduino for the receiver and upload the data to a server rather than having the receiver connected to my desktop PC.
  • Creating a few more sensors for around the yard
  • Finding a solution for a pool water temperature sensor.
  • Having the data available and graphed on a website so I can check whats happening from anywhere.
  • Add a soil moisture sensor
  • Add a humidity sensor
  • Integration with my watering system


Alarm Panel – SMS Interface Installation

For what seems like forever Simon and I have been working on an alarm panel to SMS gateway device. Mainly to be used with an existing alarm panel, this device will plug into the phone line socket of the alarm panel, allow the panel to “call” and then respond with the proper Ademco tones.

Click here for Simon’s blog posts on the hardware design.

With prototype V2 finally complete and the latest firmware uploaded it was finally time to give it a test run on my alarm panel. Now how to mount it and monitor it for testing? Here is all the stuff where I need to make it happen. Seems like a mess before I even start – this was after I cleaned up the original mess – sigh.

Alarm SMS Items What a mess

  • Alarm panel, alarm SMS interface, phone cable and GSM antenna
  • Raspberry Pi and USB cable for debug interface monitoring
  • 5V switch mode power supply module for the RPI
  • 12VDC Plug pack for the home automation gear
  • 12VAC Plug pack for the alarm

I decided to remove all the existing items from the wall and remount everything on a sheet and MDF. That will make it easier to mount things without the need to locate any wall studs. I roughly measured the wall area, alarm, RF receiver, and power point locations. Marked them up on a piece of MDF the let rip with the drill and jigsaw to get the power point hole removed.

A - Markup B - Drill C - Jigsaw

Looks nice, let’s hope it fits! Of course it did, was there ever any doubt? Now to remount everything. It all went pretty much to plan for a change. The alarm panel was slightly painful as it didn’t really have a lot of movement but some handily placed boxes took care of that.

It fits Remounted Almost done

I rewired my automation input module and finally installed the alarm SMS interface and RPI ready for testing.

Remember this is for testing so yes its all just spread over the shelf for now, the proper installation will not have the RPI and the interface will most likely be mounted inside one of the two cases with just the antenna on the outside.

Now finally I can start testing !



Wall Switches Redux

Another side track/experiment

As part of my obsession with finding the ideal wall switch, I found these Livolo brand switches via Aliexpress. Aliexpress seems to be the “go to” place to find just about anything these days.

I ordered one single switch version VL-C301-81 and one four switch version VL-C304-81. Both without the option radio interface or the A/B switching options. The radio interface, after thinking about it, would have been quite handy–  oh well, they are cheap enough to order more if required.

Why these ones? Looking at the marketing images on the Aliexpress pages seemed to show that they are relatively simple in design, with an upper and lower PCB connected with standard headers. A nice point to be able to hack into it. Also of note to the hacking people among us one of the images showed that the top PCB appeared to have a PIC processor on board – hmmm.

Livolo Assembly

The idea was buy the switch, remove the original back PCB (the one that does the 240V and relay stuff) and substitute my own low voltage PCB – with simple connectors or more advanced CAN interface. The top PCB hopefully wouldn’t be any the wiser. The end result would be a nice looking touch switch that hooked into my home automation system.


The single switch plate went into service replacing the standard Clispsal switch my FutureTAB HQ office.  Installation was quick and easy – just make sure to turn off your breakers before playing with any mains voltage stuff – or better yet get an electrician to do it for you.

Another reason I want to replace all my switches with low voltage equivalents and have other ways to flick the mains to the lights/appliances/etc. I hate touching anything with mains involved.


I like the way they work. The touch area is quite tight around the indicated circle. The blue “idle” LED is very dim, barely visible in the dark, but it is far easier to find the switch in the dark. Generally blue is an annoying color, especially if its bright and/or in your face, but this one could have been a little brighter – maybe a hack for later. The “on” red LED I really can’t see when the light is on – so maybe its useful, maybe not – again maybe a hack to make it brighter. The relay clicking is no louder than a normal Clipsal switch – so nothing to gain there. It is also easier to turn on the lights when my hands are full with food/coffee/etc – less chance of spillage accidents – bonus!

I have a home theater sub woofer with one of these annoying bright blue LEDs – it has a  strategically placed piece of tape covering it up – A bright blue LED shining in your eye while watching a movie in a dark room — WTF were they thinking?

“Don’t Turn It On, Pull It Apart” – EEVblog

In my case I say turn one on, take the other one apart!

The photo above was exactly what it was inside – how nice of the Livolo marketing folks. The photos below show the top PCB that I want to interface with. Clearly visible are the four LED and touch switch areas with some clever use of the silkscreen underneath the clear plastic parts to aid in light reflection. The bottom of the PCB shows the PIC16F960 and the 14 way header used to connect to the bottom PCB. They have even included what looks like a PIC programming header – hmmm.

 Livolo Top PCB A Livolo Top PCB B

Stay tuned for details on how I go with the hacking experiments.