Dwyer told Judge Michael Uhlarik that Wells has a documented history of major mental illness.
Wells was also arraigned in an earlier incident in which Salem police found him wandering around Bertram Field, which was closed at the time, allegedly carrying a knife. A not-guilty plea was also entered in that case.
He is due back in court on both cases on Nov. 8.
Courts reporter Julie Manganis can be reached at 978-338-2521, via email at email@example.com or on Twitter @SNJulieManganis.