Luke Mallaband, 23, was caught after a woman at the University of East Anglia (UEA)'s library in Norwich realised she was being recorded and reported it.
Mallaband admitted six voyeurism offences at an earlier hearing.
He was given the three-year ban and a six-month curfew at Norwich Magistrates' Court.
Mallaband, formerly of Norwich but now of Yew Tree Road, Walsall, was found to be at "high risk of posing serious harm to females", a probation report found.
Prosecuting, Louise Mantell-Sayer told the court a woman noticed a plastic bag in the gender-neutral toilet cubicle in UEA's library.
The bag had a hole in it which lined up with a hole in a box inside containing an iPhone set to record video.
The woman said she felt "disgusted" and "violated" by what happened.
In defence, Dave Foulkes said Mallaband had no previous convictions and had referred himself to a mental health team in the Midlands.
Police found 38 voyeurism videos on his phone filmed between July 2013 and February this year.
He will also carry out a three-year community order, a 200-hour sex offending behaviour programme and was told to pay Â£170 in costs at Norwich Magistrates' Court.
A former student who secretly filmed women using showers and toilets has been banned from entering female and gender-neutral loos.