Police officers noticed Daniel Jessop trying to put something in his mouth as they were searching him on December 13, for an unrelated matter.
They found a slip of paper containing brown powder, which analysis showed was diamorphine, said Robert Carr, prosecuting.
Jessop, 39, of Smith Street, admitted possessing the Class A drug when he appeared at Mansfield Magistrates Court on Wednesday.
Yvonne Wragg, mitigating, said Jessop had a “fairly weighty record of previous convictions” for drug-related offences, but that he was “slowly turning his life around.”
“He is trying to keep his head down and keep out of trouble,” she said.
He was fined £120 and ordered to pay a victim surcharge of £30.