Sonoff-HomeAssistant (Alternative firmware for Sonoff Switches for use with mqtt/HA)

OK just bought 2 units from Ebay. Hopefully it will work this time.

I have no idea which pin goes to which pin. I had it working with Arduino Pro Mini. Anyway, I tried it by doing so…

…and it still fail.

Do you get any output in the arduino ide?

Yesterday my 5 sonoffs arrived and it was not enough to press the button while powering up but I had to press the button during the whole uploading session (with a high baud rate not a problem at all).

Ah, and what I had to do: use an external 3V3 power source. I connected TX,RX and GND of my sonoff with my FTDI device and V3V and GND form sonoff to the power source. The sonoff and the FTDI hav to share the GND or it wont work (Shared GND for heart beat or link detection? Don’t know it anymore…). 0.5 Amps from standard USB Port is not enough it seems.

My sonoffs (marked as “2017” version, marketing trickery) looks like this:

and this:

I got 5 pcs. At least two of them (did not check the others by now) have a hand soldered capcitor in the middle of the board.
Any comment on this?
I think it could be some communication stability improvement by adding this capacitor.

@KmanOz This is an outstanding piece of handywork, Thanks for sharing with the community and please keep up the good work.

Your instructions on guithub are very thorough and have helped get the job done.

Thanks again.

No problems at all. I’m a bit slack ATM because my new 3D printer has me occupied :smiley: I have a Sonoff 4CH sitting here I need to get writing some code for. That’s next :smiley:

Yes there is some basic serial debug info the Sonoff spits out.

@KmanOz: I probably replied to you instead of @masterkenobi. Sorry!

@masterkenobi: Do you get any output in the arduino ide?

have been using Arduino Uno to program esp8266… try connecting TX to TX and RX to RX. this is how it worked for me.

@KmanOz everythink works perfectly, until the power is gone. When i unplug the sonoff, and plug it again, it sets relay in state which is in EEPROM, but it does not connect to wi-fi. After few minutes, it connects again. It is not issue with my network, because after pugging it, when I press and hold button to restart it, everythink is good (connected to wifi and ready to work). Do you have any idea? Thank you.

I had a similar issue, it ended up being interference with the lamp I had the sonoff installed in. When the back of the sonoff was mounted against the metal backing of the lamp, it would have troubles connecting to wifi. I could see it hitting my router and connecting, but the connection would drop after a minute and 30 seconds and the sonoff was only responsive with the physical button. After adjusting the location I’ve had zero problems after a power fail.

I think issue with my sonoff is not with location, because when I hit the button it connects flawlessly.

So what you’re saying is it connects flawlessly after a reset? When you say you hit the button do you mean you press and hold the button. Is that right? Also do you have more than 1 unit. Does it happen on all of them?

Yep, you are right, but now it works… The only think I changed was the location of sonoff, and router (but it is stll the same model). Anyway, thank you!

Hi :slight_smile:

Thanks for all your work on this, I’ve managed to successfully load your firmware but I’m struggling with the HomeAssistant part.

I just can’t seem to figure out the automation part.

I want to say turn my light on at 22:00 every day and then off again at 05:00 and I can’t get the code right in the configuration file for Home Assistant.

I am sure I answered this sometime ago. Look further up in the thread somewhere where I showed some simple automation examples.

Hey Guys,

I’ve got 4 of these now, all working great. Very easy to setup and configure.

The only small quirk I have, is if i reboot or powercycle my HomeAssistant, it takes around 20-25 minutes for the Sonoff switches to become responsive in the HA UI unless I physically reboot them.

Is this normal or has anyone experienced this?

I’m just using the built in HAMQTT Broker.

Cheers Rob.

The code in these units reboots them every minute unless they have WiFi or mqtt server. If they connect 20-25 minutes later then something else is happening. Do they all connect at the same time 20-25 minutes later?

Hey KmanOz,

I’m very confident it is not to do with the Sonoff-Homeassistant Firmware you provide.

They all pick up the wifi almost instantly upon boot, I can see them in my router, ping them and show under presence detection.

They don’t come online at exactly the same time but once one comes online they all follow closely.

I’ll keep fiddling see what I can come up with.

Cheers Rob.

I am kind getting the same issue as Halflcuk, come on line with AP fine… and then does no seem to try and access the MQTT broker, (from what i can see in the brockers logs), If i wire the Sonoff upto the USB to debug it connect everytime :confused:

anyone seen this before ?

So if I only plug the up-to the USB serial with no AC power it logs into Wireless and MQTT brocker…