The working–sleeping cycle strategy used for sensor nodes with limited power supply in wireless sensor networks can effectively save their energy, but also causes opportunistic node connections due to the intermittent communication mode, which can affect the reliability of data transmission. To address this problem, a data collection scheme based on opportunistic node connections is proposed to achieve efficient data collection in a network with a mobile sink. In this scheme, the mobile sink first broadcasts a tag message to start a data collection period, and all nodes that receive this message will use the probe message to forward their own source information to the mobile sink. On receiving these probe messages, the mobile sink then constructs an opportunistic connection random graph by analyzing the source information included in them, and calculates the optimal path from itself to each node in this random graph, therefore a spanning tree could be generated with the mobile sink play as the root node, finally, it broadcasts this spanning tree so that each node could obtain an optimal path from itself to the mobile sink to forward the sensing data. In addition, a routing protocol that adapts to different nodes operating statuses is proposed to improve the reliability of data transmission. Simulation results show that the proposed scheme works better concerning the packet delivery rate, energy consumption and network lifetime.