diff --git a/content/Hacking my Air Purifier onto Wifi.md b/content/Hacking my Air Purifier onto Wifi.md index 0f0c162..a3dc97e 100644 --- a/content/Hacking my Air Purifier onto Wifi.md +++ b/content/Hacking my Air Purifier onto Wifi.md @@ -19,21 +19,21 @@ I didn't want to get a different air purifier that was smart and have to deal wi ## Technical Details -The power supply and motor driver board originally connect to the control board via a 6-pin ribbon cable. Pin 4 of that cable expects a PWM signal that controls the speed of the purifier's blower motor proportional to the duty cycle. Pins 1 and 5 happen to be 5 V and Ground, which are used to power the Wemos D1 Mini ESP8266. +The power supply and motor driver board originally connect to a board that has the buttons and LEDs via a 6-pin ribbon cable. Pin 4 of that cable expects a PWM signal that controls the speed of the purifier's blower motor proportional to the duty cycle. Pins 1 and 5 happen to be 5 V and Ground, which are used to power the Wemos D1 Mini ESP8266. The Wemos boots up and connects to an MQTT broker on my Wifi network. It subscribes to the `iot/purifier/mega_1234/speed` topic where `1234` is part of the MAC address so different purifiers on the network can be addressed easily. It listens to messages that are numbers 0-100 and maps them linearly to 60-140 which correspond to the PWM duty cycle range that the motor driver expects. You can find the [source code](https://git.tannercollin.com/tanner/airmega-hack/src/branch/master/firmware/firmware.ino) on my Gitea. -A side effect of this is that the control board is completely dead and manual control of the purifier no longer works except for unplugging it. I actually don't mind this because it also kills the blue LEDs and I just use my smart watch or phone to control it instead. The built-in dust sensor also no longer works, but it should be possible to also read this with the Arduino over serial. +A side effect of this is that the control board is completely dead and manual control of the purifier no longer works except for unplugging it. I actually don't mind this because it also kills the blue LEDs and I just use my smart watch or phone to control it instead. The built-in dust sensor also no longer works, but it should be possible to also read this with the Arduino over serial in the future. ## Hardware Hacking Hacking the purifier is actually fairly straightforward. My purifier was already over a year old, so I didn't care about voiding my warranty. The power supply isn't isolated and the electronics' ground is floating at something like 48 VAC (learned this the hard way), so I keep it unplugged while I'm modifying it. -I removed the cover and all the filters, and then the nine Philips screws holding the case together. I lifted the blower half up and propped it up at an angle. You can see a photo of it below, with the ribbon cable plugged into the control board at the bottom left: +I removed the cover and all the filters, and then the nine Philips screws holding the case together. I lifted the blower half up and propped it up at an angle. You can see a photo of it below, with the ribbon cable plugged into the control board at the bottom right: ![[purifier2.jpg]] -I didn't want to destroy the cable by cutting it to connect it to the Arduino, so I ordered some connectors off of Digikey. Both [2057-25SH-B-06-TR-ND](https://www.digikey.ca/short/mt9d2cm0) and [1175-51125-06-0200-01-ND](https://www.digikey.ca/short/v53bnq97) mate well with the white ribbon cable connector. I soldered the connector to a bit of 0.1" perf board and wired it to the Arduino: +I didn't want to destroy the cable by cutting it to connect it to the Arduino, so I ordered some connectors off of Digikey. Both [25SH-B-06-TR](https://www.digikey.ca/short/mt9d2cm0) and [51125-06-0200-01](https://www.digikey.ca/short/v53bnq97) mate well with the white ribbon cable connector. I soldered the connector to a bit of 0.1" perf board and wired it to the Arduino: ![[purifier3.jpg]] ![[purifier4.jpg]] @@ -57,7 +57,7 @@ Researching the hack was not as straightforward. I disassembled the unit and not I attached my oscilloscope's ground lead to the `GND_S` pin and probe to the `SIG1` pin, expecting that to be a signal. I plugged the purifier in and immediately heard a POP! That's when I learned the power supply isn't isolated and I had just shorted 48 volts through my oscilloscope to ground. -Luckily I only blew a fuse on the board and just had to solder a new one on, part number [4598-MST3.15A250VCT-ND](https://www.digikey.ca/short/nv9wtwr9). From then on I used two probes, one on the signal and one on the ground pin and used my oscilloscope's math feature to subtract them. This made a noisy and imprecise trace, but it was enough to tell the speed was controlled by PWM. +Luckily I only blew a fuse on the board and just had to solder a new one on, part number [MST 3.15A 250V](https://www.digikey.ca/short/nv9wtwr9). From then on I used two probes, one on the signal and one on the ground pin and used my oscilloscope's math feature to subtract them. This made a noisy and imprecise trace, but it was enough to tell the speed was controlled by PWM. This showed me the hack was indeed possible, so I ordered a differential probe off Amazon in order to scope the signals precisely: