About

Diffusers that are "smart" and have some Google Nest or Amazon Alexa integration tend to also be overly expensive. On the other hand, when browsing for diffusers that accept a smart firmware such as Tasmota, the results seem pretty scarce and the devices seem hard to find given that they are all aftermarket non-branded devices.

However, it seems overkill to search for existing smart devices or devices that can have their firmware customized because all the technology to turn a non-smart device into a smart one is already there. With that said, this guide will jot down some notes on how a non-smart diffuser can be turned into a smart-device.

Availability

Due to Chinese markets, the availability of diffusers is very large, with a bunch of designs that vary in aspect yet frequently use the same control circuit. Typically, there are buttons for turning the device on or off, buttons for changing the LED colors and various other doohickies such as changing the light intensity.

In order to keep the built minimal, ideally, a device should be found or preferred that uses the minimal amount of controls. The less controls on a device, the less GPIOs have to be expended on a controller to be able to cover the device functionality.

One device was found that has a single button, and one single button is used to control all the device features, depending on the length of time spent pressing on the button. It's simple: long presses toggle the device on or off and short presses changes the colors of the device. This implies that whatever circuit will be designed, it should implement a timed debouncer with the ability to specify the debounce interval. However, that is still better than using more GPIOs since it will allow the usage of a minimal ESP.

For this project an ESP-01S will be used - it is decently small, has just a few GPIOs which is sufficient because there is only one button and the power consumption is truly minimal on such a small device.

Schematic

A very simple schematic can be created for the whole circuit that will be built. Intuitively, the additional circuit will hook into the existing PCB of the diffuser and draw power from the existing PCB as well as use two control lines in order to toggle the functionality of the PCB.

+------------+
|            |
| Diffuser   |   GPIO R/W   +---------+
| Controller +--------------+ ESP-01S |
|            +--------------+         |
|            |              +---+-+---+
|            |                  | |
|            |  +------------+  | |
|            +--+ Buck       +--+ |
|            +--+ 5V -> 3.3V +---+
|            |  +------------+
|            |
+------------+
            

Upon probing the PCB, it turns out that the entire circuit runs at $5V$ due to being USB-powered and without any exposed pins for $3.3V$ digital voltage which would be ideal in order to run the ESP-01s. A voltage divider cannot be used with ESPs due to their instability such that a small buck converter based on an LM voltage regulator will have to be used. One GPIO will be used to trigger the button and also one additional GPIO will have to be expended in order to read-in some voltage as feedback that will be used to determine whether the diffuser is currently turned on or off.

One of the troubles with push-buttons that toggle the power of devices, compared to regular stateful switches is that it becomes difficult to determine whether the device is powered on or off at a given point in time. A solution is to use the ESP permanent storage to store the power state of the device but this will not work reliably if one takes into account power outages when the stored state variable becomes de-synchronized with the current state of the device. Unfortunately, the only solution is to use another GPIO to read in the current state of the device being toggled such that it can be known in advance whether the device is powered on or off and then take a decision on whether the power state should be toggled. Note that in good Wizardry and Steamworks tradition, the actual operational logic of the device will not be hardcoded into the ESP software, but rather all the above will just be made accessible via a data bus such as MQTT.

Realization

Perhaps the more difficult part of the build is to probe around the existing diffuser PCB in order to find the hooking points that will be needed to patch in the additional circuitry. There are two points needed:

  • one hooking point is needed to flip the power state of the device, this will be usually found around the switch
  • the other point needed, is a point that steps over digital $3.3V$ (given no analog inputs on the ESP-01S) when the device is powered on, in order to be able to provide the necessary feedback power state

This operation of determining hooking points is somewhat non-trivial and it is never sure that the required points will be found. Probing for the hook needed to toggle power, is easy given that it is known that the push-down button is responsible for power, such that connectivity is checked around the switch, to hopefully determine a trace that is exposed well-enough to be able to attach a wire. In this diffuser's case, there was no such point found, such that the hooking wire was soldered directly to the back of the push switch on the small exposed trace that does not correspond to ground.

Probing for a feedback hooking point is performed by using connectivity testing and determining which points correspond to the ground on the PCB. After that, the device is toggled on and off in order to determine which points, other than the points corresponding to the ground, change their behavior depending on whether the device is powered on or off. If one such point is found, it is measured in terms of voltage to make sure that the point at least exceeds $3.3V$ which is the minimal input voltage required for a digital signal. Fortunately, one of the benefits of working with ESP devices, is that GPIO pins are typically $5V$ tolerant, meaning that if a hooking point is found that switches over $3.3V$, it can be patched in directly to the GPIO of the ESP provided that it does not exceed $\approx 6.5V$. Of course, in case the voltage does exceed the $6.5V$ approximate threshold, then a voltage divider has to be added to ensure that the voltage is pulled in-range of the ESP tolerance level in order to not burn the ESP.

Hardware

Locally, there is additional trouble with determining hooking points with the chosen device namely that the diffuser senses the lack of water and turns off, such that the diffuser cup will have to be filled to keep the circuit running, whilst also performing measurements at the same time. Perhaps the sensor connector can be shorted using a resistor to fool the sensor, but a towel was thrown over the white cup to keep the fountain of water contained while measuring instead.

Disassembling the diffuser is relatively easy, the top cup can just be removed by hand and it is not held in place by anythng, whilst the bottom cup can be unscrewed by first removing the rubber feet and then extracting the small screws with a screwdriver.

With the diffuser opened, the PCB is marked as QOOLIFE, is connected to a fan, the ultrasound and sensor as well as to the colored LEDs via a mini ribbon cable. All the cables seem to be removed easily, with the exception of the fan that refused to let itself be extracted such that it was left there. Fortunately, the small fan is just lodged within a small enclosure such that it can be pulled out if necessary.

The ESP driver circuit is created and connected to the PCB hooking points: the white cable is connected directly to the switch and will be responsible for toggling the diffuser power, the alternating braided white and red wire feed into the buck step-down converter that powers the ESP and the sole red wire entspringing from the ESP circuit goes to the right side of the PCB fan connector, which is the point that will be providing the power on state feedback.

Here is a close-up of the circuitry; it is not a difficult circuit, most of the connections being straight-forward with the exception that a transistor switch is used to provide the necessary impulse to press and depress the power button.

The transistor switch is not visible that circuit has been used many times in Wizardry and Steamworks projects and should be thoroughly documented on the FUSS page. In brief, the transistor switch connects the ESP GPIO pin to the base of an NPN transistor through a resistor such that when the GPIO is set to high, the current flows between the collector and emitter to ground, thereby simulating a button press. This is easy to understand if the pins of the switch are measured because one of the pins of the switch connect to ground, whilst the other pin connects to the power line that will be grounded when the button is pressed, which is exactly what the transistor switch will do.

One of the problems with using two GPIOs on the ESP-01S without hooking into GPIO0 that is needed for booting the ESP, is that the remaining pins are GPIO2 and the two others are the RX and TX that provide the serial console functionality. In case the RX and TX pins are used as GPIOs then the serial console cannot be used, which will make debugging difficult. (Or if you're good with morse code, you can make the LED blink the text!).

The rest of the circuit is trivial, being more about positioning things adequately on the breadboard and connecting conveniently to the necessary pins. Of course, the ESP-01S is mounted onto pin headers such that the module can be easily removed, re-programmed and then slotted back into the diffuser circuitry very conveniently. Interestingly, there is a lot of space available inside, and even with a two-layered breadboard with a mounted ESP-01, there is still plenty of room inside the diffuser, perhaps for other possibilities to explore.

The diffuser is reassembled back after the job is done.

Software

The Arduino sketch used is the the ESP GPIO tool and the corresponding node-red flow is the following:

where:

  • Scent is the Alexa control node to provide voice-control to the diffuser,
  • the two purple nodes marked as "esp" are the MQTT connector nodes that pass data back and forth between the ESP and node-red,
  • the Toggle node, is a template node that is used to toggle the power of the diffuser, while the Status node is periodically used to poll the power status of the diffuser,
  • the upper half is responsible for receiving the power status and storing the state into a flow-scoped variable, whilst the bottom half is mainly meant to toggle the device and periodically poll its status,
  • the switch network on the bottom half simulates the following logic if the state of the diffuser is on and the user requests the device to be turned on then do nothing, if the state of the diffuser is on and the user requests the device to be turned of then turn the device off as well as the converse when the state of the diffuser is off

It is possible to avoid polling as follow-up work, by removing the timestamp node and then perhaps querying the device right after a "toggle" instruction, which should remove a timer from the setup - perhaps the timestamp node can be kept in place and only used on startup as an additional failsafe initialization when the state has not been stored to the flow.

Followup Revisions

One of the main problems with the ESP-01S is that it is extremely unstable in the sense that the GPIO pins and various combinations of pulling the pins low or high condition the functionality of the ESP-01S a lot. For example, GPIO 1 and 0 must be held high for the ESP-01S to boot such that connecting anything to the pins that might drain current will make the ESP-01S either not boot at all, or just boot into the firmware programming mode. There are few solutions, except changing the controller yet the ESP-01S is still the smallest ESP available.

Otherwise, the diffuser seems to be fairly simple in design but also has lots of room allowing for modifications such that the project could be extended.

Swapping out the Transistor as a Switch for a Relay

For this project, the transistor as a switch circuit was dismantled in favor of using a low coil-voltage relay that is able to emulate the button press. The advantage of using a relay is that without a difference of potential there is no permanent drain on the GPIO pin that would make the ESP boot chaotically.

The new circuit is much simpler and just required to fit a small EE2-3NUH relay with a required coil voltage of just $3V$ that can then be directly engaged using a GPIO pin without having to level shift the GPIO pin in any way. Simplicity at is finest.

The voltage probe that was used to determine whether the circuit is live or not is unchanged and hooked up again. The positive terminal of the relay is connected to GPIO1 an the probe will be connected to GPIO3, both of these pins representing the serial port, such that the only drawback will be that the ESP will have to remain silent by using Serial.end() on the sketch to be uploaded.

On the back the probe has a $330\Omega$ resistor connected in-line with the lead that will measure the voltage when the diffuser is turned on in order to prevent the pin to be immediately drained as the circuit is being powered on. Otherwise, the only other change consists in fitting JST sockets in order to be able to remove the circuit board and the ESP altogether if need be for future possible developments.

Painting

The shell of the diffuser can be painted over according to taste. However, there is one interesting property of the diffuser, namely that the upper cup is painted over with a rubberized paint. Intuitively, the diffuser is driven by ultrasounds such that no flames could possibly destroy the plastic and the paint, but as it stands the upper cup will always be wet due to the water that is shot up by the diffuser which might explain the paint. The problem is that after long time usage, the rubberized paint itself will end up destroyed and will even start "crumpling" or "leaking" such that it should be removed, refreshed and redone properly.

A similar effect can be achieved by first cleaning the cup, using primer to coat the cup with an initial coat of paint and then finally applying the color paint.

After applying the final paint coating, the very last step is to apply acrylic paint.

The acrylic paint is meant to protect against wear and tear against water and grime and should be applied abundantly on the cup. It might happen that the acrylic clumps a little leading to white-transparent strains across the body and if it does, it's still possible to mix the color paint and the acrylic together in order to perform corrections. Note that the paint should definitely be applied to the interior where the actual water will be splashing onto the plastic, which is even more important than the outer shell.


iot/making_a_diffuser_smart.txt · Last modified: 2025/01/27 03:41 by office

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.