{"id":29632,"date":"2016-11-24T12:17:24","date_gmt":"2016-11-24T12:17:24","guid":{"rendered":"http:\/\/randomnerdtutorials.com\/?p=29632"},"modified":"2019-04-02T10:23:30","modified_gmt":"2019-04-02T10:23:30","slug":"how-to-flash-a-custom-firmware-to-sonoff","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/how-to-flash-a-custom-firmware-to-sonoff\/","title":{"rendered":"How to Flash a Custom Firmware to Sonoff"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">In this post, you\u2019re going to learn how to flash custom firmware to the Sonoff device.\u00a0<\/span><span style=\"font-weight: 400;\">I recommend that you read <a href=\"https:\/\/randomnerdtutorials.com\/sonoff-5-wifi-wireless-smart-switch-introduction\/\">my previous post<\/a> to get familiar with the Sonoff.<\/span><!--more--><\/p>\n<p>If you don&#8217;t have a <a href=\"https:\/\/makeradvisor.com\/tools\/sonoff-wi-fi-smart-switch\/\" target=\"_blank\" rel=\"noopener noreferrer\">Sonoff<\/a> yet, you can get one for approximately\u00a0$5 &#8211; visit <a href=\"https:\/\/makeradvisor.com\/tools\/sonoff-wi-fi-smart-switch\/\" target=\"_blank\" rel=\"noopener noreferrer\">Maker Advisor<\/a> to find the best price.<\/p>\n<h2>First, watch the step by step video tutorial below<\/h2>\n<p style=\"text-align:center\"><iframe width=\"720\" height=\"405\" src=\"https:\/\/www.youtube.com\/embed\/ZztPgbAwOMk?rel=0\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<p>The code mentioned in the video can be found here: &#8220;<a href=\"https:\/\/randomnerdtutorials.com\/reprogram-sonoff-smart-switch-with-web-server\/\" target=\"_blank\" rel=\"noopener noreferrer\">Reprogram Sonoff Smart Switch with Web Server<\/a>&#8220;.<\/p>\n<h2>Safety warning<\/h2>\n<p><span style=\"font-weight: 400;\">Make sure you disconnect your Sonoff from mains voltage. Then, open the box enclosure.<\/span><\/p>\n<p><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter size-full wp-image-29199\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/warning-m-1.png?resize=700%2C200&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"warning-m\" width=\"700\" height=\"200\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/warning-m-1.png?w=700&amp;quality=100&amp;strip=all&amp;ssl=1 700w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/warning-m-1.png?resize=150%2C43&amp;quality=100&amp;strip=all&amp;ssl=1 150w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/warning-m-1.png?resize=300%2C86&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/warning-m-1.png?resize=80%2C23&amp;quality=100&amp;strip=all&amp;ssl=1 80w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/warning-m-1.png?resize=220%2C63&amp;quality=100&amp;strip=all&amp;ssl=1 220w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/warning-m-1.png?resize=250%2C71&amp;quality=100&amp;strip=all&amp;ssl=1 250w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/warning-m-1.png?resize=280%2C80&amp;quality=100&amp;strip=all&amp;ssl=1 280w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/warning-m-1.png?resize=510%2C146&amp;quality=100&amp;strip=all&amp;ssl=1 510w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/p>\n<h2>Sonoff pinout<\/h2>\n<p>The Sonoff is meant to be hacked, and you can see clearly that these connections were left out, so that you can solder some pins and upload a custom firmware.<\/p>\n<p>That\u2019s the pinout.<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" class=\"aligncenter size-full wp-image-29633\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/sonoff_gpio-r.jpg?resize=750%2C424&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"sonoff_gpio-r\" width=\"750\" height=\"424\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/sonoff_gpio-r.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/sonoff_gpio-r.jpg?resize=150%2C85&amp;quality=100&amp;strip=all&amp;ssl=1 150w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/sonoff_gpio-r.jpg?resize=300%2C170&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/sonoff_gpio-r.jpg?resize=80%2C45&amp;quality=100&amp;strip=all&amp;ssl=1 80w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/sonoff_gpio-r.jpg?resize=220%2C124&amp;quality=100&amp;strip=all&amp;ssl=1 220w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/sonoff_gpio-r.jpg?resize=177%2C100&amp;quality=100&amp;strip=all&amp;ssl=1 177w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/sonoff_gpio-r.jpg?resize=265%2C150&amp;quality=100&amp;strip=all&amp;ssl=1 265w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/sonoff_gpio-r.jpg?resize=421%2C238&amp;quality=100&amp;strip=all&amp;ssl=1 421w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/sonoff_gpio-r.jpg?resize=734%2C415&amp;quality=100&amp;strip=all&amp;ssl=1 734w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/p>\n<p>I&#8217;ve soldered 4 header pins, so that I can easily connect and disconnect wire cables to my Sonoff device.<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" class=\"aligncenter size-full wp-image-29636\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/pins-soldered.jpg?resize=622%2C369&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"pins-soldered\" width=\"622\" height=\"369\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/pins-soldered.jpg?w=622&amp;quality=100&amp;strip=all&amp;ssl=1 622w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/pins-soldered.jpg?resize=150%2C89&amp;quality=100&amp;strip=all&amp;ssl=1 150w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/pins-soldered.jpg?resize=300%2C178&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/pins-soldered.jpg?resize=80%2C47&amp;quality=100&amp;strip=all&amp;ssl=1 80w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/pins-soldered.jpg?resize=220%2C131&amp;quality=100&amp;strip=all&amp;ssl=1 220w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/pins-soldered.jpg?resize=169%2C100&amp;quality=100&amp;strip=all&amp;ssl=1 169w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/pins-soldered.jpg?resize=253%2C150&amp;quality=100&amp;strip=all&amp;ssl=1 253w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/pins-soldered.jpg?resize=401%2C238&amp;quality=100&amp;strip=all&amp;ssl=1 401w\" sizes=\"(max-width: 622px) 100vw, 622px\" \/><\/p>\n<h2>Preparing your 3.3V FTDI module<\/h2>\n<p><span style=\"font-weight: 400;\">You need an FTDI module to upload a new firmware to your Sonoff. Use the schematics provided as a reference.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-54097\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/sonoffo-ftdi.jpg?resize=867%2C263&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"867\" height=\"263\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/sonoffo-ftdi.jpg?w=867&amp;quality=100&amp;strip=all&amp;ssl=1 867w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/sonoffo-ftdi.jpg?resize=300%2C91&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/sonoffo-ftdi.jpg?resize=768%2C233&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 867px) 100vw, 867px\" \/><\/span><\/p>\n<p><span style=\"font-weight: 400; color: #ff0000;\"><strong>Warning: <\/strong> uploading a custom firmware is irreversible and you\u2019ll no longer be able to use the app eWeLink.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">I\u2019ve added a toggle switch in the power line, so that I can easily turn the Sonoff on and off to flash a new firmware without having to unplug the FTDI module.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">I used hot glue to glue the ends of the wires together. This prevents you to make wrong connections between the FTDI and the Sonoff in the future.<\/span><\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-29638\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/hot-glue-ftdi.jpg?resize=750%2C369&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"hot-glue-ftdi\" width=\"750\" height=\"369\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/hot-glue-ftdi.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/hot-glue-ftdi.jpg?resize=150%2C74&amp;quality=100&amp;strip=all&amp;ssl=1 150w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/hot-glue-ftdi.jpg?resize=300%2C148&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/hot-glue-ftdi.jpg?resize=80%2C39&amp;quality=100&amp;strip=all&amp;ssl=1 80w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/hot-glue-ftdi.jpg?resize=220%2C108&amp;quality=100&amp;strip=all&amp;ssl=1 220w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/hot-glue-ftdi.jpg?resize=203%2C100&amp;quality=100&amp;strip=all&amp;ssl=1 203w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/hot-glue-ftdi.jpg?resize=280%2C138&amp;quality=100&amp;strip=all&amp;ssl=1 280w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/hot-glue-ftdi.jpg?resize=484%2C238&amp;quality=100&amp;strip=all&amp;ssl=1 484w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/p>\n<h2>Boot your Sonoff in Flashing Mode<\/h2>\n<p>To flash a new firmware to your Sonoff, you have to boot your Sonoff in flashing mode. Follow this 4 step process:<\/p>\n<p>1) Connect your 3.3V FTDI programmer to your computer<\/p>\n<p>2) Hold down the Sonoff button<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-29639\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/hold-down-sonoff-button.jpg?resize=300%2C273&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"hold-down-sonoff-button\" width=\"300\" height=\"273\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/hold-down-sonoff-button.jpg?w=700&amp;quality=100&amp;strip=all&amp;ssl=1 700w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/hold-down-sonoff-button.jpg?resize=150%2C137&amp;quality=100&amp;strip=all&amp;ssl=1 150w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/hold-down-sonoff-button.jpg?resize=300%2C273&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/hold-down-sonoff-button.jpg?resize=80%2C73&amp;quality=100&amp;strip=all&amp;ssl=1 80w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/hold-down-sonoff-button.jpg?resize=220%2C200&amp;quality=100&amp;strip=all&amp;ssl=1 220w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/hold-down-sonoff-button.jpg?resize=110%2C100&amp;quality=100&amp;strip=all&amp;ssl=1 110w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/hold-down-sonoff-button.jpg?resize=165%2C150&amp;quality=100&amp;strip=all&amp;ssl=1 165w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/hold-down-sonoff-button.jpg?resize=262%2C238&amp;quality=100&amp;strip=all&amp;ssl=1 262w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/hold-down-sonoff-button.jpg?resize=456%2C415&amp;quality=100&amp;strip=all&amp;ssl=1 456w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/hold-down-sonoff-button.jpg?resize=535%2C487&amp;quality=100&amp;strip=all&amp;ssl=1 535w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/hold-down-sonoff-button.jpg?resize=654%2C595&amp;quality=100&amp;strip=all&amp;ssl=1 654w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>3) Toggle the switch to apply power to the Sonoff circuit<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-29640\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/apply-power-to-sonoff.png?resize=600%2C287&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"apply-power-to-sonoff\" width=\"600\" height=\"287\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/apply-power-to-sonoff.png?w=600&amp;quality=100&amp;strip=all&amp;ssl=1 600w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/apply-power-to-sonoff.png?resize=150%2C72&amp;quality=100&amp;strip=all&amp;ssl=1 150w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/apply-power-to-sonoff.png?resize=300%2C144&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/apply-power-to-sonoff.png?resize=80%2C38&amp;quality=100&amp;strip=all&amp;ssl=1 80w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/apply-power-to-sonoff.png?resize=220%2C105&amp;quality=100&amp;strip=all&amp;ssl=1 220w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/apply-power-to-sonoff.png?resize=209%2C100&amp;quality=100&amp;strip=all&amp;ssl=1 209w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/apply-power-to-sonoff.png?resize=280%2C134&amp;quality=100&amp;strip=all&amp;ssl=1 280w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/apply-power-to-sonoff.png?resize=498%2C238&amp;quality=100&amp;strip=all&amp;ssl=1 498w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/p>\n<p>4) Then, you can release the Sonoff button<\/p>\n<p>Now, your Sonoff should be in flashing mode and you can upload a new firmware.<\/p>\n<p><strong>Sonoff tutorials list:<\/strong><\/p>\n<ul>\n<li><a href=\"https:\/\/randomnerdtutorials.com\/sonoff-5-wifi-wireless-smart-switch-introduction\/\">Sonoff \u2013 $5 WiFi Wireless Smart Switch Introduction<\/a><\/li>\n<li><a href=\"https:\/\/randomnerdtutorials.com\/reprogram-sonoff-smart-switch-with-web-server\/\">Reprogram Sonoff Smart Switch with Web Server<\/a><\/li>\n<\/ul>\n<h2>Wrapping up<\/h2>\n<p>That\u2019s it for now, I hope you had fun learning about the Sonoff device. Make sure you <a href=\"https:\/\/randomnerdtutorials.com\/download\">subscribe to my blog<\/a>, because I\u2019ll be posting more tutorials about the Sonoff.<\/p>\n<p><strong>Do you have any questions?\u00a0<\/strong><strong>Leave a comment down below!<\/strong><\/p>\n<p>Thanks for reading,<\/p>\n<p>Rui<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this post, you\u2019re going to learn how to flash custom firmware to the Sonoff device.\u00a0I recommend that you read my previous post to get familiar with the Sonoff.<\/p>\n","protected":false},"author":1,"featured_media":29633,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[304,265,269,225,264,275,218],"tags":[],"class_list":["post-29632","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-0-home-automation","category-esp8266-project","category-guide-project","category-home-automation","category-project","category-sonoff","category-web-server"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/11\/sonoff_gpio-r.jpg?fit=750%2C424&quality=100&strip=all&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/29632","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/comments?post=29632"}],"version-history":[{"count":0,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/29632\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/29633"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=29632"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=29632"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=29632"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}