In this algorithm, we assum that the sensors are distributed linearly, just the as the testbed. At each step, the active sensors move to the specified position and get the temperature. Then, they store the temperature and the corresponding position to the shared central devices.
At the beginning, all the sensors are active and evenly distributed. From the first set of data from those sensors, one linear search is carried, and find the two adjacent sensors i and j, whose |(tempi - tempj)/(posi - posj)| is maximum. Here, tempi means the temperature get by the i-th sensor, and posi is the position of the i-th sensor. Sensor i or j will be choosed arbitrarily to carry the task thereafter, and all the other sensors are inactive. Let us suppose that sensor i is chosen. Sensor i keeps 4 values: temp_left, temp_right, pos_left and pos_right, where temp_left and pos_left are the temperature get by itself and the corresponding position, and temp_right and pos_right are the temperature get by sensor j and the corresponding position. When the i-th sensor get new read: temp and pos, it calculates
t_left = |(temp_left - temp)/(pos_left - pos)|
t_right = |(temp_right - temp)/(pos_right - pos)|
If t_left is greater than t_right, the next position where the temperature should be detected is (pos_left+pos)/2, and pos become the new pos_right; If t_left is less than t_right, the next position is (pos_right+pos)/2, and the new pos_left is pos. This procedure will iterate until sensor i find that the next step it should move is less than a give threshold.
The following pictures are the result of one experiments. The first picture is the output of the Binary Search. The second picture is gotten by evenly detecting the temperatures alone the strand. Those pictures show that in this case Binary Search can find the maxmum temperature gradient.