IoT devices collect data from their surroundings using sensors and transmit it to a central system or cloud platform via the Internet, where it is processed, analyzed, and used to trigger actions or provide insights.