The problem of extending the lifespan of wireless sensor networks (WSN) based on the Internet of Things (IoT) has been widely investigated over the last 20 years. This paper proposes an Optimized J-RMAC (optimized joint routing and media access control protocol) to guarantee the network lifetime in IoT-based WSN. Initially, all sensor nodes report their position and coverage information to the sink, which uses this information to pick a list of active nodes based on energy usage and active time. Then, the k-covered network is formed to execute the routing task by selecting the active nodes with the largest sensing areas. A multi-objective seagull optimization algorithm (MO-SOA) represents routing paths between the source and destination by considering two objective functions: energy consumption cost and end-to-end delay of a routing path. After that, the contention window of the nodes in the routing path is adjusted using a new iterative adaptive adjustment process of the contention window with adjustment parameters (IAACW-AP) to avoid message conflicts. The proposed protocol is simulated in the NS2 simulator. The performance of the proposed protocol will be compared with existing strategies in terms of network lifetime, packet delivery ratio, communication overhead, energy consumption, and delay.