Police discovered that the first floor of the empty property had been converted when they broke into it.
Officers were requested to force entry to the property in Scopsley Green, Dewsbury, by Kirklees Council which said it had been abandoned.
Alex Bozman, prosecuting, said: “The first floor had been converted into a cannabis farm with 12 plants.
“This was dismantled and a fingerprint on the banister was linked to the defendant.”
Leighton Wood, 37, pleaded guilty to producing a Class B drug at the house following the raid on November 17 last year.
He was initially offered a police caution but then charged with the offence after failing to comply with a condition to attend a course run by the Drug Intervention Programme.
The cannabis set up included sophisticated equipment such as an automatic feeding system, a filter and extractor as well as a fan, transformers and lighting.
District Judge Michael Fanning, sitting at Kirklees Magistrates’ Court, commented: “It was very generous to offer him a conditional caution – it’s a pretty slick looking operation.”
But Wood, who appeared in custody, insisted that he set up the cannabis farm for his girlfriend at the time to stop her from purchasing the drug from dealers.
Ian Whiteley, mitigating, said: “He’s a mechanical engineer and went on the internet to find out what to do.
“He didn’t want his girlfriend to purchase drugs from illegal sources and it was an experiment for him.
“It was a sophisticated set up but there’s no suggestion it was for professional use.”
Judge Fanning sentenced Wood to a community order with 120 hours of unpaid work and six months of drug treatment.
He will have to pay £85 costs and £85 victim surcharge.
ORIGINAL ARTICLE BELOW