Archive for December 2009
So school is out for the year, and I’ve got some three odd weeks off — plenty of time for side projects.
Anyway, I picked up a really cheap prepaid cell phone a while back for $50, with $5 prepaid credit on it. Neat thing is that it runs JavaME and has a cheap GPS unit built in. Overall, the thing feels pretty flimsy and cheap, but I still can’t believe it was $50.
Anyway, Tim and I wrote a small bit of code to read the latitude, longitude, and altitude coordinates from the GPS unit on the device and upload it to sensor.network via a $0.35/day internet connection on the phone.
HttpConnection conn=(HttpConnection)Connector.open(datastreamURI+"/data"); conn.setRequestMethod("POST"); conn.setRequestProperty("X-SensorNetworkAPIKey", APIKey); conn.setRequestProperty("Content-Type", "application/xml"); conn.setRequestProperty("Content-Length", sampleDataXML.getBytes().length + ""); OutputStream os = conn.openOutputStream(); os.write(sampleDataXML.getBytes());
If you do take a look at the original source, you’ll notice that I had to change only a very small bit around; Java ME doesn’t have the URL class, so I had to open things up with a Connector; other than that, it was pretty straightforward.
So with a bit more code to sample the GPS, I’ve got a $50 GPS tracker that uploads data to the internet.
With Sensor.Network, I can graph where the phone is.