A recurrent idea in the study of complex systems is that optimal information processing is to be found near bifurcation points or phase transitions. However, this heuristic hypothesis has few (if any) concrete realizations where a standard and biologically relevant quantity is optimized at criticality. Here we give a clear example of such phenomenon: a network of excitable elements has its sensitivity and dynamic range maximized at the critical point of a nonequilibrium phase transition. This non-linear signal processing is due to creation and annihilation of excitable waves within the network and is a generic transduction property of excitable media. Our results are compatible with recent experimental evidence concerning the essential role of gap junctions in retinal ganglionar cell output, the large dynamic range in olfactory glomeruli (where gap junctions have also been found) and critical avalanches in neural tissue. Synchronization and global oscillations also appear in the network dynamics. We propose that the main functional role of electrical coupling is to provide an enhancement of dynamic range, therefore allowing the coding of information spanning several orders of magnitude. The mechanism provides a microscopic neural basis for psychophysical laws, and suggests a new principle for enhancing sensitivity and dynamic range in artificial sensors.