Archive

Uncategorized

This is used for and Android app I’ve been working on, which is based on Copter-GCS.  The app, which I have dubbed the most original Android GCS, is a drone ground station that should work with any Mavlink enabled autopilots, but I have been testing it with an Ardupilot 2.

wpid-IMG_20130202_204452.jpg

The bridge connects a Bluetooth serial radio to an XBee radio (or 3dr radio).  The XBee provides a long range link to the airplane or ‘copter, and the Bluetooth provides the link to an android device.  The great thing about this setup is that it allows you to easily connect any Bluetooth enabled computer as well, without switching cables, etc.

The setup works incredibly well.  The only downside I found was my android phone heats up a bit from the intense Bluetooth connection, but I have not seen any big battery drain.

XBee Attached

XBee Attached

 

 

 

 

 

 

 

Parts List:

RN-41: Roving Networks Serial Bluetooth 2.0

XBee (I use 900mz, but any will work)

LD1117V33: 3.3v voltage regulator

0.1 uF and 10uF Capacitors

Adafruit XBee Adapter (Not absolutely needed for this setup, but I used it just for the pin breakout)

I etched my own board for this, since I hate having a rats nets of wires, so here’s the first draft:

top_copper.grb.psdPretty hard to follow, huh?  Ok, the RN-41 is the footprint on the bottom right, the power supply is on the bottom left, and the connection to the XBee is the top left.  The power supply gives power and ground to thew RN-41, as well as the XBee.  The TX from the XBee is connected to the RX of the RN-41, and vice-versa.  I added plenty of pads for testing, expansion, as well as a connection indicator LED for the RN-41.  It was a pain in the ass soldering the smd chip… those are tiny pads!  I ended up ripping off the pads I wasn’t using so I didn’t bridge anything.  If I did it again, this board would be slightly reconfigured, sent out for fab, and I would reflow the chip onto it, but this is a good prototype.

The next part is setting up the bluetooth.  I only had to set the baud rate to 57k, and the RN-41 has a great set of AT commands.  Linking with my android phone was easy, and there is a great set of instructions that accompanies this chip.  The difficult part is this is a 3.3v part, and my TTL Serial supplies 5 volts.  I ended up powering the chip with 3.3v through the circuit board, and attaching jumpers to tx and rx from my TTL cable.

To enter command mode on the RN-41: $$$<cr>

then to set to 57k: SU,57<cr>

That’s all you need to change, but I changed the device name (SN,<name>), added a security pin (SP,1234).  Pairing is easy, just plug the RN-41 into power, scan for devices on your phone, and click on what it finds.  If a pin is required, the default is 1234.

I made this bridge a while ago, but I recently added in a Y-splitter to the serial connection, and attached a arduino that listens to the serial stream, or transmits with the flick of a switch.  I intend to add in an antenna tracker based on the arduino.

In some time killing procrastination at work, I happened by the new(?) Google Places API, which provides information about the surrounding area based on a given latitude/longitude pair.  Location based information is one of my favorite data sets, so I jumped right in.  I’ve already got a matrix of tools set up that can react to the current location of my phone, which I may detail in a later post, ending with a cgi script on my server.

The API calls for authenticated GET requests, so I started by adding a simple wget call to the aforementioned cgi:

wget -q -O /tmp/places.txt https://maps.googleapis.com/maps/api/place/nearbysearch/xml?key=$apiKey&location=$lat,$lon&sensor=true&radius=$radius&types=$types;

However, for some reason, I couldn’t get wget to properly make the secure request. So, I got a bit serious, and went to perl, my goto for the heavy lifting:

my $req_url = ‘https://maps.googleapis.com/maps/api/place/nearbysearch/xml? key=’.$apiKey.’&location=’.$lat.’,’.$lon.’&sensor=true&radius=’.$radius.’&types=’.$types;

This got me the data, and after a quick parse with LibXML got me what I wanted:

my $parser = XML::LibXML->new();
my $doc = $parser->parse_string($source);
if($doc->exists(‘/PlaceSearchResponse/status’) ) {
foreach my $result ( $doc->findnodes(‘/PlaceSearchResponse/result’)) {
$name = $result->findnodes(‘./name’)->to_literal;
$vicinity = $result->findnodes(‘./vicinity’)->to_literal;
$type = $result->findnodes(‘./type’)->to_literal;
$rating = $result->findnodes(‘./rating’)->to_literal;

From there, i just weed out the crap like convenience stores, fast food, etc. and send a push notification to my phone using C2DM, so I get a note with interesting places around me wherever I go.  It’s a lot like Field Trip for android… but I made it.

In the end, after a few weeks of using it, I was annoyed by the crap that Google has in their places database.  I ended up replacing this tool with one that queries the Foursquare API.