You can buy the detector at the Mos Eisley Cantina bar level hub. However, in order to buy it you need to find the corresponding power brick, #11. You should be able to find this one in Episode 5, Chapter 5 "Cloud City Trap" during free play mode. Just walk into the back of the X-Wing fighter at the very start of the level to get the brick.