There are a lot of Instructables that show how to make a thermostat. But what if you already have a thermostat, and you want to log or monitor when it turns off and on? This Instructable shows how to use an optocoupler to obtain logic-level DC voltages from a common household programmable thermostat that connects to a 24 volt AC heating and cooling system. It also includes a temperature sensor, and code suitable for running on a Raspberry Pi to log and graph thermostat status, events, and temperatures.
WARNING: Working with electricity can be dangerous. Before continuing, be sure you have adequate understanding and skills to complete this project safely. While I've done my best to make it safe, I am not responsible if this project fries your thermostat, Raspberry Pi, HVAC system, your cat/dog, or burns down your house.