Wireless Sensor Networks(WSNs) are applied to many monitoring applications. Present sensor nodes can perform many functions at the same time and contain complex software. During the lifetime of sensor nodes, they are required to reprogram their software because of their new functions, software, software bug fixes. The nodes are inaccessible physically or it is very difficult to upgrade their software by one by one. To upgrade the software of sensor nodes in WSNs remotely, this paper presents an energy efficient method by selecting an optimal relay node. The CHR(Cluster Head Relay) method is compared with SPIN and RANDOM method. Three methods are simulated in NS-2 with the same environmental parameters. Simulation results show that CHR shows faster update time and less power consumption compared with other two methods.