DIY IoT Fan
mulliken.netThis is a nice hack, but I'm always very wary of playing with large voltages because it's too easy for things to go wrong. Instead, for controlling mains devices, I recommend a Sonoff S20:
https://esphome.io/devices/sonoff_s20.html
I usually flash ESPurna onto it (Tasmota and ESPhome are also good choices), it's very easy to do and it's extremely reliable and hopefully has a lower chance of fire than anything I'd make.
For just turning something on or off I've been happy with the "IoT Relay" from Digital Loggers [1][2][3]. It is essentially a power strip with 4 outlets and a control connection. The control connection can take either a DC signal from 3-60 V or an AC signal from 12-120 V.
One of the outlets is always on, and the other three are controlled by the control signal. Two of those are normally off and turn on when the control signal is present, and the third is normally on and turns off when the control signal is present.
I'm using it to control a space heater with a Raspberry Pi. The GPIO pins on most microcontrollers commonly used in DIY projects will work directly to control the relay.
[1] https://dlidirect.com/products/iot-power-relay
[2] https://www.sparkfun.com/products/14236
[3] https://www.amazon.com/Iot-Relay-Enclosed-High-Power-Raspber...
I'm looking for something similar: a power strip with all the outlets individually switchable. At least 4. So like a mix between that and a Sonoff S20.
Having three instead of four switchable outlets, and different "normally on" and "normally off" setting threw me off a bit.
The issue here is that these fancy tower fans don't have a mechanical on/off switch. So just switching the mains voltage does exactly crap.
...well not crap, mine beeps a few times when the power turns on =)
The ESP32 fiddling is required to fake button presses on the touch sensitive buttons to make it actually start.
Good Lorde how I hate capacitive touch buttons on appliances and such. I regularly brush by my icemaker (it's a tight corridor/passage), and cause the water dispenser to splash everywhere. I have a 3D-modelled overlay (basically a custom mesh) queued for 3D printing, to stop it from happening. The moment the warranty ends, I'm ripping into it, and putting physical switches.
Well, I already opened it to solder a beeper bypass switch [aka "mute button], 'cause the thing was (multi-)beeping constantly, on every action and every result! But that mod is reversible without any visible changes... which reminds me, have to do the same to the bread machine. To my detriment, appliance makers these day are extremely beeper-happy.
He's not playing with mains voltage (except to wire in the USB power supply) - the button's he's "pressing" with his relay are part of a low voltage control circuit.
But that just gives you on/off controls and maybe energy consumption, doesn't it? It won't let you play with the fan speed, which is probably something I'd want first and foremost.
I've used some TP-Link's equivalent up until the point when TP-Link decided to effectively brick it for me by disallowing control via local network because "security". I'm very concerned about someone on my WiFi turning on my kettle and boiling me some water. :)
OP uses an off the shelf USB 'wall wart' for power, everything else is <= the 5v that that provides. It's not really any more involved/risky/'playing with large voltages' than say changing the plug on a power cable, or using one of the terminal-block-style Sonoff devices.
220V are not large voltages. It's within capabilities of a properly taught highschooler to make sound circuits for mains.
It's when you get above 400V+, then the physics of electricity gets tricky.
220v is still a lethal voltage, and 220V at 10A is enough to sustain a nasty arc in the right circumstances.
An arc can have the temperature of four times the surface of the sun and will not neccesarily trip a noormal protective device due to its impedance.
Just for interest, vaporised copper has 67,000 times the volume of solid copper, this is why it makes quite a big bang.
I am an electrical engineer, most people do not fully understand the dangers of electricity and the lottery they play even at 110VAC.
The "physics" of electricty are tricky at all voltages, there are recorded cases of people dying from electric shock from a 24VDC truck battery.
>The "physics" of electricty are tricky at all voltages, there are recorded cases of people dying from electric shock from a 24VDC truck battery.
yes, that's because lethality is a combination of voltage, current and the location where those are applied to the body. Apply one charge to your foot? No problem. Apply the same charge to your chest right above your heart or in some configuration where the current flows through your heart? You are probably going to have a bad day :p
> properly taught
Key words the author did not write. While electrocution might be the first thing to come to mind, the ongoing risk of house fire might be the risk that best guides the (mis)use of hardware certified to perform a task.
The pinout of that ESP32 board says 3.3V but the author feeds 5V into it. But apparently it works :)
Something else I didn't quite understand: they write "NodeMCU ESP32 which is a small IoT device with a USB port and is programmable in ESPHome". Does that mean that the little board itself does not need to be flashed? That, out of the box, it's controllable/programmable in ESPHome, which is webbased?
Looks like a fun little project, all in all. Kudos for documenting and sharing it!
> The pinout of that ESP32 board says 3.3V but the author feeds 5V into it.
He is using a dev-board with a USB jack and an integrated step-down converter. The ESP32 is not 5V tolerant at all, the pinout diagram is for the pads on the ESP32 module, not the whole board.
It does still need to be flashed. ESP32 are blank on arrival
Cool DIY guide to make a smarter fan!
I was playing around with upgrading my own fan last year and ended up adding person-tracking capabilities so that the fan automatically stays pointed at me when I move. I ended up started a company, Following Fan, that builds and sells these tracking fans!
I have this same exact fan! And the remote recently stopped working so I was thinking of doing something really similar to this. Glad to see it worked out.
I recently came across this neat button pusher IoT gadget (used it to control the boiler in our rented accommodation): https://www.switch-bot.com/products/switchbot-bot
A less intrusive and safer alternative for those not quite comfortable with mains diy.
I installed an IoT IR blaster, since our air conditioners and ceiling lights all have IR remotes. Works fine, and if it stops working it doesn't matter since we didn't actually replace anything and lose any existing functionality.
For those less keen on mains voltage - some wifi smart plugs can be flash with tasmota without opening them.
Tricky but is you need a fan that powers on when it gets juice. Something that requires a button press won’t work
A neat trick: there is almost always enough AC on the neutral, even when the line is off to run some very low power MCU, or even do some LED blinks.
Between neutral & earth? That's surely going to depend on the topology of your earthing system [0] - TN-C will be so low impedance you won't get much through your deliberate load at all, more with TN-C-S, but most luck with TN-S where neutral already has a long cable run full of impedance before it joins back up with earth, and you can add a small enough load that that path gets a non-negligible share of the current.
[0] - https://en.wikipedia.org/wiki/Earthing_system#IEC_terminolog...
Even device's own ground plane some times works. Though, it's near impossible to do with isolated power supplies. Modern ULP MCUs are incredibly power efficient, and can run for a day on a power of a single LED blink.
Anything wireless is still out of the question unless real ground is there though. Without ground, a dedicated power harvesting circuit would certainly provide more power.
We experimented with harvesting, with 10cm antennas, it's just enough to do a single beep once 20-30 minutes using specialised ULP UHF radios, or RX for a few seconds once a minute.
I have the same fan, I'll love to control it with esp32. Is he using 3 relays to trigger on/off, rotation and speed? Also, from what I see, he is not detecting the previous state?
I was wondering the same - I re-read it a couple of times and he only seems to be concerned with turning it on and off. I can see where speed would also be useful and I'm sure it's just a matter of using more relays. State is another matter - but it looks like it does have a least a few LEDs that are on when it's working - a voltage probe across one of those LEDs or another similar point should be pretty easy without having to get near mains voltage.
For anyone who wants the luxury without DIY. I really dig the Xiaomi fans and their 'nature' mode.
I did this with an Arduino and a light when I was in highschool a few years ago! Very fun project 11/10
Wondering if esp32 + some infrared board wasn't an option here
Neat hack, but why would you want a fan on the internet?
Automation - for the vast majority of people - isn't so much about having something "on the internet" (like a free roaming chicken?) but to be able to control it intelligently. For example when I set the alarm to leave my house I have a routine that kills any lights in rooms that might be left on, adjust the thermostats on my HVAC, kills all the ceiling fans, etc.
Conversely when I'm heading home I can remotely let my automation know so that it sets the recovery temperature on my thermostats and resumes the ceiling fans to help circulate things with the HVAC system. If I had a room without a ceiling fan but could still benefit from circulation this would be a nice solution along the same lines.
Combine systems like the above with occupancy sensors and zoning and energy savings are significant enough you notice them in your power bill.
And all of that runs on a box in my living room - cloud is for remote access only; I loathe cloud only automation systems :p
esphome seems pretty great, been meaning to give it a try.