Adding a GPS to the Air Quality Monitor

I’ve gotten a little obsessed with this air quality monitoring project I’ve been working on, which tends to happen once I’ve been through the trough of sorrow and a project starts to look like it might actually work.  The last piece that is missing is the location of the readings.  It’s going to be hard to build up the kind of maps that this project calls for without it!  Once again, it’s Adafruit to the rescue with their awesome Ultimate GPS Breakout.  It was (and remains, as of the time this was written) out of stock on Adafruit’s website, but Robotshop and others have it on hand.  I’m growing very fond of Adafruit’s products, they all work as designed, have great docs, etc.

Before adding a new component into an existing project, especially something as complex as a GPS, it always pays to get it working in isolation.  In this case that means wiring up the GPS module to a spare Arduino Uno.  A tip for people just getting started and switching between boards:  make sure you change the port and board type to match what you are actually using!  When I switched from the Mega used to actually run the monitor to the Uno for testing I forgot this step and momentarily thought the Uno was dead.  That’s the kind of thing that happens during late night coding sessions when your brain isn’t quite working right.  After fixing this little issue the GPS powered up quite happily and quickly got a fix.  It only takes four wires to get the Ultimate GPS Breakout up and running.  Just add power, ground and a serial connection.  Simple, right?  The Adafruit product tutorial for Arduino covers all this, and how to use the provided sample sketches to prove it works.

The next step was to get this module integrated into the existing project.  A little easier said than done due to a lack of real estate on the perfboard.  It took some rework and creative wire routing, but it’s in there.  When the board is installed in its enclosure the antenna will not be correctly oriented, but it is good enough for testing outside the enclosure.  The final version will use an external antenna mounted on top of the enclosure anyway so that’s not a big problem.  After wiring it up and updating the monitor’s sketch to use the GPS and send data to our collection server, it could not get a fix.  Moving it outside, reorienting the antenna and changing the serial port had no effect.  After several hours the GPS would just sit there and blink at 1Hz (indicating no fix) and no location data was coming to the collection server.  What’s the problem?

A little digging around in the docs and on the internet indicates that this module is particularly sensitive to noise in its power supply.  Without an oscilloscope it’s impossible to say for sure how noisy the supply is.  A little filtering couldn’t hurt anything, so I added a few decoupling capacitors to the supply lines.  Did it work?  No.  No it didn’t.  After over an hour the GPS had still failed to obtain a fix.  Back to the drawing board.  I tested the module with the Mega directly and got it working nicely by switching from a software serial port to a hardware port on Serial3.  Great, except for the fact that the same sketch wouldn’t work in the monitor itself.  It only worked if I isolated the Arduino Mega and GPS module on a breadboard.  This result indicated that something else on the air quality monitor board was the cause.

I began to wonder if another component on the board was interfering with the GPS.  Due to space constraints, the GPS module was right next to a WINC1500 Wifi module and a 5v regulator that powers the heaters in the gas sensors.  Could one of these be the cause?  The easiest way to test this is to move the components further apart.  I used a few jumper wires to move the GPS off of the board (about 10 inches away) and the GPS acquired a fix almost immediately.  Progress!  Now it was just a matter of narrowing down exactly which component was the culprit.  Simply for convenience I removed the WINC1500 module first since it wasn’t screwed down.  Again, the GPS acquired a fix almost immediately.  Looks like that is the cause.  The GPS must be getting some kind of interference from the Wifi module.  Lesson learned, these components apparently need some distance if they are to be used in the same project.  This is likely due to the patch antenna built into the Ultimate GPS breakout being right next to the WINC1500 breakout.  Hopefully moving to the external antenna that will ultimately be needed anyway will fix the problem.  If not, remote mounting the GPS module will.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s