Donal Grace, who is 52 and from Edergole in the town, was arrested by Gardai at the hospital on November 20 last year.
Staff had called officers to the hospital.
Letterkenny District Court heard that Grace, who is originally from Dublin, suffered from a number illnesses including chronic back pain.
He took cannabis to relieve this pain, his solicitor said.
When Gardai arrested him he admitted possessing cannabis with a street value of €20 but insisted it was for his own use.
Judge Paul Kelly ordered Grace to make a donation of €100 to the Ardara Senior Citizen’s Christmas Ball.