Message Boards Message Boards


A Smart Programing Language for a Smart Cities Hackathon

Posted 8 years ago
0 Replies
4 Total Likes

On Friday, February 20th, I had the pleasure to be inspired by a group of young and smart individuals enlisted to represent Barcelona in the Global Urban Datafest. For this hackathon the organizers offered one Raspberry Pi platform per team and a variety of sensors to capture physical parameters. The event lasted three days and it was locally organized by Anna Calveras and Josep Paradells with the help of Universitat Politècnica de Catalunya, Barcelona's City Council, iCity Project, Urbiotica, IBM, and Wolfram Research.


I showed the hackathon participants that the Wolfram Language knows about thousands of kinds of real-world entities, and that everything in the language is a symbolic expression:

built-in model of the world

Then, I showed how easy it is to track usage in a bike sharing system in a smart city. To get the real-time data I used the CityBikes API. Importing and visualizing this data in GeoGraphics was straightforward:

     ColorData["DarkRainbow"][1. - (1 + (#[[3]] - #[[2]])/(#[[2]] + #[[3]] + .001))/2], 
     Point[#[[1]]]} & /@ ({Quiet[
       GeoPosition[{"lat", "lng"}/1000000.]], "bikes", "free"} /. 
     Import["", "JSON"]), 
  PlotLabel -> "Availability of Bicing bicycles in Barcelona"], 
 BarLegend[{"DarkRainbow", {0, 35}}]]

Barcelona Bicing

The data for Barcelona was obtained by running a ScheduledTask every 10 minutes. Below is the end result for Barcelona:

Heartbeats of Barcelona

Then I explained how I used a Raspberry Pi to digest Friday's bicycles data overnight. The microprocessor was set up to compute the total amount of bicycles available in different cities every 10 minutes from 3:30 am to 8:30 am CET:

Smart Cities

European cities showed a valley at 8am when people cycle to work. Citizens from New York and Mexico City were found to head back home around 5am CET.

Essential for this hackathon was the new Wolfram Data Drop platform, which works great on the Pi while connected to the Wolfram Cloud. The following is a dataset that I created for Barcelona's bike sharing system. Every three minutes the total number of parked bicycles was added to a Databin:

bin = CreateDatabin[]


 DatabinAdd[Databin["3k7NAGZG"], <| "bicycles" -> 
    Total["bikes" /. 
      Import["", "JSON"]]|>], 180]




One of the cool features of Data Drop, is that you can directly analyze this data through Wolfram | Alpha.

Another dataset that I created using a Raspberry Pi, was the pedestrian flow happening in the front door of my apartment. If any movement was detected by a PIR motion sensor, the RaspiCam would take a photo, and a new entry would be added into this databin:

Motion Track

DateListPlot[Databin["myDatabinUUID"]["TimeSeries"]["movementn"], Filling -> Axis]

Movements Counts

Then I showed how it could be set it up to monitor my home hall's activity in regular periods of time: Home Activity

Certainly, this opens a new world of possibilities. For example, you can use Data Drop to data fuse specific events from different devices. This was exactly what one of the teams did. They set up a Twitter account with ServiceConnect to inform about the current air pollution in Barcelona's "La Diagonal". Every 20 minutes they checked the latest values of ten gas sensors, and then a ListLinePlot with the map of sensors was generated and tweeted:

Gas Emissions

Other smart city projects involved the use of the new Machine Learning capabilities available in Mathematica 10, FindFaces to estimate the numbers of individuals in a bar, or BarcodeRecognize for a universal citizen ID card project. For most of the participants, this was their first encounter with the Wolfram Language. So I can't wait to see what they are capable of with just a little bit more of practice. I wish all you tons of happy smart coding!


If you haven't participated in a hackathon yet, check out the Smart City App Hack or the International NASA Space Apps Challenge. Also, feel free to contact us for future events, and don't forget to have a look at Create, Code, Deploy: Workshop for Hackathons if you missed it. Finally, if you are looking for a three weeks long hackathon, apply now to the Wolfram Innovation Summer School or the Wolfram Science Summer School 2015.

POSTED BY: Bernat Espigulé
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract