A man who planted a spy camera in the female toilets of the studios where the latest James Bond film is being made has been jailed.

Peter Hartley, a convicted sex offender, used a miniature camera triggered by motion and vibration and positioned it behind a grill in the WCs at Pinewood Studios, west London, to try to record women on the lavatory on 21 June.

Hartley, who worked in maintenance, was caught after a freelancer working on No Time to Die noticed the light reflecting from the lens, similar “to light reflecting off the face of a watch”, and used a screwdriver to remove the grill.

Hartley, 50, was jailed at Aylesbury crown court for 16 months on Friday and will be on the sex offender register for 10 years.

Daniel Wright, prosecuting, told the court the device was marketed as a spy camera, and Hartley had used tape to cover its LED light to try to stop it being detected.

The defendant, who has a history of similar offences dating to 2008, contacted his public protection officer at the Metropolitan police that morning to tell him he had reoffended.

He has previous convictions for placing cameras in a council building in Coventry in 2009 and for installing one in the changing rooms of a leisure centre in 2016.

The 50-year-old has a total of three convictions for eight offences, though at his first conviction he asked for 113 offences to be taken into consideration.

When asked by police why he had placed the device in the studio toilets, he said: “I suppose sexual gratification is the main reason, as I’ve learned from my past whenever something bad or stressful happens I act out.”

Hartley, of Uxbridge in west London, said his partner had been in hospital undergoing tests for cancer when he committed the offence.

He later pleaded guilty to one count of voyeurism at Milton Keynes magistrates court.

In a victim impact statement, the woman who found the camera said she had needed mental health treatment and experienced acute anxiety.

She said: “I am not eating or sleeping properly and I don’t feel safe anywhere – I check the whole house for cameras. I don’t doubt that I will check every bathroom I go into for the rest of my life.

“I don’t believe he has any remorse. This was a deliberate act using high definition, wide angle and vibration-triggered equipment. He knew exactly what he was doing and must have seen the damage [to the victims] last time.”

The court heard Hartley had completed a sex offender rehabilitation programme eight months before reoffending. He claimed it had made him worse by “opening a Pandora’s box” in his mind.

The judge, Francis Sheridan, said the victim’s life had been “devastated by a dirty-minded individual who preys on women using the lavatory, where he can compromise them”.

Irfan Arif, defending Hartley, said his client was remorseful and he believed his offending was linked to being sexually abused as a child.