PurposeThis paper aims to propose a system for automatically forming ad hoc networks using mobile phones and battery-powered wireless routers for emergency situations. The system also provides functions to send emergency messages and identify the location of victims based on the network topology information.Design/methodology/approachOptimized link state routing protocol is used to instantly form an ad hoc emergency network based on WiFi signals from mobile phones of the victims, backup battery-powered wireless routers preinstalled in buildings and mobile devices deployed by search and rescue teams. The proposed system is also designed to recover from partial crash of network and nodes lost.FindingsExperimental results demonstrate the effectiveness of the proposed system in terms of battery life, transmission distance and noises.Originality/valueA novel message routing schedule is proposed for conserving battery life. A novel function to estimate the location of a mobile device which sent an emergency message is proposed in this paper.