andrewmv / esphome-lasko

ESPHome config for Lasko tower fan
0 stars 0 forks source link

Question about the hardware side #3

Open Diegus83 opened 1 month ago

Diegus83 commented 1 month ago

Hi! Thanks for sharing this code, I have a similar fan and I'm looking to make it ESPhome compatible.

Can I ask how you implemented this on the hardware side?

It seems to me you are using the IR receiver to keep track of any status changes caused by an user using the IR remote, so when someone sends a command you update the fan status. And you are also using the IR emitter to send command to the fans when an user sends a command via ESPhome/Home Assistant?

Is that correct?

I'm looking to place this inside the fan case and maybe also monitor the physical buttons in case someone in the house turns on the fan by pressing them.

andrewmv commented 1 month ago

Oh cool, glad you've found this useful...and a little impressed you found it, since I've apparently documented absolutely nothing on this one.

Your intuition is correct - I've got the OUT pin of a VS1838B IR receiver directly connected to D7, and a super-bright IR emitter connected to D6 via an N-Channel MOSFET to drive it at something like 10W so that it doesn't rely on line of sight. I pulled all the codes by turning on debug mode and pressing all the buttons on the factory remote.

I have the ESP assembly mounted to the wall near an electrical outlet - I've found this particular fan is very picky about line of sight, so I needed to go nuts with the power of the IR blaster to get it to work reliably. If you tape your ESP to the front of the fan (and power it somehow) you could probably skip the amplifier circuit and wire an LED directly.

The receiver is optional, and just there to keep the state from falling out of sync if you also intend to use the factory remote control. I never really ended up using this feature after I got it working right with HomeAssistant anyway, though.

I don't actually have a solution for using the physical controls on the device. I suspect that rather than wiring all the buttons in and trying to keep a fancy state machine going, it'd probably be easier to just remove the original control IC from the board and run everything directly from the ESP board. This has worked well enough for my needs, though, and when it occasionally falls out of sync I just use the physical controls to fix it.

andrewmv commented 1 month ago

These are the emitters I used: https://www.amazon.com/gp/product/B00ULB0U44/

And the driver circuit looks like this. irblaster_scribble

It's almost certainly overkill, but I've deployed these in a few different rooms in my house and they work pretty reliably.

Diegus83 commented 3 weeks ago

Oh wow, thanks so much for the detailed answer. I did a search for "ESPhome Lasko fan" and your repo eventually appeared in DDG. It has been extremely valuable since this is my first ESPhome project.

I had time to play around with this for a bit, one thing I learned is that the IR protocol seems to be fairly flexible with the exact timing of the codes, I captured the ones of my remote just for fun and they are slightly different from yours but the fan still accept both.

I think I will mount the ESP directly inside the fan case so I can leech power off it and that will also solve the IR issues because in my test it was hit and miss once the fan started oscillating, I'm driving my emitter at much lower power with a 2N2222 because it is what I had around.

I suspect that rather than wiring all the buttons in and trying to keep a fancy state machine going, it'd probably be easier to just remove the original control IC from the board and run everything directly from the ESP board. This has worked well enough for my needs, though, and when it occasionally falls out of sync I just use the physical controls to fix it. I noticed the control board inside the fan uses this µC SN8P2501DP and the board only has three wires running to it, I guess ground, +V and a serial interface. It would certainly be an interesting experiment to sniff that line and replace the entire control by an ESP but I lack the equipment to do that.