I have to turn on and off (not speed control) my celing fan using sonoff basic via google home, I have 3 wire in my fan (see image) White+White , Black+Red , Black+Black. how can i connect these with sonoff ?
This is a probable scenario but there is no way for a remote person to be sure so proceed at your own risk.
The white wire is the neutral.
The black wire is the main fan motor hot wire from the wall switch.
The red wire is the hot wire for the light circuit from the wall switch.
To operate the fan motor with sonoff:
You would split the two blacks. The one coming from the wall switch is the line input and the one going to the fan is the line output.
Likewise you would split the two white wires. The one coming from the wall switch is the Neutral input and the one going to the fan is the neutral output.
In my opinion it is better to replace the wall switch with IOT than to do it in the fan. Keep in mind that if someone turns off that wall switch the Sonoff will also be turned off. Of course if you don't have a wall switch to start with then you have no choice but to do it in the fan. Another 2 cents worth...if you put the Sonoff inside that metal casing the wifi is likely not going to work since it is a radio signal.
Put sonoff in wall behind fan switch. (Power at fan is broken by the wall switch unless you leave wall switch permanently on.)
Sonoff live side has red and black using another pair of wires connecting to red and black from main circuit breaker.
Output uses another pair of wires connecting in parallel across the 2 x blacks across the switch.
Dont touch High voltage unless your authorised . At least turn of breaker for that circuit.
You can only use one wire are the neutral?common runs thru the Sonoff.
Keep the active on the same side of the Sonoff as where its run in or when it operates it will short wiring.