Introduction: Jig for Programming Sonoff Basic Switches

About: Part software developer, part maker.

If you're like me, you're always on the lookout for ways to enhance your smart home experience. I'm currently checking out the Sonoff Basic smart switches, compact devices that can control your home appliances and devices. But the true fun begins when we tweak these gadgets to work with custom setups like Home Assistant by flashing them with custom firmware.

To do so I've made a DIY programming jig, that will help me to program these switches easily and without messing with wires.

This post is sponsored by PCBWay

PCBWay offers services for custom PCBs, PCBA, 3D printing, CNC machining, Injection molding, and more.

Check out their 2023 Christmas Big Sale to get access to discounts, lucky draws, tons of coupons, 50% OFF on selected items, blind boxes, and much more!

Supplies

Tools and materials used in the video. Purchasing through the links below helps the channel at no extra cost to you!

Step 1: Prepare the PCB

To kick things off, let's prepare a PCB adapter that will make the programming of our Sonoff Basic switches a whole lot easier. This adapter will serve as a bridge between our USB to serial converter and the Sonoff Basic, ensuring the proper alignment and connection for flashing the firmware.

First up, I grab a piece of prototyping PCB – the size doesn't matter, as long as it can fit the connectors. I've chosen one of the smallest ones available. On one edge of the perfboard, I solder a four-pin male header. This will plug directly into the serial breakout pins on the Sonoff switch.

On the opposite side of the perfboard, I attach a female header, which will connect to our USB to serial adapter and I used the adapter for which I make the jig as a holder for the header.

Step 2: Wire Up the PCB

This is where things can get a little crafty. Based on the layout of your USB to serial adapter, you may need to rearrange the wiring on the perfboard. For instance, the ground on the perfboard should align with the ground on your USB to serial adapter, and the same goes for VCC, TX and RX.

Based on your adapter, this process will be different. What you will need to do is to ensure that on the male header pins the wiring is VCC, TX, RX, GND, starting from the pin nearest to you that will go into the square pad on the Sonoff.

Step 3: Test the PCB Connections

Once everything is soldered securely, I like to double-check the connections with a multimeter. This helps prevent any nasty surprises later on.

To do so, I checked each pin in continuity mode, making sure that it is connected to the right pin on the USB to serial adapter and not connected with any other pin.

Step 4: Other Alternatives

Take a closer look at your USB to serial module. You might notice that the pins are "almost there" in the order that corresponds with Sonoff's serial breakout. You can "hack" the module to fit our needs by carefully bending certain pins. For example, if the 5V pin is where you need a 3.3V connection instead, you can bend the 5V pin out of the way to avoid accidentally supplying too much voltage to the Sonoff.

After gently bending the unnecessary pin, I insulate it and the board with some electrical tape to prevent it from making contact with other components. Now you're left with the pins you need - VCC, TX, RX, and GND - exposed and ready to be connected. Remember to match the VCC pin to the 3.3V output on your USB to serial converter, as the Sonoff Basic operates at this voltage level. 

This workaround is quick and dirty, but it gets the job done. Just remember to proceed with caution – we don't want to damage the USB converter or the Sonoff switch. And as always, double-check your connections before plugging anything in; precision is key in avoiding mishaps.

Step 5: Next Steps

Alright, we’ve finished setting up our Sonoff switches and found ways to connect them even without a special adapter. That means you can now use your switches with your favorite home automation setup and make your house smarter your way.

If you liked figuring this out with me and want to get more cool ideas for DIY projects or get better at making your home smart, make sure you hit that subscribe button on my YouTube channel. I've got lots more to share, and I'm always cooking up new things to teach and show you.

Thanks a bunch for hanging out with me, and if you’ve got any questions, or if there’s something you want to see next, just leave a comment below. Your thoughts really help, and I love chatting with you. So, let’s keep making things together, and I'll see you in the next Instructable.

Cheers!