There's this guy here, though you may need to add another relay to it depending on current draw of your trains.
A somewhat simpler, though more costly, option is here.