There are many kinds of anemometers. For the sake of this answer I will describe the most basic model. The anemometer consists of three or four cups, one with a magnet attached to it. As the wind blows it spins the cups around a central shaft. Each time the magnetic cup completes a full revolution it is detected and read as average wind speed over time.