This project underwent quite a few changes before it reached it's final form that we turned in to our professor for UW Bothell's Sensors and Sensor Systems (B EE 484) elective class. Our biggest learning experience here was to read data sheets carefully and confirm subsystem compatibility before purchasing and tying to integrate parts. I can't stress that enough. What this project will showcase is the final product we had at the due date. There are many places where the hardware and code could be cleaned up and simplified, but we did what we could with the limited time, knowledge, budget, and resources we had.
The Project - BeginningsThe idea was a group tracking and environmental data reporting system. A user would have a system with various sensors on them that would display quantitative and qualitative data about their local environment including how far away and to what direction other group members or a reference point is, all on a single LCD screen. We decided we wanted to try to use a Wifi signal for the communication rather than the shorter distance limitations if we had used Bluetooth, and none of us had experience programming devices to use Wifi so we thought it would be a valuable experience. Our professor told us we would have to build two systems to demonstrate the communication.
We were budgeted $200 for a group of 4 from course fees, which wasn't enough to pull off this project. Everyone had to supply or purchase other materials than we were able to order - another drawback about planning a project before comparing data sheets and considering cost. We had to think of a way to house the system in a way that would minimize obstructing the user's activities, so we opted for a super stylish fanny pack. Growing up in the 90's, that was the best thing I could think of that would hold a micro-controller and peripheral hardware on an active person. However, we didn't get to enjoy that aspect until the last week of the quarter.
The Project - Coding and System IntegrationWe were prompted to use an Arduino Uno for the project in attempt to simplify programming, which is why this is based around an Arduino, but we ended up using the Arduino Mega for its multiple Serial IOs. The biggest problem we had was using Wifi to allow communication between devices. The original module we purchased for Wifi communication required more RAM than a simple microcontroller would provide. This was discovered after hours of research for sample code and concepts to implement the device. One team member had two Raspberry Pi microcontrollers in their possession and came up with the idea that he could interface the Arduino with the Raspberry Pi and use the built-in Wifi capabilities to exchange data over the Cloud. This was done by using Python code on the Pi to read a serial port from the Arduino Mega to transmit and receive position data to the Cloud. Crazy overkill on the microcontroller use, and just a patch job at that, but we were running out of time and didn't want to redo the coding and connections we had already worked hard on. It ended up working great though, thankfully.
The next big hurdle was the PmodGPS sensor code. We found example code on Digilent's website that got us started. It was designed as a state machine, which seemed really cool at the time. It turned out later that this state machine approach made more complex interactions involving timers and interrupt service routines with the other sensors too difficult or clunky to implement for our knowledge. Many sacrifices were made, but the PmodGPS turned out to be a heavy lifter for our project, with excellent accuracy when it was getting sufficient satellite signals.
The data from the PmodGPS latitude and longitude functions returned strings and in what is called the Degrees-Minutes-Seconds format. This required code to parse the strings, convert the parts to floats, perform any conversion calculations and sum the parts so the coordinate data was in what is called Decimal Degrees format, which allowed further calculations. Using some algebra and trigonometry, I was able to code distances between coordinates and an angle with cardinal direction to the other user. This was more of a pain than it sounds because I needed satellite signals to test the code with real data, which worked fine outside but not in very many places indoors on campus. We even bought antennas to boost the pickup gain, but it didn't cure the geography of being in the lower floors of the UW Bothell campus. Unfortunately, it was also autumn quarter and generally not great to be outside with technology.
A last note about the GPS calculations, there were a few linearizations and assumptions I made when writing the code. I did not take into account the curvature of the Earth. I also linearized the distance between longitude degrees to the Seattle area since the distance between longitude degrees approaches zero as you approach the poles. These simplifications reduced the range that the system can be highly accurate to about 100km about Seattle. These parameters can be simply adjusted for anywhere in the world but not for the entire world.
Since the majority of the code and data was from the PmodGPS sensor, it made more sense to integrate the other sensors into that code for the sake of time and simplicity near a deadline. This reduced plans to derive more quantitative results and alert systems from the barometric pressure and temperature sensor and the air quality sensor.
The Project - ResultsAt the time of submission, the project displayed this data on both systems with high precision and accuracy:
- Current latitude and longitude in degrees
- Altitude of user in meters
- Distance magnitude to other user in meters
- Cardinal direction (e.g. NE) and degrees relative to East to other user
- Speed of user in km/hr
- Local barometric pressure in inHg
- Local temperature in Celsius
- Local air quality in 4 stages from "No Pollution" to "High Pollution"
Even though this was a rather stressful project, it was really awesome that we got it working and that it was highly accurate. Since I've spent countless hours on this project and we put together a report for the class submission, I am not going to go into further detail unless a reader has specific questions or curiosities. I have included with this project all of the code we used, the report we wrote, a powerpoint presentation, and a capstone-style poster. Hopefully that will clear up any questions you may have at this point or get you started on your own project. I may continue to update this project or work out noticeable kinks in the future. Please comment if you would like to discuss anything specific. Thanks for reading!
Comments