Temperature Responsive Cereal Box Fan
This quick and easy project produces a quiet breeze for hot summer nights. I wanted something gentler than the fans already in the house, and I wanted it to automatically turn itself off in the middle of the night once things cooled down enough. It also let me apply lessons I've recently learned. Even though I've found that the TMP36 sensor isn't a great fit for a ESP8266, it's something already on hand for an ESP8266 to tell if it's cool enough to turn the fan off.
The 3-wire fan is a PC cooling fan with a 200mm diameter, relatively large within that category. I bought it some years ago for my first Luggable PC project, it was just a bit too large for that purpose and sat idle until now. I thought about designing and 3D-printing a stand for this fan, but in the spirit of keeping things simple and quick, I mounted it in an empty cereal box instead. Cutting holes in the box to accommodate the fan took a tiny fraction of the time it would have taken to 3D-print something.

Primary air intake was the top of the box, left open.

I cut a smaller secondary air intake towards the bottom of the box, which also makes it easy to toss my control board in there and feed it power from a salvaged DC power supply. A TMP36 sensor was soldered in the farthest corner in this picture, visible sticking up vertically.
Results
Running ESPHome (YAML excerpt below) this project successfully controls fan speed via ESP8266 PWM. It was also able to read temperature via TMP36 sensor, but values were affected by ESP8266. Located 1/2 of the circuit board away plus the entire height of its legs was not enough distance from the ESP8266 heat island: temperature reading dropped noticeably whenever the fan is turning. Still, it's enough for me to create a Home Assistant automation to turn off this fan whenever the temperature dropped below a certain threshold. Due to the heating from ESP8266, the temperature value rises a few degrees immediately after the fan was turned off. Thankfully there was no risk of system feedback oscillation, because I did not create an automation to turn the fan on -- I do that manually when I'm ready for a light breeze.
This worked well sitting on my bedstand, creating a light cool breeze when I'm ready to fall asleep and turning itself off while I was asleep. But its physical footprint was a problem: it took up space that is ideally used for a bedstand light. The obvious solution was to pull some LEDs into the next version, which is an opportunity to tackle another item on my to-learn list: PC accessories with embedded RGB LEDs.
ESPHome YAML to read TMP36 temperature and fan speed every 5 minutes:
sensor:
- platform: adc
pin: A0
name: "Fan Temperature"
unit_of_measurement: "°C"
update_interval: 1s
accuracy_decimals: 2
filters:
- multiply: 100
- offset: -50
- sliding_window_moving_average:
window_size: 450
send_every: 300
send_first_at: 15
- platform: pulse_counter
pin: 12
id: fan_rpm_counter
name: "Fan RPM"
unit_of_measurement: "RPM"
accuracy_decimals: 0
update_interval: 300s
filters:
- multiply: 0.5 # 2 pulses per revolution
output:
- platform: esp8266_pwm
pin: 14
id: fan_pwm_output
frequency: 1000 Hz
fan:
- platform: speed
output: fan_pwm_output
id: fan_speed
name: "Fan Speed Control"