Greg Klein's Blog

Prepaid Phones, Sensor.Network, and Java

with one comment

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.


The phone in question.

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 via a $0.35/day internet connection on the phone.

The code to post the sensor data was just a slightly modified bit from yggdrasil (actual source file is here).

HttpConnection conn=(HttpConnection)"/data");
conn.setRequestProperty("X-SensorNetworkAPIKey", APIKey);
conn.setRequestProperty("Content-Type", "application/xml");
conn.setRequestProperty("Content-Length", sampleDataXML.getBytes().length + "");
OutputStream os = conn.openOutputStream();

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.

GPS Trace

A trace of the phone's location; you can tell that the GPS isn't very good.

Fun stuff.

Written by gregklein

December 15, 2009 at 1:47 am

Posted in java,

One Response

Subscribe to comments with RSS.

Leave a Reply

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

You are commenting using your 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 )

Connecting to %s

%d bloggers like this: