I live in an older house and am replacing an old ceiling fan. Previously, the fan was on two switches- one for the light and one for the fan. To my suprizs, when I pulled the fan down there are only two wires. My fan has three wires one blue, one black and one white. I can't figure out how to wire this back up. I pulled the switch off and attached is a picture. Help is much appreciated!
Just a quick note of warning: The white wires tied together in the switchbox should NOT have the bare wire spliced in with them. They are for two separate paths and must be kept separate, one for equipment grounding (bare) and the other for the neutral/return (white). The bare wires should not carry current except in fault conditions. Some of the danger is lessened if the bare going to the fan is kept isolated from the other two bare wires, but from the pictures I'm unable to tell if they are all tied together or if that one has been separated from the others.
Upon closer inspection, it looks like the previous fan was returning current on the grounding conductor (bare) which is non-compliant usage[NEC 200.6(A)]. They were using the white wire as a separate switch leg for either the light or the fan, another NEC violation as it is neither reidentified nor should be used as a switch leg [200.7(C)(1)]. The fan has a white which was tied to the bare wire, a blue which was tied to the switch leg for the light, and a black wire which was tied to the switch leg for the fan.
What SHOULD be done? To be code compliant the cable ought to either be replaced with a 14-3 wG cable (or possibly 12-3 wG if 20A circuit breaker or fuse), OR change the white wire from a switch leg back to being the neutral the way it was originally wired and the grounding wire back to being for grounding. The black and blue wires from the fan would both tie together with the black wire coming from the switch, and you would probably replace the double switches with a simple single pole switch to avoid confusion later. Most ceiling fans have a pull chain option to change the fan speeds and turn it off, or turn the lights off separately with the other pull chain to run the fan in the dark.
If this advice is disregarded, at the very least make sure the bare wire in the cable with the switch legs is not twisted together with the other bare wires and doesn't touch anything else metal, either in the switch box or fan outlet box. It is only carrying about 3 amps, but at 120v this can still be dangerous, especially if it is allowed to touch the other grounding conductors or bonded metal parts. Again, I'm not saying to do this, but it becomes less dangerous if the wires are kept isolated and it only carries current through this one cable instead of electrifying your entire grounding system.
If you can't rerun a cable, you still have options
If you can't run a new /3 cable for the fan and light, you still have a couple of options for maintaining control of both separately while bringing the situation up to Code.
First off, you could get a Lutron Maestro combination fan/light control (MA-LFQHW) and use that -- these use a canopy module and hard-wired controller to multiplex full multispeed fan control and dimming light control over a single switched hot wire. This is probably the simpler solution to install and operate.
If dimming/multispeed fan control isn't an option for some reason or another, you can use a Functional Devices HLF3 at the fan to multiplex control of the fan and light onto a single switch -- however, the operation of this is a bit clunky (requiring "flip the switch off and back on again until you get what you want") compared to other setups.