A 49-year-old with a cannabis farm in the upstairs of his house was only rumbled when a keen-eyed neighbour saw burglars raiding the property.

Officers who arrived at John Stokes' home not only found it had been broken into but that the bedrooms had been converted into a sophisticated drugs factory.

Now after hearing he only profited from the operation by getting a bit to smoke himself and was sorry for what he had done a judge spared him prison.

Claire Marlow, prosecuting, told Swindon Crown Court how the operation was uncovered by chance on Tuesday, May 27, last year.

"The police were actually called to the address on Greenham Walk, Park North, because one of the neighbours had called to say there was a burglary at that address.

"When they were there Mr Stokes returned. They discovered a cannabis factory on the first floor. Three bedrooms had been set up for growing of cannabis plants.

"There were 23 plants with an efficient watering, lighting and ventilation system in the three bedrooms."

She said a bag of drugs was also recovered and the total value of the cannabis recovered could have netted up to £12,500 in street deals.

When he was questioned by officers he said that he owed £27,000 and all he got from the operation was some for himself.

"It was in view of that debt that that is how he came to be there with this cannabis factory," she said.

Stokes, of Greenham Walk, Park North, pleaded guilty to a charge of producing a class B drug.

The court was told that sentencing guidelines put the case meant the maximum penalty was six months.

Mark Sharman, defending, said "His timely guilty plea is the best evidence of his remorse."

Despite the fact his client suffered from bipolar disorder, he said he was capable of undertaking unpaid work should he not be jailed.

"Not only is he able to do it he is keen to do it as reparation to the community for his wrong doing," he said.

"Mr Stokes is very keen to make what ever reparation he can to the community. There are concerns he might have some difficulty coping with his mental health difficulties in a custodial sentence.

"I ask the court to give him a chance to show it was an error of judgement that will not be repeated."

Judge Peter Blair QC said: "Having read really quite a lot about you it seems to me that it would be damaging to send you to prison straight away today, albeit you deserve it for the sophistication of what was being grown and plainly a part of that being to feed your own use of cannabis, for whatever reason, which you knew was completely illegal.

"Having regard for the guidelines that exist for sentencing people for what you have done I have come to the conclusion because you have pleaded guilty at an early stage, have no previous convictions and are able to keep out of trouble as you have for many years, I can suspend the sentence."

He imposed a three month jail term suspended for 18 months and told him to carry out 200 hours of unpaid work.

Speaking after the discovery PC Rachel Barnett, of the East Swindon neighbourhood policing team, said: “We were called to reports of a burglary which was phoned in by a neighbour.

"It is possible that one or two plants were taken in the burglary and a TV was stolen. It was not this person’s lucky day.

“We have been speaking to neighbours and doing house to house enquiries. They were all blissfully unaware of what was going on in this property.

“The community have been very shocked by the discovery. There are a lot of older people living in the area and it is quite scary for them really."