Levoit Air Purifier with Home Assistant
Back in January I posted about how I've gone a bit crazy with home assistant and zigbee. I decided to get back to my "automation roots" and do something DIY again. I've been using a Levoit air purifier, which I bought off Amazon for around £100, for about a year now. It works well and the filters aren't overly expensive.
At the time of purchase, I was faced with a decision about whether it should have WiFi or not. Correctly, I declined - I don't want to depend on some Levoid-specific phone app which will brick my air purifier in the future. However, during the time I've been using the purifier, I've gradually become more fed up of turning it on, off, or somewhere in between.
I decided to take it apart! There are a surprisingly large number of screws - self tapping into plastic, no less. I was unable to get the top panel off, so basically only had access to the power supply and blower. The power supply provides power to the top panel via two thin wires, while a third provides a PWM signal back to the power supply.
Perhaps surprisingly, I didn't even need to break out my oscilloscope for this. My reasonably-cheap multimeter has modes for both duty cycle and frequency measurement. The PWM signal was running at 4KHz with some duty cycle fairly closely matching the power / speed. 100% duty cycle (i.e. DC) would set the blower to full, while 0% duty cycle (i.e. grounded), turned it off.
I flashed an ESP8266 with ESPHome (via my web browser?! - crazy) and
managed to pair it quite easily to Home Assistant. I disconnected the
top panel and used the +/- supply to power the ESP8266 via a 3.3V
regulator module. I connected GPIO0
to the PWM (third) pin
directly, but used a 10k resistor to pull this up to 3.3V. The ESP8266
will not boot without this resistor.
Within ESPHome, configuration was simple and I just added the following:
output:
- platform: esp8266_pwm
pin: GPIO0
frequency: 4000 Hz
id: pwm_output
inverted: false
fan:
- platform: speed
output: pwm_output
name: "Aaron's Air Purifier"
Of course, the front panel does not work anymore, but this isn't a problem. I leave the air purifier at the end of my bed and quite often my toes would turn it up during the night, or turn it off entirely.
I'm glad I've finally tried ESPHome. I was surprised by how easy it is to get started and will definitely be thinking of other things to automate.
Related posts:
Wanting to leave a comment?
Comments and feedback are welcome by email (aaron@nospam-aaronsplace.co.uk).