Wireless sensor network for derailment detection in freight trains