Posted on 35 Comments

#33: Sonoff Mini and S55: ALMOST perfect

The new Sonoff Mini DIY and Sonoff S55 are (so far) the best Sonoff devices that ITEAD has made. Flash them with Tasmota, and they get even better.

Resources

Background

The original Sonoff Basic didn’t have any provision for an external button or switch. One of the most common hacks is to add a switch, so ITEAD decided to make it easy and put screw terminals right there on the Mini.

The Mini is also the smallest Sonoff model so far, which makes it ideal for retrofitting behind an existing switch. Combined with the screw terminals to connect the switch, the Mini is probably the best general-purpose Sonoff for anyone wanting to retrofit home automation to an existing home.

The S55 is an exterior-rated GPO (General Purpose Outlet) or power point. It allows you to have both local control of the power point using a button, and also control from your home automation system.

Both are nice devices, but they become even better when the amazing Open Source Tasmota firmware is installed on them.

Over the years there have been many methods developed to do OTA (Over The Air) replacement of the existing Sonoff firmware with an alternative such as Tasmota. However, I’ve found that these methods are either frustratingly complex or just stop working because ITEAD change things with new releases. I don’t even bother trying these methods anymore: I just go straight to connecting a USB-to-Serial adapter to the programming pins on the Sonoff’s processor. It can be tricky to get the connections sometimes, but it’s guaranteed to work every time single time.

Warning: Do not attempt to connect a programming adapter to any Sonoff model while mains power is connected. ALWAYS disconnect the Sonoff and power it ONLY through the 3.3V connection.

Install Tasmota on Sonoff Mini

The programming connections for the Sonoff Mini are provided on tiny flat pads on the bottom of the PCB:

The button on the top of the PCB is connected to GPIO0, so if you connect to GND, 3.3V, TX, and RX, you can put the Sonoff Mini into programming mode by holding down the button while connecting power from the programmer.

Unfortunately the pads on the PCB are very small, so soldering jumper wires onto them is tricky. If you have a small soldering iron and good eyesight (or magnification) you can solder wires directly onto the pads.

Just be careful you don’t apply too much heat, because the pads can come away from the PCB!

To get around that problem I used my 3D printer to make a programming jig using a design published on Thingiverse. This programming jig uses “pogo pins”, which are spring-loaded pins that can make temporary connections to a PCB. Pogo pins come in a variety of sizes and shapes. I used P75-B1 pins, which means they have a 0.75mm diameter pin with a simple conical point:

This design has 3 parts: a base that holds 4 pogo pins, a small spacer that slips over the pins to help keep them aligned, and a top that goes over the pins and then provides alignment guides for the Sonoff Mini.

I used super-glue to attach the top to the base, once I’d checked everything was aligned:

The Sonoff Mini can be attached using an elastic band:

The pogo pins push against the pads on the PCB:

Hold down the button on the PCB while plugging in the programming adapter to force the Sonoff to go into programming mode, then you can use Esptool or whatever other method you prefer to load the Tasmota binary. In my case I used Esptool, and the command looked like this:

esptool.py -p /dev/tty.usbmodem141101 write_flash -fm dout 0x0 sonoff-6_6_0.bin

However, this command is specific to the USB port that I used on my computer. You may need to adjust the command to suit your needs. This is all documented well on the Tasmota site.

Because the Sonoff Mini has different pin arrangements to a normal Sonoff Basic, and it’s designed to use a normal switch instead of a button, you need to load a special configuration for it.

After you’ve been through the normal Tasmota setup process and connected it to your WiFi as described in the Tasmota docs, go to the Tasmota templates site at blakadder.github.io/templates/ and search for “Mini”. You’ll find a template that looks like this:

{"NAME":"Sonoff Mini","GPIO":[17,0,0,0,9,0,0,0,21,56,0,0,255],"FLAG":0,"BASE":1}

In the Tasmota interface, go to Configuration -> Configure Other and paste the template into the “Template” field.

Make sure the “Activate” check-box is ON, then click “Save”.

Your Sonoff Mini will now operate as expected, with the external switch operating in the normal way.

Install Tasmota on Sonoff S55

The Sonoff S55 doesn’t have a “DIY mode” jumper, so that’s not an option. Luckily, the usual programming header is provided on the PCB ready for you to solder on wires, solder on a header, or just press connections against it. The button for external control is linked to GPIO0, so it’s very easy to put it into programming mode.

The header is in the normal 0.1″ pitch so it’s large enough to solder on a header directly. There’s no need to use a complex pogo pin programming jig.

Solder some hookup wires directly onto the pads, or solder on a header:

I soldered a 4-way 0.1″ header socket onto the pads, with the pins bent a little sideways to make the head sit almost horizontal with the PCB. This makes it easy to plug in a Sonoff Programming Adapter, or use jumper wires to your own USB-to-serial converter.

Hold down the GPIO0 button while you connect the programming header to put it into programming mode, then follow the normal instructions for installing Tasmota. This is very well documented on the Tasmota site.

There’s no specific device profile for the S55 in Tasmota, but it uses the same pinouts as the Sonoff S26 and other mains-plug adapters. Simply select “Sonoff S2x” as the module type in the configuration interface, and it will work as expected.

35 thoughts on “#33: Sonoff Mini and S55: ALMOST perfect

  1. Thx for giving us another great tutorial……

    Glad that you are back

  2. Hi,
    Have a look at the following Amazon items:
    B07FKYT5G8 I have bought three (3) of these three (3) gang wall light switches and loaded Tasmota onto them. They work very well. They work manually as well as via the WiFi (in my case openhab).
    One actually drives two (2) down lights (left and right switches) the center switch communicates with openhab and it then Tx’s a IR code for the ceiling fan. 🙂

    I’m about to buy a couple of these GPO’s to give a try for things like Soldering Iron switches 😉
    B07S942V7L

    Just plug the above codes into the Amazon search bar.
    Neil

  3. can you please add the flsh gid to your online store? I would buy one and i’m sure others would also.

    1. I will as soon as it’s ready. I’ve done an updated version with auto-reset but the pinout on the programmer probably has to be changed before I release it. It’s all tied up with the “let’s make a standard programming header for ESP8266” discussion at the moment.

      1. Got anywhere with this yet, I want to buy a kit ready made to tazomtize the mini

      2. I am definitely keen on one of these programming jibs also when they are available.

  4. The mini will be great when they make a version that doesn’t require a neutral wire. Like almost every device it suffers from that annoying requirement.

    1. Mainly because it requires both Positive (AC LIVE) and Negative (AC Neutral) to turn on. Try using a device with only one side of the battery connected.

  5. Hello! Do you thin is it posibile so i can but from you a complete programmer set stand and pcb for the sonoff mini?

  6. Hi Jonathan! Actually it’s not needed to solder/dissasemble the Sonoff Mini to upload Tasmota anymore as they have DIY mode from version <= 3.3. With the (DIY) jumper installed you just need to make an access point with an ssid sonoffDiy and password 20170618sn. And than just use the tool on their github ( https://github.com/itead/Sonoff_Devices_DIY_Tools?files=1 ) to upload any firmware you like 🙂

    1. Yes, I addressed that in the video. DIY mode is a good idea, but it’s a horrible implementation with an annoying process.

  7. hi Jonathan,
    I am just found your channel on youtube and really like all of your ideas .
    could you help me with fill things please .
    1- in the codes libriary there any thing that will help to slow down a motor after the sensor pass to some point and not let it goes at same speed till the end or when it come back on reverse again slow down.

    2- the sonof mini has the S1 S2 pins 3.3 volts . I got some 5 volts infrared to conect on it but want activate the infrared on 3.3 volts any ideia to sorting it .

    I was looking about buck converter with LM7805 but I just need get the signal and not sure if really needs it or could use something cheaper like 10k resistor than load the infrared with 5 v to dropping to 3.3

    3- the same way I have another problem where I am getting 12 volts signal and want load in the pins S1s2 to put sonoff mini on than was thinking would just resistors to drooping down would be fine or not ?

    4 – do you sell this Sonoff Mini Programming Jig’ ? really like the one you did .

    thank you

    1. 1- Sorry, I don’t know what you mean about the codes library, or how this is related to Sonoff. Do you want to control a motor with a Sonoff? If you do, you can’t control the speed.
      2 & 3- If you want to trigger the S1/S2 inputs, what it actually needs is to be driven to 0V in an open-collector arrangement. One of those pins is permanently connected to 0V inside the Mini, and the other is connected to a digital pin. It’s watching for the digital pin to be pulled down to 0V.

      Instead of a voltage regulator, it sounds like you need a voltage divider. It’s a common technique to convert 5V signals to 3.3V signals. If you search for “voltage divider” you’ll find plenty of examples. But this may not be appropriate either, we’d need to know a lot more about what you’re connecting together to understand the problem you’re trying to solve.

      The best thing is to describe what you’re trying to connect on either the Forum or the Discord server (both linked at the top of the page) and discuss it there.

      4- I will, but it stalled because of the problem of defining a standard programming header and I need to get back to it.
      3-

    2. Do you happen to know exactly what amperage the dc switch loop runs at?
      Does anyone?
      My testing Sonoff melted and I’m kinda grasping at straws so I won’t need to come back to this a week from now.

  8. hi Jonathan ,
    thank you .
    1- about reducing the speed of the motor with code come in mind after I tried do something in my gate motor and could not have the board works as I want and also I was the ideia of it is to use in another project use a small servo with gear reduction to turning old door locker … Probably will be easy buy a solenoid locker but I just want adapt it on the actual and have access remotely .

    http://www.dummies.com/computers/arduino/how-to-change-the-speed-of-a-dc-motor-with-the-arduino/

    How to Change the Speed of a DC Motor with the Arduino

    Sometimes you need to have greater control over the speed of your motor, which the Arduino allows you to do with the MotorSpeed sketch. The following shows you how to control the speed of your motor with the same circuit.

    The MotorSpeed sketch
    Open a new Arduino sketch, save it with a memorable name, such as myMotorSpeed, and then type the following code.

    int motorPin = 9;
    void setup(){
    pinMode(motorPin, OUTPUT);
    }
    void loop() {
    for(int motorValue = 0 ; motorValue = 0; motorValue -=5){
    analogWrite(motorPin, motorValue);
    delay(30);
    }
    }
    After you’ve typed the sketch, save it and press the Compile button to check your code. The Arduino Environment should highlight any grammatical errors in the Message Area if they are discovered.

    If the sketch compiles correctly, click Upload to upload the sketch to your board. When uploading is done, you should have a motor that spins very slowly to start with, speeds up to its fastest spin, spins back down to a stop, and then repeats. It can be difficult to see this, so you should fix something more visible, such as adhesive putty, to show you what’s going on.

    You may find that at its slowest point, the motor just hums. If so, this is not a problem; it just means that the electromagnet doesn’t have enough voltage to spin the motor; it needs more voltage to generate the magnetism and gain momentum.

    The MotorSpeed sketch breakdown
    The pin you are using to control the motor circuit, digital pin 9, is declared.

    int motorPin = 9;
    Because it’s an output, you define it in setup.

    void setup() {
    pinMode(motorPin, OUTPUT);
    }
    In the main loop, you use analogWrite to send a PWM value to pin 9. This is the same principle as in the Fade sketch, used to fade an LED. The first for loop sends a gradually increasing value to pin 9 until it reaches the maximum PWM value of 255. The second for loop gradually returns this value to 0; then the cycle repeats itself

    void loop() {
    for(int motorValue = 0 ; motorValue = 0; motorValue -=5){
    analogWrite(motorPin, motorValue);
    delay(30);
    }
    }
    This process could be likened to revving a car engine. If you push the pedal down, you accelerate to full speed. If you tap the gas pedal, the engine accelerates and then slows down. If you tap it at a constant rate before it slows, you will maintain some of the momentum of the spinning motor and achieve an average (if somewhat jerky) speed.

    This is what the transistor is doing, but very quickly. The intervals between on and off and the momentum of the motor allow you to achieve analog behavior from a digital signal.

  9. About the infrared that I am looking put on pin s1 s2

    the infrared i want put on the s1 s2 is that one ….. just for get alerts ….. and maybe turning on and off the sirene 🚨/ alarm .

    https://www.amazon.co.uk/SeeKool-Pyroelectric-Microcontrollers-Electronic-Raspberry/dp/B07DVZLHFB/ref=mp_s_a_1_1?keywords=SeeKool+5pcs+HC-SR501+Human+Body+Sensor+Module+Pyroelectric+Infrared+PIR+Motion+Sensor+Detector+Modules+for+Arduino+UNO+R3+Mega+2560+Nano+KY65%2C+Genuino%2C+Microcontrollers+Electronic+Projects&qid=1578436075&sr=8-1

    was found it on amazon

    10pcs L7805 LM7805 7805 Voltage Regulator +5V 1.5A

    https://www.amazon.co.uk/10pcs-L7805-LM7805-Voltage-Regulator/dp/B071R4VVCL/ref=mp_s_a_1_1?keywords=10pcs+L7805+LM7805+7805+Voltage+Regulator+%2B5V+1.5A&qid=1578435197&sr=8-1

    Adafruit 3.3V 800mA Linear Voltage Regulator – LD1117-3.3 TO-220 [ADA2165]

    https://www.amazon.co.uk/Adafruit-800mA-Linear-Voltage-Regulator/dp/B01BMRDFRE/ref=mp_s_a_1_1?keywords=Adafruit+3.3V+800mA+Linear+Voltage+Regulator+-+LD1117-3.3+TO-220+%5BADA2165%5D&qid=1578435246&sr=8-1

    3v just be aware of that Other then that it is highly recommended
    This is helpful for putting stable 5v but it doesn’t start working until 3.3v just be aware of that
    Other then that it is highly recommended

  10. about the 12 volts I want put on the s1 /s1 on the mini to get signal

    will be this device https://m.ebay.ie/itm/262753744565?_mwBanner=1&_rdt=1

    I know the regular sonoff with thermostat but I want put it conect to my water tank to check temperature than sent signal to the central heating turning on and off
    .

    the other thing I am doing with the 12 volts signal hacking my intercom but inside my apartment …. for this I probably keep using the original firmware and ewelink app

    calling the intercom from outside apartment than press on ewelink turning on the sonoff than closing a external relay in the board of my intercom inside apartment than door opens without someone answering inside the intercom and i don’t need the expensive foobs that are in use here

  11. Thanks a lot for all your work! I flashed my Sonoff Mini with Tasmota and discovered the external switch didn’t work. Luckily you provided me with a good and working solution!

  12. Brilliant work! Thank you.

    I would like to know if it is possible to connect a TTP223 capacitive touch switch on a SONOFF MINI instead of using a standard switch connected to S1 & S2. This way I could make the switch invisible behind a board for example.
    What would be the easiest way to achieve this ?
    TTP223 has 3 connections: VCC=3.5-5.5V / GND=0V and I/O.
    I guess I need to connect it on Sonoff Mini using:
    – S1 for GND
    – S2 (GPIO4) for I/O
    – 3V (or 5V?) available on the back of the Sonoff Mini PCB
    Since I am a complete newbie in electronics I would be happy to have your advice before I burn my Sonoff Mini ;-).
    Hope my English is ok
    Best regards
    Catherine

  13. Yes, it works!
    I connected the Ttp223 touch sensor to a SONOFF MINI :
    Sonoff Mini –> TTP223
    ■ S1 –> GND
    ■ S2 –>I/O
    ■ 3.3V –> VCC
    Be careful, the sensor is very small and the 3.3v connector on the Sonoff Mini PCB is very tiny to solder a wire.

  14. Is there any way to use the Sonoff Mini S1,S2 to connect up a little water leak detector? I would like a leak detector to turn off a circ pump by triggering the sonoff mini’s relay and reporting to eWelink, most of the leak detectors are 433mhz and need a hub.

  15. Hi Jonathan, this was a great video and showcases a lot of interesting capabilities. The Sonoff Mini really suits my use case. I have been trying to look around on your site and through comments. What is your view on the electrical certification of these products for use in Australian homes? My two concerns are: 1) Would licensed electrician perform this sort of install 2) Would it impact my home insurance coverage in the event of a fault?
    I have been scouring various forums, and feedback on this seems quite vague.

    1. Hi again, just stumbled upon your VLOG63 which was very insightful around insurance coverage, so that answers part of my concerns. But to my original question, would an electrician still be willing to perform this sort of work on devices that may not have Australian certification?

  16. Hi:
    Thank You for one of the best instructive videos I’ve ever watched. I learned more in 27 minutes than in tens of hours of reading web sites.

    While watching your youtube video near the end of it you said”alexa please turn on test GPIO” and my alexa responded with OK and my desk lamp turned on. Do I need to do anything to return my alexa back to normal? So far I see no difference in the operation to my six plug adapters I have on my system, but I plan to install 8 more sonoff minis. I will be using three of then to upgrade my old hot tub, my first attempt used IFTTT smart switches and without a reset switch they were very hard to keep paired. I’m not a software engineer like you, but I can hold my own in electronics engineering of 10 years ago.
    Again thank you for your help and for providing this service.
    Do you sell your GPIO programmer boards?

  17. Hi, is the Sonoff Mini jig ready yet. I need one

    1. Hi Michael,
      The jig is not essential now that the DIY mode has been updated. Search online to find the latest method which was only released I think in April. I had some issues on the first batch but since then it has been easy.

  18. Just a precautionary comment: I was trying out various switch types (spst, mom.on, etc) with a Sonoff mini when I got a rather nasty electrical shock. I was suprised because all I was touching was the switch (a C&K SPST). I got my trusty Fluke multimeter out and measured voltages on the terminal block. I was surprised to find 96 Volt AC from neutral to either switch terminal, as well as 106 V DC from neutral to either switch terminal. All I had touched accidently was the back of the C&K switch, which I assumed from the video (9:06 minutes in) was at 3.3 V. So be advised, check all voltages first. Don’t assume!!

    1. I just checked three more Sonoff mini’s for the voltages from the back of the switch to earth and they are the same as I posted above. Note that the voltage between S1 and S2 is 3.3 V DC, which may confuse somebody setting up the switch. The Sonoff notes, besides being too small to read, advise “Please do not touch the switch during use”, but this statement is not clear on which switch is being referred to, especially as the diagram shows some type of switchboard switch. Of course all carefull qualified professionals should and will make sure power is off when installing mains voltage circuitry, such as a Sonoff switch.

  19. I purchased 5 Sonoff Mini’s. 1 Arrived dead on arrival and wouldn’t pair. Of the 4 remaining, only 3 are still working 2 months later. The 4th one has lost wireless and refuses to pair. Sonoff support start are next to useless and seem to have no interest in trying to support their product and are more interested in trying to blame your WiFi. For reference, all 4 devices were installed within 50cm of each other. Build quality is questionable and the cases easily pull apart. Really hard to recommend as they are designed to be installed inside the power points which mean you either need to know what you’re doing or get a sparky which far outweighs the low price point. Get an external smart switch instead, this way if it fails which seems likely given my 40% failure rate you can always pull out the smart socket and continue to use the power

  20. Friends,…
    I have been attempting to flash Tasmota on my 15 Mini’s for over a year, without any luck. I’ve managed to brick them all (10 more on order from Banggood). A couple were bricked initially when I attempted to solder itty-bitty wires to their pads. I’ve learned my lesson.

    So, took the alternate, and attempted to do OTA (version 1.0). I had no throuble, until the DIY “TOOL” failed to find anything via mDSN. For some reason mDSN wouldn’t work on any of my many systems, something about not having iTunes installed. So, I found Bonjour for Windows, but that didn’t fix anything. But I kept trying.

    Finally, Sonoff gave us Version 2.0 of OTA which was going to be my savior. I went through many days of trying to find the magic sequence to make it work. After many bricks, and many long weeks, success. I thought.

    After all the testing and hacking, I felt that I had finally made it. The last step was to master ARC (the Advanced Rest Client). I followed all of their examples. Repeated them, to be sure I knew what I was doing. Tested and tested, without a failure. I was so confident, I went ahead and tried to flash Tasmota. Surprise… Another brick. For the life of me, I couldn’t see what I did wrong. I thought it was an act of God. But I looked at, even installed a copy of Linux Server, but backed away. What a bunch of junk, just to flash a small image. So, I attempted flashing once more, and promptly created my last brick. Defeated, I’ve just ordered another few Mini’s from Banggood.

    So, now I’m begging for a jig to help me flash Tasmota. I’ve got so many bricks, and the only way to try to resuscitate them is via a wired flash. But, I am a shaky 78 years young, and recently had a very debilitating stroke – my right side is totally gone, and I used to be right handedA. That combination has left me rather useless with a soldering iron. My only saving hope is to get my hands in Jon’s jig. He keeps saying “I need to make some changes”, but week after week, nuthin’ happens. Maybe he will sell me the old one???? Please?
    Dale Chaney, Sarasota, Florida 262 – 853 – 1156

    1. Dale,
      if you are happy to ship them to Australia, I would be happy to put them in my flash rig and flash them for you. I assume they are bricked BUT the chip is still flashable. email me if you are interested. michael@thin.com.au

    2. I had a friend 3D print one from the template files on the web. I purchased the pogo pins but never got to using it as i managed to get the DIY OTA process working eventually. Very fidly though and still hit and miss. I have about 12 programmed now with 3 bricks. I think the jig will be a challenge too with the pins so close together.

      1. I have a rig, they work very well. I found setting up the pogo pins a challenge. I have flashed about 30 units with it. I woul dliek to see what happens with a “bricked” one.

      2. Please help to find and buy a jig like this.
        Is there any way to pay and BUY this thing from you or anyone here ?
        I want to have this adaptor and load easily my custom code to sonoff mini.
        I can pay 30€ for sure for such a thing, I want to buy 2 of them, is this possible ?

  21. HI…… I wonder if you could tell me how I can use a touch module TTP223 with SONOFF MINI

Leave a Reply

Your email address will not be published. Required fields are marked *