2013年5月21日星期二

Building a Bicycle Barometer

In my day job in the United Kingdom’s Government Digital Service, I had got used to ambient information from screens that dot the office. These provide real-time updates about the progress of various projects. I wanted a bit of that for home—something I didn’t need to tap or click to check, something that was just there.

How I could achieve that came to me in April 2011 at a Rewired State “National Hack the Government Day” event, when I started playing with a Nanode microcontroller. The US $50 Nanode is an Arduino-like microcontroller designed by a group at the London Hackspace, with Internet connectivity built in. I’d had various Arduinos sitting about for a while, with the intention of learning how they work and building something network enabled. But this never quite happened: Getting an Arduino connected to the Internet requires a separate Ethernet “shield” component, which were hard to get hold of at the time. So a Nanode was just what I needed.

 However, connecting the Nanode was still a little tricky. First I had to figure out some things at the local-area-network level, such as divining the hardware media access control (MAC) address used to identify the board on the physical Ethernet network. Learning how to read a value from a server on the Internet also took some time.

Coming from a Web programming background, I had difficulty getting my head around creating microcontroller code to handle connections and process the results, so I decided to keep the Nanode software fairly dumb. I programmed my Nanode to read just a single value from the Internet and move the barometer’s needle to a position based on that value. The hard work of determining that value would be done on a Web server, where I set up a Flask application on the Heroku cloud application platform. Flask is a lightweight framework for creating websites that use the Python language. It’s great for simple applications that don’t require a database. Heroku is a good fit for hosting Web applications made with Flask, and it’s free for low usage.

Next I had to decide what data to gather and how to boil it down to a single value. The U.K. government’s Met Office provides an API that gives 3-hour forecasts for 5000 locations across the United Kingdom, detailing 30 weather types (mist, drizzle, sleet, thunder, and so forth) along with the wind speed, temperature, and pollution level. For public transport information I used the Live Tube API from Transport for London, which tells you if a station is open (I wanted to know about Brixton station) and the status of each line (in my case, I was just interested in the Victoria line).

To turn the weather and transportation data sources into something meaningful, I started with the number 100, which means “You really should cycle!” The Python code deducts points for bad weather: 10 points off if it’s under 15 °C, 30 points off if it’s going to drizzle, 75 points if it’s going to thunder, and so on. Points get added if the Victoria line is not running in good service or if Brixton station is shut. Once all the additions and subtractions are done, my Flask application outputs a number between 0 and 100, which the Nanode reads as plain text.

Having lived with the Barometer for a few months, and with a little tweaking of the weightings, I’ve found it surprisingly accurate, although the weather’s been pretty bad, so it’s mostly been pointing at the Tube sign! There’s still room for improvement, though—I’d like to add information about daylight hours and maybe real-time pollution data.

The Barometer has also triggered ideas for future projects that take small chunks of information from the Web and display it on Ventilation system: I’ve just finished a whiteboard with six dials that uses a projector to display arbitrary values from a Google spreadsheet based on the dials’ settings. I’m also thinking about building something for my brother that tells him about conditions at his local golf course.

Moving from paper passports to plastic electronic IDs, will change the way people do business and communicate with the government, Nikiforov said. The chip inside the card will be capable of storing official information, like passport details and a digital signature, and additional data, such as travel documents or shopping coupons, as well as the cardholder's personal data, the minister said.

Regarding mobile number portability, or MNP, by which mobile subscribers can switch providers but keep their number, Nikiforov said, it needs to happen soon in order to bring more competition to the mobile communication market. Mobile companies will compete for each user's business to prevent their switching to other operators.

A law mandating MNP was signed by President Vladimir Putin in December last year, but faced opposition from mobile network operators, who blame high costs and incompatible infrastructure for the delays with its deployment.

Previously, Nikiforov said that mobile operators "may try not to be ready" for the planned introduction of the MNP on Dec 1. However, Deputy Prime Minister Arkady Dvorkovich said Tuesday that he expects it to happen on schedule. "I assume that everything can be done on time," Dvorkovich told reporters. "But if there is a delay, it won't be much, two to three months maximum."

National roaming is another problem that the Communications and Press Ministry is determined to solve, Nikiforov said. "It is some sort of a travel tax that you, business people, pay when you travel between regions in the same country, within the same economic space."

Recently appointed Russian Post CEO Dmitry Strashnov and Rostelecom chief executive Sergei Kalugin were also present at Tuesday's forum and answered questions regarding strategic development of the state-funded postal service and the long-distance communications provider. They answered questions from business people about delays with international parcel delivery and internet connectivity in remote areas.

没有评论:

发表评论