Seeking A Solution: Essential Oil Diffuser

Thanks for the ideas, timpro. I am willing to do this.

Can you confirm the HW I’m going to need for this? I already have computers I can use to download and run the flashing SW.

Clearly I need an ESP, WINGONEER D1 Mini Pro - 16M Bytes External Antenna Connector ESP8266 WIFI IoT Board is what I’m eyeing.

This article suggests that I’m going to need:
Breadboard 3.3V power supply
3.3V FTDI USB module
Breadboard
Jumper wires

I suppose I also need a mini-USB to USB cable.

Regarding power, I think it’s 24V, here it is:

If you don’t mind waiting a little bit for shipping, I highly suggest buying from Aliexpress (find a shipper that ships ePacket as you get a tracking number and ships faster), you will save yourself a lot of money. Type in Wemos D1 Mini, they use an ESP-12 mounted to a prototype board which you can easily work with. The version you found on amazon will need an external antenna, this may be a little overkill for an oil diffuser :wink:

I’d suggest buying a couple, as you may accidentally burn it out if you’ve never worked with one before. I still make mistakes and blow the odd one up. Plus, chances are once you get your oil diffuser automated you’ll want to keep going!

Once you have your Wemos, you will connect it to your computer using a micro-usb to usb cable. You’ll need to go to the ESPEasy site to download their firmware.

Tutorial ESPEasy Firmware Upload - Let's Control It

The wemos d1 mini with an esp-12 will have 4096K of memory, so you’ll need to select that when uploading the firmware.

Once uploaded, unplug the usb and plug it back in to give it a good powercycle, then let it sit for a minute. Eventually it will broadcast an access point that you will log onto, and this is where you tell the Wemos what wifi network to connect to, and password. Once it completes its setup, it’ll give you it’s IP address. You can then log back onto your wifi network and navigate to the IP of the Wemos.

From this point, you will enter your mqtt credentials and configure your gpio’s. Once done, you will need to solder a wire from the button to which ever GPIO you’ve configured it to, etc. Then comes the Home Assistant configuration.

If you let me know how far you get, I can help you out some more. :slight_smile:

As far as powering goes, it might be easiest to run a separate power cable to power the wemos using a cheap wall brick and cable from the dollarstore. It is possible to use the 24v adapter but that would require the use of step-downs and what not. If someone else wanted to weigh in on this that would be great, powering isn’t my specialty (as I mentioned I’ve blown a few things up, you learn as you go lol).

Here’s my current candidate: ESP8266 ESP-12 ESP12 WeMos D1 Mini Module Wemos D1 Mini WiFi Development Board Micro USB 3.3V Based On ESP-8266EX 11 Digital Pin

Also, FWIW, here’s the inside of the diffuser.

The link you provided is the correct one. If they ship with ePacket (it usually costs a $1-2) you might want to select that option otherwise it you’ll be waiting over a month to receive it, in my experience :). I find on Aliexpress I will look at multiple listings until I find a seller that ships ePacket at a reasonable price.

Looking at the inside of your diffuser, it seems simple enough. Essentially you’re going to want to tap onto the LED that turns on with power and solder it to one of the GPIO’s on the Wemos. Then the same for the push button.

I’ve received the ESPs and I’ve flashed one with ESP Easy R120. v2.0 would not connect to my wireless access point.

The ESP is on my local network, accessible via the web interface. I’ve entered my mqtt broker credentials.

A few questions:

  1. The ESP may be subscribing with the client ID: “ESPClient0” and not “diffuser”. At least this is what my MQTT broker’s (mosca) log suggests.

    `logs/mosca.log:11811:{“pid”:14,“hostname”:“mosca”,“name”:“mosca”,“level”:20,“time”:1524614051222,“msg”:“pingreq”,“client”:“ESPClient0”,“v”:1}
    logs/mosca.log:11812:{“pid”:14,“hostname”:“mosca”,“name”:“mosca”,“level”:20,“time”:1524614051222,“msg”:“setting keepalive timeout”,“timeout”:22500,“client”:“ESPClient0”,“v”:1}

I’m not terribly worried about this but it’s not what I expected.

  1. How do I map ESPEasy’s GPIO layout to the ESPs? The ESP8266 has labels like D[0-8], but the ESPEasy suggests labels like GPIO-[0-16], but with a few entries greyed-out. Does D0 map to GPIO-0? I cannot understand the greyed-out GPIOs in the input.

This post suggests that I should be able to set the ‘First GPIO: GPIO-5 (D1)’ but I don’t seem to have that setting. I wonder if it’s a ESPEasy v2 feature vs. R120 that I am using (see above wireless AP problem).

ESP8266

  1. Can I create a log entry or some LED-blinks on the ESP upon receiving the MQTT event? I’d like to confirm that I’m receiving events properly before cutting any wires on the diffuser.

Wouldn’t wiring in a sonoff basic be easier and potentially cheaper option?
Flash with Tasmota and integration is easy

I filed a ticket against ESP Easy and found that the ESP_Easy_v2.0-20180322_normal_ESP8266_4096.bin image allowed me to connect to my AP.

I’ve answered a few of my own questions:

Q1) The ESP may be subscribing with the client ID: “ESPClient0” and not “diffuser”. At least this is what my MQTT broker’s (mosca) log suggests.

A1) There is better logging with the new ESP Easy image. ESPClient_XX:XX:XX:XX:XX:XX is the client ID, and it subscribes to “/diffuser/#”. This all looks fine to me.

Q2) How do I map ESPEasy’s GPIO layout to the ESPs? The ESP8266 has labels like D[0-8], but the ESPEasy suggests labels like GPIO-[0-16], but with a few entries greyed-out. Does D0 map to GPIO-0? I cannot understand the greyed-out GPIOs in the input.

A2) I seem to have the better labeled selections for the GPIO to ESP tag mapping. For example, the drop-down-box allows me to select “1st GPIO: GPIO-0 (D3)”. I’m not sure what the significance of “1st” is. I suppose I need to read more…

Q3) Can I create a log entry or some LED-blinks on the ESP upon receiving the MQTT event? I’d like to confirm that I’m receiving events properly before cutting any wires on the diffuser.

This last one is still open. I’ll post progress if I make any…

It looks like a simpler device, but if I read correctly it’s also a few inches long. I’m not sure if it will fit in the diffuser enclosure. Also, most instructional videos I watched had the Sonoff intercepting the power cable. I need to intercept the wire from the button-press (what would you call this wire?). Is this possible from the sonoff? The diffuser requires a button-press to activate.

I’m not proficient in EE, so sorry for the sloppy language. :slight_smile:

I know this thread is a bit old, but I’m looking for the same ability – controlling a diffuser. What about one of these WiFi ones, like this? I can’t find any info about an API, but if it works with Alexa, there must be an API, right? Perhaps it can be reverse engineered?

2 Likes

I looked into this same setup using a Wemos D1 Mini into a diffuser. The Wemos Power shield can take 7-24V input so that was taken care of. I never got around to probing the diffuser to see if the board converted to 12v for the LED’s and control board. I think 24v is usually needed for the ultrasonic mister and fan.

I found no room to mount a flat pcb as the units are all rounded. Maybe a bigger 500ml model with a larger base would have the room to fit the electronics needed. I also found it low priority since its a pretty useless feature with such a small resovoir in these units.

For anyone still looking for an aromatherapy / oil diffuser, this one works as a Sonoff device right out of the box.
https://amzn.to/2I39lou

The only catch is that it is on/off only and can’t control the LED color or brightness. Other than that, it works great and going through HA is much easier than using the eWeLink app.

1 Like

Thank you for the update! I actually bought this device last year because I could program a timer, which was at least some level of automation.

What do I need to integrate it with HA? Do I need a Sonoff RF Bridge or something else? Any recommendation would be appreciated.

1 Like

No bridge needed, but my “out of the box” comment was getting ahead of myself. I actually needed to install the Sonoff eWeLink custom component. Just follow the readme about where things should go.

Then if you don’t have it already, add the following code in configuration.yaml:

sonoff:
  username: !secret sonoff_username
  password: !secret sonoff_password
  scan_interval: 60
  grace_period: 600

After restart you should see a switch that looks like this:

switch.sonoff_00-DEVICE-ID-NUMBER-00

Hmm… I cannot get it working with HASS v0.90.2. It seems that the component may need to be patched to support a different directory structure. To install I’m just dong a:

git clone https://github.com/peterbuga/HASS-sonoff-ewelink /config/custom_components

and I get the ERROR:

 2019-04-02 20:13:28 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.sonoff.sensor. Make sure all dependencies are installed
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/loader.py", line 166, in _load_file
    module = importlib.import_module(path)
  File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 962, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'custom_components.sonoff.sensor'; 'custom_components.sonoff' is not a package
2019-04-02 20:13:28 WARNING (MainThread) [homeassistant.loader] You are using a custom component for sensor.sonoff which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2019-04-02 20:13:28 WARNING (MainThread) [homeassistant.loader] Integrations need to be in their own folder. Change sensor/sonoff.py to sonoff/sensor.py. This will stop working soon.
2019-04-02 20:13:28 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.sonoff.switch. Make sure all dependencies are installed
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/loader.py", line 166, in _load_file
    module = importlib.import_module(path)
  File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 962, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'custom_components.sonoff.switch'; 'custom_components.sonoff' is not a package
2019-04-02 20:13:28 WARNING (MainThread) [homeassistant.loader] You are using a custom component for switch.sonoff which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2019-04-02 20:13:28 WARNING (MainThread) [homeassistant.loader] Integrations need to be in their own folder. Change switch/sonoff.py to sonoff/switch.py. This will stop working soon.

Not sure what the error as it’s not my component but it might be easier to install manually. You can grab the raw files from github and save as individual files. This is what my file structure looks like. I am also on v90.2.

43%20AM

hi all, i’m the creator of the sonoff component.
for those of you who are in doubt on how to install it 1st of all please read the description (that’s the main problem usually) and/or follow up in the original thread.
if you want to help integrating the device mentioned by @sfgabe feel free to join (and help) the discussion https://github.com/peterbuga/HASS-sonoff-ewelink/issues/83

also, HA v0.88+ needs a different structure of the files (@sfgabe) and there are branches that follow this change.

1 Like

Out of interest, if this works as a sonoff, can it be flashed with tasmota, and addressed directly?

A bit late but I just want to share my recent experience. I also bought this one:
https://m.aliexpress.com/item/33014570952.html
They nicely show in the video and images that is compatible with eWeLink but it’s not. It can pair only with Tuya or Smart Life and it’s not recognized by HA. So be careful guys.
As with regards to the eWeLink ones, did you manage to integrate it in HA? Can you adjust more settings than only the power?
As I see Smart Life can connect with IFTTT but the diffusers are not recognized as compatible devices. So, as a workaround for people who don’t want to install too many things, you can create a scene in Smart Life that turns the diffuser on/off which is recognized by IFTTT. Therefore you will have something like HA -> IFTTT -> Smart Life -> diffuser.
Really don’t like this solution but it works for now.

I have same thing, did you find it ?

Tasmota found just 1 GPIO15 which is Led on off Only.

Power ON/OFF is not found.

It was Tuya platform.

Actually, this is very strange.