The sun is still high in the sky on a June evening in Barcelona when Juan Blanco, Cisco’s (CSCO) business development director for southern Europe, takes me on a walk through the city’s medieval quarter, with its twisting alleyways and sidewalk cafés spilling over with people. As we enter a cobblestone square where the centuries-old El Born market hall stands, Blanco asks, “Notice anything unusual here?” At first I don’t. It looks like a typical Mediterranean city in full summer splendor, with nothing out of place—nothing, that is, until I look up and spot the curved plastic shields affixed to the lampposts at a height of about 30 feet, each with a few metal boxes inside. “Those?” I ask.
Those, indeed. The boxes are no regular electricity meters. They are fine-tuned computer systems, capable of measuring noise, traffic, pollution, crowds, even the number of selfies posted from the street. They are the future of Barcelona, and in some sense they are the future for all of us too. The hard drives are just one piece of what is “unusual” on this street, in fact. Cast your eyes down, and you might spot the digital chips plugged into garbage containers, or the soda-can-size sensors rammed into the asphalt under the parking spaces.
Then again, you might not notice anything. Discreet and largely unannounced, the changes in Barcelona have slipped by even observant residents and the millions of tourists who pour into Spain’s second-biggest city every summer to soak up its tapas, music, and beaches. Yet the stealthy transformation is profound and potentially so sweeping that no one is sure where it will lead. “Our lives have changed totally in the past 10 years thanks to smartphones,” says Josép Ramon Ferrer, a telecom engineer who until late June was Barcelona’s smart-city director, charged with shepherding its digital overhaul. “The management of cities has not changed that much until now. But in the next 10 years, cities will change totally.”
If you want a glimpse of the very near future, one good place to start is this graceful, breezy seaside city of about 2 million people. In times past, Barcelona was famous for its revolutionary artists, like the painter Joan Miró and the architect Antoni Gaudí. But in just the last four years it has carved out a role in a revolution of a different kind: creating a blueprint for the city of the 21st century at a moment when urban dwelling is ever more predominant. According to the UN, about 84% of people will live in cities by the end of the century.
Whether in cities or villages, our modern lives are already saturated in vast amounts of data. The dimensions are almost impossible to grasp: 104,000 YouTube videos are streamed every second, and 2.4 million emails are sent per second. Or rather, those were the figures at the time that sentence was written; they are accelerating at warp speed. The market intelligence organization International Data Corp. (IDC) estimates that by 2020, about 30 billion embedded devices—the Internet of Everything—will monitor and manage countless activities in our lives, from the moment we awake to the moment we fall asleep, from catching the bus to filling the refrigerator, walking the dog, and watering the garden.
For cities the possibilities seem endless. Officials around the world who find themselves grappling with tight budgets and rocketing bills have seized on this tsunami of data as a way to cut costs and overhaul systems that have barely changed in decades. Juniper Research, which this year ranked Barcelona its No. 1 smart city, estimates cities will save about $17 billion a year in energy bills by 2019 by installing smart streetlights and devices like parking and garbage sensors. “The smart-city concept is barely off the ground,” says Juniper senior analyst Steffen Sorrell. “The endgame figure will be much larger.” Indeed, McKinsey Global Institute says in a June report that by 2025 cities will save up to $1.7 trillion a year in delivering services if they deploy new digital systems on a large scale.
For all the eye-popping estimates of future savings, the financial promise remains largely abstract, however. Cities sign on, many at little cost, believing the projects will pay off big. In Europe the EU has committed funds for some cities to upgrade their systems, masking the true expense. “Many of these are pilot projects funded by suppliers or R&D funds,” says Eric Woods, research director in London for the U.S. analytics company Navigant Research (NCI). “It will become so cheap to include a sensor in a waste collection point, and to collect the data, that service operators will do it as a default.”
Clearly city officials are hoping the outsize estimates of savings prove true. Boston, for example, has inserted sensors to monitor transportation, parking, and energy use, and installed solar-powered street benches that measure pollution and noise. London is developing 3-D maps of its underground wires and pipes to try to stop different utilities from repeatedly digging up the same roads. Hamburg’s port, which handles about 10,000 ships a year, recently computerized its loading systems to synchronize offloading and reduce diesel-choking traffic jams.
The smart-city rush extends beyond the affluent West. Indian Prime Minister Narendra Modi promised during his election campaign last year to build or retrofit 100 wired metropolises by 2022 at a cost of $1 trillion. In June the Indian government published a call for companies to compete for a major rollout of smart-city systems. Its “request for interest” report makes enticing reading for tech companies: The government estimates that about 500 million people—40% of the country’s population—will live in Indian cities by 2030. And all of those, it says, have a “crying need” for high-tech infrastructure. The benefits for cities seem clear: more ordered, clean, coordinated services, at lower cost.
The tech companies that build this new infrastructure stand to gain even more. IBM (IBM), Cisco, and Microsoft (MSFT), all of which have invested heavily in developing and manufacturing pieces of the infrastructure, see cities as a key to growth. Navigant estimates that by 2023 technology companies will do about $27.5 billion a year in smart-city business.
To hear Blanco of Cisco tell it, the world is moving to a business equivalent of the clash between ancient city-states. “In the 19th century empires competed. In the 20th century countries competed,” he says. “In the 21st century cities compete.” He tears a piece of paper from my notebook and draws a graph with a straight upward slope. “Cisco’s revenue over the last 20 years has very closely tracked the growth of Internet use,” Blanco says. “This is very simple math. The more people there are on the Internet, the more we grow.”
The term “smart cities” was barely in use when Cisco began testing its ideas in Barcelona in 2011. The company had invested heavily in Songdo, a South Korean business district built from scratch almost as a high-tech experiment, with a network of sensors controlling everything from escalators (they move only when someone steps on them) to classrooms (remote connections with schools abroad). But there were limited numbers of brand-new “green field” places in which to invest. Cisco knew it would need to sell systems to creaking old cities if it was to grow its smart-city business.
Barcelona, which dates back to the ancient Romans, proved an ideal candidate. Its mayor, Xavier Trias (one of Fortune’s 50 World’s Greatest Leaders last year), had argued during his election campaign in 2011 that Barcelona’s economic future would increasingly depend on digitizing its public services. Spain was then languishing through its worst recession in decades, deep in debt, with one in four young Spaniards out of work. Hundreds of thousands of protesters calling themselves indignados were regularly storming the streets of Barcelona and Madrid, burning barricades and raging against austerity budgets.
To tech companies, none of that mattered. Barcelona already had a thriving startup scene: As part of hosting the Summer Olympics in 1992, it had converted its abandoned textile-factory district into a tech hub called @22, which now houses dozens of startups, and laid a network of fiber-optic cables that today covers 310 square miles. The existing fiber-optic cables alone cut the upfront cost of the smart-city programs from what might have been 300 million euros to about 30 million euros, according to Ferrer. Another factor made Barcelona gold for tech giants: Barcelona Football Club, one of the richest, best soccer teams on the planet, and the Mobile World Congress, which about 90,000 tech executives and journalists attend each March. “This city has international branding,” Blanco says. “So anything we develop we can expose to the rest of the world.”
Like most cities, Barcelona had added services haphazardly over the decades. Vicente Guillart, who runs the Institution for Advanced Architecture of Catalonia, says he was initially skeptical, believing smart-city tech was “just about companies trying to sell you something.” He was won over after studying Barcelona’s tangled services and signed on to become chief architect under Trias. “Before, the city was organized like silos,” he says. “Lighting didn’t talk to traffic didn’t talk to water. Each had its own budget with its own data and its own cameras.”
Underground, the wastefulness looked worse. “Five years ago you could go into a tunnel under Barcelona, and there would be four or five different telephone cables,” says Cisco’s Blanco. “Each was fiber optic. And each was using about 5% of its capacity.” The solution was to knit the services into one system under a single company—the Spanish tower operator Cellnex Telecom won the bid—to run the network and sell spare capacity, generating revenues for the city.
Only parts of Barcelona have been rewired so far. But the results are already visible. Sensors measure how full trash containers are, allowing garbage trucks to empty them only once they’re filled. Parking-space sensors tell drivers, via a phone app, which are vacant, so they avoid circling around. Barcelona reworked its bus routes into an efficient grid rather than the confusing tangle that existed before, increasing ridership 30% in four years. Electronic bus stops now show schedules and local sights, and could soon have ads tailored to the neighborhood.
Those sleek new lampposts along the grand avenues? They are not for aesthetic beauty. Hollow inside, they have fiber-optic cables running up them. Each has its own IP address, turning it into a telecommunications tower, with the capability to monitor crowds, noise, weather, and traffic from a Wi-Fi router on top. Now if a crowd of drunken tourists wakes up El Born neighborhood at 2 a.m. (a frequent gripe), there is no need to call the cops: They already know the precise decibel level.
Once in place, all this technology is astonishingly simple to manage. One afternoon Jordi Alvinyà, commercial-strategy director for Cellnex, takes me into Barcelona’s high-security control center, which adjoins the tower Norman Foster designed for the Olympics, with jaw-dropping views. Inside, some 10 engineers in shorts and sneakers sit at screens, monitoring beeps and flickers that tell them in real time whether a streetlight is dead or a pipe is leaking. As we walk out, Alvinyà glances at a refrigerator-size box. “All the policing and security of the city is in that,” he says.
Barcelona officials believed another step was crucial: creating an operating system to run the entire city within one interface. In a café on the Passeig de Grácia, the city’s main boulevard, the outgoing smart-city director, Ferrer, whips out his iPhone 6 to show how he hit on the concept. “For me the cities of the future will be like a smartphone,” he says. “We have a lot of hardware, but it isn’t anything unless it interfaces with the OS. If there are 200 platforms and 200 providers, it is a mess and not sustainable.”
In 2012, Barcelona put out a tender for tech companies to create its OS. The bidding was fierce: 18 companies competed in a process that dragged on for months. In the end, Ferrer signed a contract in May with a consortium comprising Accenture (ACN), GDF Suez, and Cellnex to build the system, for the pittance of about $1.6 million. “It was nothing,” Ferrer says. “But for the companies, it was a chance for them to deploy solutions for a lot of cities in the world.”
It all seems to make a lot of sense. Certainly it’s logical that digital systems would drive down costs. But the smart-city world is replete with fuzzy projections, and the technology is so new that there are no concrete results to point to. Cisco estimates that Barcelona will see “cumulative economic benefits of 832 million euros by 2025,” including 86.4 million euros in extra tourist spending, but offered little explanation of how it arrived at those figures.
That makes Barcelona a testing lab for a transformation that has only just begun. Four years after Cisco invested in Barcelona, Blanco now shuttles between Barcelona and his home down the coast in Valencia, meeting a parade of city officials who have flown in from New York, Los Angeles, Buenos Aires, Dubai, Qatar, China, Kazakhstan, and elsewhere to examine how they can replicate the smart-city ideas; about 200 delegations have visited during the past year alone. “We don’t necessarily make money in Barcelona,” Blanco says, “but we will make it elsewhere, in other cities.”
Companies are betting there will be billions to gain once Barcelona’s OS is operating and can make sense of the mountains of data the new technology sucks up. Consider for a moment the possibilities of Wi-Fi-fitted lampposts, each with its own IP address, monitoring the numbers of Facebook posts, tweets, or credit card swipes as you stroll by with your smartphone (which identifies where you are from) and withdraw cash, buy shoes, drink a soda, and visit a museum. “We have millions of people coming off cruise ships, many of them Americans with higher incomes,” Cellnex’s Alvinyà tells me.
When I tell Alvinyà I don’t want my movements tracked, he says, “Then use cash and leave your phone at home.” Of course, most people do neither. “It is almost impossible for tourists not to send a photograph to friends back home,” says Alvinyà, describing the gold mine of data the city will finally tap. Then, he says, “we can know where you are from, where you are shopping, and at what hours.”
The prospect of a new incarnation of Big Brother leaves many people uneasy—as Rio de Janeiro discovered. As part of Rio’s World Cup last year, IBM built a command center to knit together 30 service agencies and monitor floods, fires, and other potential disasters. It sounded positive until Mayor Eduardo Paes boasted that it “allows us to have people looking at every corner of the city, 24 hours a day, seven days a week.” His words sparked outrage among some residents.
So far Barcelona has avoided the resentment. And by 2021 it will have its biggest data hub yet: Barcelona Football Club’s new state-of-the-art complex. The team, which has star players Neymar Jr. and Lionel Messi, packs every game in its current 90,000-seat stadium, giving the club an extraordinary 600 million euros in yearly revenues, according to Josep Maria Bartomeu, the club president. But its new 105,000-seat stadium will offer new revenue streams by linking fans directly to merchandising with free Wi-Fi. It will also remove the fences around its 54-acre compound, which draws about 1.7 million tourists a year, creating a smart-city neighborhood in the middle of Barcelona. “We will have a permanent connection with technology,” Bartomeu says. “Companies will get information about people who are there from all over the world.”
That data collection is already underway. In September, Microsoft assigned Bismart, a local big-data startup, to analyze the spending of some of the 2 million people partying at Barcelona’s annual four-day festival. Bismart monitored the credit card swipes of 448,000 tourists. The results were revealing. “We found that French people camp [rather than stay in hotels], and British people don’t spend anything,” Bismart CEO Albert Isern says. In years past, marketing companies would have tried to find those results by questioning tourists. “Manual surveys generally analyze 1% of data. Here we analyze 50%.”
For four years now, Barcelona’s smart-city program has seemed unstoppable. Then came May, when residents ousted Mayor Trias and voted in Ada Colau. She could scarcely be a more jolting contrast. At 41, she is 28 years younger than the business-friendly Trias and rose to fame as a feisty indignado, whom police arrested more than once during protests over apartment evictions. Colau vowed to rein in gentrification and tourism, which many feel are threatening to engulf Barcelona. She triumphed largely by casting Trias’s government as too closely tied to business, too focused on branding the city as a magnet for tech companies. “We have a real commitment to new technologies that go beyond just TV ads titled ‘Smart City,’ ” she told a reporter in April.
Ada Colau, Barcelona’s new mayor, rose to fame protesting evictions and seems less enthusiastic about smart-city spending than her more business-oriented predecessor.Photograph by Joan Tomás for Fortune Magazine
When I arrived in mid-June, one day after Colau’s inauguration, it was clear the smart-city brand had taken a knock. In her first month in office, Colau canceled Barcelona’s bid for the 2026 Winter Olympics and announced that the city would not do business with banks implicated in evicting delinquent mortgage holders. “We are going to change our focus to social issues, like analyzing which apartments are unoccupied, for example,” Bismart CEO Isern says. “Data is like a knife,” he says. “We can use it to cut food or kill people.”
So far, Barcelona’s new leaders are not sure what kind of knife smart-city technology is. When I catch Colau outside a meeting one morning, she says she “still needs to study the issue.” But the previous evening Barcelona’s new deputy mayor, Gerardo Pisarello, told me the new regime had a very different view from the smart-city cheerleaders they ousted. “We’ve spoken about smart citizens. That is what we need—not just a smart city,” he tells me. “We want technology to reach the poorest neighborhoods. That is what a ‘smart city’ is to us.”
Barcelona’s political earthquake has shaken smart-city devotees into realizing that not all politicians may share their vision about digitizing their cities, especially given the perpetual lack of cash. Those concerns are not unique to Barcelona. Indians have questioned whether Modi’s new smart cities will exclude poor people. Londoners have pooh-poohed some digital overhauls as a waste of their tax money. The technology might need to prove its true value (which, of course, it can’t do until a sizable locale rolls it out and gives it time to succeed or fail). “The need is clear in the cities,” says Woods of Navigant. “What is less clear is how cities roll out these solutions at scale, and how they will find the financial means to do so.”
In truth, it might be too late for Barcelona’s new mayor to stop the clock, given that many smart-city programs are already underway. The real wrangle will be over whether profits and social good can co-exist in harmony. “The Internet of Everything is going to happen,” says Guillart, the architect. “The only question now is, Who is going to rule it?”
A version of this article appears in the August 1, 2015 issue of Fortune magazine with the headline “The most wired city in the world.”