A scalable, minimum node complexity, energy efficient, and error-resilient routing method for wireless sensor networks is described. The network is partitioned into regions by power controlled base station scans using a directional antenna. Routing is performed using only local location information and instructions received from the base station at each sensor node with minimum processing and control overhead, thus allowing simple, low-cost sensor designs. Sensors in the network provide to a base station reports of the condition of the sensors themselves, and these reports are analyzed by the base station to determine improved routing instructions, which are then provided to the sensor nodes in control messages. Each data packet is relayed in an interleaved, loop-free mesh of sectors toward the base station, making data delivery robust to sensor failures and transmission errors. The disclosure also contains descriptions for simple edge-based tasking, query, code distribution, and network programming for sensor nodes. The method is suitable for large-scale, dense sensor networks for detection, alarming, and monitoring applications.