We study the problem of routing in sensor networks where the goal is to maximize the network's lifetime. Previous work has considered this problem for fixed-topology networks. Here, we add mobility to the source node, which requires a new definition of the network lifetime. In particular, we redefine lifetime to be the time until the source node depletes its energy. When the mobile node's trajectory is unknown in advance, we formulate three versions of an optimal control problem aiming at this lifetime maximization. We show that in all cases, the solution can be reduced to a sequence of nonlinear programming roblems solved on line as the source-node trajectory evolves. When the mobile node's trajectory is known in advance, we formulate an optimal control problem which, in this case, requires an explicit offline numerical solution. We include simulation examples to illustrate our results.