To be patentable as a utility patent, an invention must have three attributes: utility, novelty, and nonobivousness.
“Utility” means the invention must work and have value. False or misleading inventions such as perpetual motion machines are considered to lack utility (because they do not work) and are therefore unpatentable.
“Novelty” means that the literature does not record anyone ever making or conceiving of your particular invention. So if, for example, an old issue of Popular Mechanics shows your invention then your invention lacks “novelty”. However, is someone secretly previously conceived of your invention but no publication shows this, then your invention still has “novelty” and may be patented.
Novelty may also be lost, if you have published information about your invention before filing your application for a patent.
“Nonobviousness” means that your invention is sufficiently different from what has come before so that your invention is not an obvious invention or improvement over the prior art. So if you invent something new and novel but your invention or improvement is only a slight or obvious improvement over what already exists, then your invention is not “nonobvious” and is not patentable.
Now patents may cover most inventions but some inventions or discoveries, such as laws of nature may not be patented.
One bar to patents is the one year on sale bar. This means if you have been selling, or offering for sale, your invention more than one year before filing your patent application then your application should be denied. Now, there are legal arguments that during the period in which you selling your invention you were still developing it so the one year on sale bar should not apply. But, the general rule is do not wait a year before applying for your patent.