Possession of any amount of marijuana is illegal even if it is just residue or waste. The 5th degree possession charge seems appropriate. However, a good lawyer may be able to help you avoid a conviction for that charge.
Assuming the matter is in a Minnesota state court (not federal), in my view, charging pipe residue as if it were hashish is just plain wrong. The punishments enumerated in Minnesota statutes are equal for Marijuana and Tetrahydrocannabinols in all but one instance. The only difference is the decreased penalties for the possession of, or distribution without remuneration of, a small amount of plant-form Marijuana. This provision does not include Tetrahydrocannabinols. The statute specifically excludes the "resinous form" of Marijuana from inclusion in the definition. Case law refers to Hashish as the resinous form of Marijuana and generally holds that Marijuana and Hashish should be treated equally under the law; and discusses how to identify hashish. Pipe residue simply is not hashish, regardless of any overreaching police officer or prosecutor. You will need a good criminal lawyer, experienced in marijuana cases, to help defend you.
Much will depend on the testing results that come back from the BCA, which will take an eternity, because recently, the BCA declared it will be suspending trace and residue testing. See the link here:
You need an experienced criminal defense lawyer that understands the shortcomings of chemical testing in labs in Minnesota, and who is willing to take the time to research judges in the area and their approach.