WASHINGTON (Reuters) - An American student detained in Iran who was freed this month under a prisoner swap said on Thursday he was accused of trying to overthrow the Iranian government and held for nearly a month in solitary confinement.

Matthew Trevithick, who had traveled to Iran to study Farsi, told CNN that interrogators at Iran’s Evin Prison also accused him of having access to millions of dollars and knowledge of secret weapons caches.

In his first television interview since his Jan. 16 release, he described his 41-day ordeal, including how he was captured and his treatment and conditions at the prison.

Asked what he would tell tourists or students considering travel to Iran, he said: “I wouldn’t advise that they go, sadly.... Unfortunately, I don’t think the time is ready for you to go.... I would not encourage people to go to Iran.”

The Massachusetts native had traveled to Iran in September, planning to spend four months at a center affiliated with Tehran University, his family has said.

Trevithick told CNN he was finishing his studies and making plans to go home for the Christmas holidays when he was picked up and driven straight to prison. He said he spent 29 days alone before being moved to a cell with other prisoners.

A jailer asked if he knew Jason Rezaian, the Washington Post journalist who had been held for more than a year in Iran.

“I said of course, the whole world knows Jason Rezaian,” he told CNN. “And he said ‘He’s never leaving and neither are you.’ And that’s when you know it starts to hit you ... I’m a prisoner.”

Trevithick was freed with four other Americans being held, including Rezaian, in a swap that came just as the United States and other world powers implemented a nuclear deal with Iran.

He told his accusers it would be difficult to overthrow the government with the tools he had: “some Farsi textbooks that I’d purchased in Iran, a newspaper, some flashcards and some pens.... They said. ‘Well it’s not our plan, it’s yours’.”

He said interrogators tried to videotape a confession admitting to attempts at overthrowing the Iranian government, but he refused.

Since returning, Trevithick went to eat a hamburger with his mother and is looking forward to watching the new Star Wars movie, according to CNN.

“It’s fantastic to be back,” Trevithick said.