When I was a teenager a blocked pipe caused the backyard of my family’s house in south Dublin to fill with sewage; with my mother I waded through the dull, brown water in wellies, attempting to solve the problem, before we finally called in professionals, who unblocked the drain with high-pressure hoses. Most of the time, for most people who live in modern cities in wealthy countries, the sewage system runs smoothly, invisibly. But along every street in practically every city around the world, rivers of foul liquid are flowing just beneath the surface.

The largely invisible underground network of pipes that carries wastewater from our homes generally goes unnoticed until something happens to make us aware of its presence.

When we think of sewage we tend to think of human excrement. Drainage professionals use the term “wastewater”, which is not a euphemism; it reflects the fact that most of what enters the sewer system is water, from showers, sinks, washing machines, dishwashers, toilets, industrial processes, and rain.

In The Big Necessity, her 2008 book about the management of human waste around the world, Rose George pointed out that almost half of sewage in Ireland was treated only to primary levels – screened for lumps – and called this a “rich country with an infrastructure more suited to a poor one”.

A glance at an Environmental Protection Agency map that shows hundreds of outfall pipes around the country confirms this judgment.

Before Dublin had a sewer system, the city’s streets often served as open drains; cesspools full of sewage festered behind houses and bred disease. In 1773 and 1774 legislation was passed and a board formed “for paving, cleaning, lighting, draining and improving the streets”. New sewers were paid for by rates levied on residents. Householders would occasionally refuse to co-operate, and as a result those drains weren’t laid, remained incomplete or were filled in.

On Braithwaite Street in the middle of Dublin in 1798, the Rev James Whitelaw found severe overcrowding (for example, four families sharing one apartment) and swarming vermin. He recorded that human waste was flung from the windows of the buildings into the backyard, building up in heaps that reached the first floor. When it rained heavily the heaps of shit would ooze on to the streets, as “there is not one covered sewer in that populous portion of the Liberty south of the street called the Coombe”. And the problem was not restricted to the Liberties.

Dublin’s most significant thoroughfare, Sackville Street (later O’Connell Street), had cesspools as late as 1816. By 1849 about 55km of sewers had been constructed in the city.

Some of the drainage infrastructure built in the 19th century remains in use: Robert Buckle, a Dublin City Council area engineer, says he believes the oldest intact sewer, which is still in use in Cornmarket, dates back to 1852.

Whiffy Liffey

The Dublin Main Drainage Scheme, completed in 1906, saw the construction of large sewers under the Liffey quays that intercepted most of the sewage that had previously flowed into the river. The north sewer crossed beneath the river near Eden Quay, joining the south sewer in its progress towards the new processing plant at Ringsend.

In 1958 the North Dublin Drainage Scheme was completed: a large sewer now ran across the north of the city from Blanchardstown to Howth, where untreated sewage was pumped into the sea. Although the main purpose of the North Dublin Drainage Scheme was to alleviate overloading in the existing north Dublin sewers, it also provided capacity for the expansion of the northern suburbs.

In the 1970s a large sewer was built along the south bank of the River Dodder in south Dublin, running from Tallaght to Ringsend. This high-capacity drain took wastewater from the suburbs between the mountains and the southern city – Templeogue, Rathfarnham, Churchtown, Dundrum – while enabling the growth of residential and industrial areas in the western suburbs.

The Grand Canal Tunnel, which runs five kilometres from Dolphin’s Barn to Grand Canal Street, is as wide as a London Underground tunnel. After recent extensions it now brings sewage to Ringsend sewage plant from as far away as Ratoath, in Co Meath – a distance of 27km. In 1998 an undersea tunnel was built to run from the pumping station at Dún Laoghaire across Dublin Bay to Ringsend, in an effort to eliminate sewage discharge to the coast.

Two years later an extensive network of sewers was built across the northern fringe of Dublin, skirting the M50 motorway and reaching from Finglas through Santry and Coolock to a pumping station in Sutton, from which an underwater pipeline was built across the bay to Ringsend, consolidating the treatment of sewage from the north and south city in a single plant.

As late as 1999, sewage sludge from the Ringsend plant was dumped from barges into the sea in the vicinity of Baily Lighthouse, just off Howth Head.

Central control room

When I started thinking about what happens after we flush our toilets I pictured a central control room where sewage could be tracked as it moved through the city, and I wondered if such a thing existed. It turns out that it does, more or less.

Alan Vickers works in the drainage-services division of Dublin City Council. When I meet him in a conference room at the council’s offices he powers up his Panasonic Toughbook to show me what’s going on in the sewers. At certain key points in the system are what Vickers calls flow monitors – sensors that track the flow, depth, pressure and volume of sewage moving through the pipe.

Vickers picks up his mobile phone and dials a local number. The call is picked up on its first ring and answered with a squall of electronic noise similar to what you hear when you dial a fax number. This noise is coming from a modem connected to a sensor in the sewers: each sensor has its own phone number. New technology means that more recent sensors can use wireless Sim-card-based systems. Some sewers have landlines; others have mobiles.

A few days later we go to see the sewer Vickers had dialled. We find it under a small manhole in a housing estate in Chapelizod. We have been driven here by Christy Maguire of the drainage division, who lifts the manhole using a long crowbar-like iron tool that he calls a key. I look into the opened sewer. The pipe is about double the diameter of the 23cm pipe that we can see joining the main sewer at an angle, carrying wastewater from the rows of houses south of where we stand. A moderate amount of brown liquid flows at a gentle pace through the main sewer below.

Brain drain

In a sports field in the grounds of University College Dublin we look at a much larger sewer, 150cm wide. Vickers and Maguire lever the shamrock-shaped manhole cover, this time using two keys they have brought with them. Below us the contents of the Dodder Valley sewer drain at high speed in the direction of Ringsend. There is a strong smell of excrement, with strange notes of bleach and washing powder.

Vickers tells me that during periods of heavy rainfall the pressure in the sewer at UCD has been known to become so great that the manhole cover – which took two people to lift – has been blown off and sewage and other detritus spread up to 10m around the opening. I spent a largely uneventful period studying at UCD, and it strikes me that this was by some distance the most exciting thing that had ever happened on the campus.

A few days later I visit the wastewater-treatment plant at Ringsend. Michael Kenny, Dublin City Council’s senior engineer at the plant, leads me through a pair of tall metal doors beside which is a sign, with black text on a yellow background, that reads “Stop odours please keep doors closed”.

Inside the low-slung building the noise is relentless, and we have to raise our voices to make ourselves heard. A series of grey metal machines stand along one wall. Industrial metal panels serve as a floor, below which channels of raw sewage rush. This is where the treatment of Dublin’s wastewater begins.

“There’s seven channels, and it all comes through here, and then these are the screens,” Kenny says, “what we call bar screens, loads of bars, and there’s a six-millimetre gap between the bars. So when the water flows through, the solids – or the rags, as we call it – get caught on the screens, and rakes come up and just rake off the screens.”

He gestures towards a machine he has opened up. Long metal combs with serrated teeth draw sodden grey shreds of material from the foul water below. “When I say rags, this is what I’m talking about. It’s like baby wipes and” – “Stuff that doesn’t get broken up?” “Yeah, sanitary towels, condoms, all that kind of stuff.”

Rags and grit

We walk out of the building. Below us you can hear water rushing, and to the left is a series of covered tanks: the grit tanks, where inorganic material is removed from the process. “The first thing we do is take the screenings out, or the rags,” Kenny says. “And the second thing is to take the grit. The grit is basically what gets washed off the roads. It’s like sand or small stones. If they are passed forward into the process they increase the abrasion in the pumps and all the mechanical equipment.” Fats, oil and grease are also removed from the wastewater at this stage.

Whatever sinks to the base of the tank is spat out by two large plastic tubes into a long grey skip. Without getting any closer than is necessary I have a look at the black-brown heaps of grit that have built up in the skip. There are stones, as you’d expect, but the grit heaps are also dotted with a startling number of bright yellow specks that stand out against the dull background. It takes me a second to realise what I’m looking at. “You do get some organic stuff, like sweetcorn,” Kenny says. I am now feeling slightly unwell. That sweetcorn has passed through the digestive systems of Dubliners.

Once the sewage has passed through the grit tanks it’s pumped into one of 12 primary-treatment tanks, which separate solids from liquid. The primary-treatment tanks used at Ringsend are a type known as lamella tanks. Kenny says that inside each one are plates mounted at an angle to accelerate the settlement of the solids, and that scrapers at the bottom of the tanks move the solids to one side.

When the original plant opened, in 1906, the scraping of sludge from the primary settlement tanks was done manually – a disgusting job for which I hope, but doubt, someone got well paid.

When the sewage has settled in the lamella tanks the liquids are channelled away and the sludge is pumped into a holding tank, from where it will be drawn for further treatment. As the liquids still have an amount of suspended solids floating in them, they’re sent for secondary treatment, in huge tanks called sequencing batch reactors.

Bubbling water

We stand in the open air at the base of a steep metal staircase that leads up one side of what looks like a concrete multistorey car park. The dull grey sky stretches south towards the Dublin Mountains, just visible on the horizon. The sound of bubbling water is audible from the tanks above, which are exposed to the elements.

“You’re not afraid of heights?” Kenny asks.

“Not really, no.”

Perhaps I should have been more honest. I don’t like heights. When I climb more than a couple of storeys high my inner ear starts to spin. But I have gone to considerable effort to secure this guided tour, so I decide to follow Kenny up the steep metal staircase. It brings us to a narrow platform above a network of 24 tanks, each seven metres deep. I am wearing safety glasses, a hard hat and a high-visibility jacket; although the possibility isn’t discussed, I assume the latter will be handy for locating me if I fall into a tank of sewage.

I look across the plant back towards the city. To my left I can see Sandymount Strand curving southwards. Behind me the open tanks of wastewater bubble through their treatment cycles. Beyond them the imposing chimneys of the old Poolbeg power station remind me that heights are relative. As Kenny speaks I take notes, juggling a pen, a notebook and a digital camera.

Like draining pasta

We walk across a metal bridge that brings us directly above the tanks, the dark liquid just beneath our feet. Huge pipes roar next to one, bubbling tank. This is aeration: wide pipes pump air into the base of the tank. During settlement the remaining suspended organic material falls to the tank’s floor. Decanting consists of lowering the walls of the tank in order to tip the cleaner water from the surface while leaving sludge at the base – like tipping the boiling water off cooked pasta. Once the water is gone the equivalent of a plug is pulled and the sludge drips away, joining the sludge from primary treatment in a holding tank.

Kenny tells me about what he calls “bugs” – micro-organisms that digest the organic waste in the water – and how they’re naturally present in the sewage; you just have to create the right environment for them to flourish.

Having crossed the metal bridge, we descend on the east side of the tanks, the Poolbeg power-station side. To our right a green pipe leads out from the tanks to a building where the water is treated with ultraviolet light, which kills bacteria and pathogens, before being pumped out into the mouth of the Liffey, through an outfall pipe that runs under the power station.

Kenny and I walk from the stack of bubbling tanks to the other side of the site. The next stage of the process takes place in a building full of tall chrome canisters surrounded by piping. The canisters look like enormous milk pails, 10m tall. Kenny explains that they act as huge pressure cookers that treat the sludge in a process called thermal hydrolysis. This leaves the sludge molecules primed for anaerobic digesters that, as he puts it, “eat the solids” and produce methane gas.

The digesters consist of a set of four wide grey silos that stand next to the thermal-hydrolysis building. The sludge is pumped from there, brought to about 38 degrees – body temperature – and then propelled into the digesters, which break it down further, into solids and biogas. The biogas then passes into a storage balloon, which resembles a huge golf ball, and is used to power a generator, which feeds electricity back into the grid.

The solids are pumped through a surprisingly narrow silver pipe from the digesters into a nearby building, in which they are heated in rotating ovens to 450 degrees; several people I talk to refer to this process as “pasteurisation”. Kenny tells me that they are the same kind of ovens used by Guinness to roast hops.

Later, this dark material, with a consistency now somewhere between that of a powder and that of a pellet, will be driven away to be used as fertiliser on farms in Carlow, Kilkenny, Tipperary and Wicklow.

Sludge Register

At the drainage desk in Dublin City Council’s headquarters you can consult a list called the Sludge Register, which gives details of all the people who’ve bought the dried fertiliser produced from sewage sludge in Ringsend. In its dried state the product is frequently referred to as biofert. When the product hasn’t been dried, and exists in a wet form, it’s referred to as biocake. Both are also referred to as biosolids.

As I read through the Sludge Register I note the names and locations of people who have bought biofert – mainly farmers in largely rural counties but also the odd one in rural west Co Dublin and a couple of GAA clubs in Wicklow.

According to the Environmental Protection Agency’s 2012 report on urban wastewater, 106,788 tonnes of sewage sludge was produced nationally in 2009; 62 per cent of this was reused in agriculture.

But the use of biosolids is controversial. A number of leading food organisations and companies, including Bord Bia, Glanbia, Dairygold Co-op and the Irish Grain and Feed Association, ban the use of biosolids. Tom Kelly of the Irish Grain Assurance Scheme, an umbrella group for grain production in Ireland, emails me about biosolids, saying that “there are too many ‘unknowns’ with this product, therefore there is a potential food safety risk. This could have the potential to cause very serious damage to our industry.”

Dr Karl McDonald of the Food Safety Authority of Ireland says that there has been “a commercial decision by certain companies” not to allow the use of biosolids but that he believes “the controls for use are more than sufficient”.

The traffic of sewage through Poolbeg forms part of a cycle: the sludge produced at the treatment plant is reused as fertiliser to help grow food that residents of Greater Dublin eat and excrete. Their sewage in turn is flushed through the city’s underground network of sewers to the Poolbeg plant, and so the cycle continues.

This is an edited extract from Hidden City: Adventures and Explorations in Dublin, by Karl Whitney, published by Penguin Ireland, €18.99. © Karl Whitney 2014