Mariusz Baczek, 36, of Cloister Way, Grimethorpe, pleaded guilty to producing a class B drug and possession of a controlled drug with intent to supply at Sheffield Crown Court on August 14.
He had been arrested on May 12 and charged a week later, receiving the sentence - which is suspended for two years - at Sheffield Crown Court on Friday.
Officers acted on information received from the public and gained entry to the property, finding a locked room for which Baczek had hidden the key.
PC Pete Jackson said: “This is an excellent example of where the concerns of the public were acted upon leading to the arrest.
“Through information received we have been able to prevent the drugs from getting onto the streets of Barnsley.
“A proceeds of crime hearing will now take place to ensure that any money or assets gained from the production of the drugs is recovered.”