Yeah you pretty much answered it yourself. The Empire was hiding its presence their until Vader sprung his trap. So when Threepio wandered from the group and accidentally stumbled upon a Stormtrooper (probably stationed nearby in case they try to run) he's blasted before he can warn the others. They then try to dispose of his body but of course Chewie manages to find it.
THREEPIO: Oh, I'm terribly sorry. I...I didn't mean to intrude. No,
no, please don't get up. No!
Chewie looks at Threepio in bewilderment, then scratches
his furry head. He gets an idea and adjusts some connections,
whereupon Threepio immediately begins speaking normally.
THREEPIO: Stormtroopers? Here? We're in danger. I must tell the
others. Oh, no! I've been shot!