Lamar Odom says he knew he hit rock bottom with his coke addiction when his wife, Khloe Kardashian, walked in on him getting high with a random chick in a motel ... calling it "one of the darkest places I've ever been."

The ex-NBA star opened up on "The Players' Tribune" -- explaining how his cocaine addiction consumed his life leading up to the overdose at a Nevada brothel in 2015.

"At that point in my life, I was doing coke every day. Pretty much every second of free time that I had, I was doing coke. I couldn't control it."

Lamar even quoted Rick James -- "Cocaine is a hell of a drug."

In the article, Odom also admits to cheating on Khloe -- and finally realized how out of control his life had gotten when she caught him red-handed with another woman.

"One of the darkest places I've ever been was when I was in a motel room, getting high with this chick, and my wife (at the time) walked in. That probably was like rock bottom."

"My dick and my habit took me down all the roads that you don't ever wanna go down."

Odom says he's sober now -- and is motivated by his family to stay clean.