{"id":492,"date":"2018-03-18T22:24:58","date_gmt":"2018-03-19T05:24:58","guid":{"rendered":"http:\/\/diyfuturism.com\/?p=492"},"modified":"2018-03-18T23:07:40","modified_gmt":"2018-03-19T06:07:40","slug":"the-cheapest-wifi-smart-switch-flashing-the-sonoff-basic","status":"publish","type":"post","link":"https:\/\/diyfuturism.com\/index.php\/2018\/03\/18\/the-cheapest-wifi-smart-switch-flashing-the-sonoff-basic\/","title":{"rendered":"The Cheapest WiFi Smart Switch: Flashing the Sonoff Basic"},"content":{"rendered":"<p>Setting up a smart home can be a costly affair, if every device needed an expensive proprietary smart switch you would spend quite a bit of money. With a very tiny amount of soldering and some custom firmware, the\u00a0<a href=\"http:\/\/amzn.to\/2HG7m63\" target=\"_blank\" rel=\"noopener\">Sonoff Basic<\/a> model can be turned into a locally controlled MQTT enabled WiFi smart switch for about $7 each. These tiny little esp8266 based boards can be spliced into a power cord to add WiFi control to anything.<\/p>\n<p>I have about a dozen of these and they work great. Because of how cheap they are, I have started adding them to some ridiculous devices. Today&#8217;s DIY WiFi retrofit: my coffee mug warmer.<\/p>\n<p>I want my mug warmer to come on automatically when I enter my office in the morning, but only if I&#8217;ve made coffee already. But first, I need to flash some new firmware onto my Sonoff.<\/p>\n<p><!--more--><\/p>\n<p><script type=\"text\/javascript\">\namzn_assoc_placement = \"adunit0\";\namzn_assoc_tracking_id = \"diyfuturism-20\";\namzn_assoc_ad_mode = \"manual\";\namzn_assoc_ad_type = \"smart\";\namzn_assoc_marketplace = \"amazon\";\namzn_assoc_region = \"US\";\namzn_assoc_linkid = \"24f277645188a5624a689d9a750bba32\";\namzn_assoc_design = \"in_content\";\namzn_assoc_asins = \"B076Q6PZCV,B06XTNSJ46,B0773DFQJ9,B073F472JL\";\n<\/script><br \/>\n<script src=\"\/\/z-na.amazon-adsystem.com\/widgets\/onejs?MarketPlace=US\"><\/script><\/p>\n<h2>PARTS LIST<\/h2>\n<p>You will need:<\/p>\n<ul>\n<li><a href=\"http:\/\/amzn.to\/2HG7m63\" target=\"_blank\" rel=\"noopener\">Sonoff Basic<\/a>\u00a0(I usually do them in batches, since they are <a href=\"http:\/\/amzn.to\/2FKl6QT\" target=\"_blank\" rel=\"noopener\">cheaper in bulk<\/a>)<\/li>\n<li><a href=\"http:\/\/amzn.to\/2G7sQeQ\" target=\"_blank\" rel=\"noopener\">Male header pins<\/a><\/li>\n<li><a href=\"http:\/\/amzn.to\/2tYhXY3\" target=\"_blank\" rel=\"noopener\">FTDI\/UART to USB serial adapter<\/a><\/li>\n<li><a href=\"http:\/\/amzn.to\/2G1qI8D\" target=\"_blank\" rel=\"noopener\">Dupont cables<\/a><\/li>\n<li><a href=\"http:\/\/amzn.to\/2HLWG5J\" target=\"_blank\" rel=\"noopener\">DHT22 sensor<\/a> (optional)<\/li>\n<li><a href=\"http:\/\/amzn.to\/2IAEBci\" target=\"_blank\" rel=\"noopener\">Mr Coffee Mug Warmer<\/a>\u00a0(or other device)<\/li>\n<\/ul>\n<h2>FLASHING THE SONOFF<\/h2>\n<h3>SOFTWARE<\/h3>\n<p>To communicate with the Sonoff, we hook it up to the\u00a0 serial adapter, and plug that into the computer (you may or may not need a FTDI serial driver, depending on OS). I use the <a href=\"https:\/\/www.arduino.cc\/en\/Main\/Software\" target=\"_blank\" rel=\"noopener\">Arduino IDE<\/a> to flash the new software.<\/p>\n<p>In the Arduino Preferences, add the additional boards URL for the Boards Manager<\/p>\n<div id=\"attachment_509\" style=\"width: 806px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-509\" data-attachment-id=\"509\" data-permalink=\"https:\/\/diyfuturism.com\/index.php\/2018\/03\/18\/the-cheapest-wifi-smart-switch-flashing-the-sonoff-basic\/screen-shot-2018-03-18-at-5-36-19-pm-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-5.36.19-PM-1.png?fit=796%2C606&amp;ssl=1\" data-orig-size=\"796,606\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Arduino IDE &#8211; Additional Boards\" data-image-description=\"\" data-image-caption=\"&lt;p&gt;Arduino IDE &#8211; Additional Boards&lt;\/p&gt;\n\" data-medium-file=\"https:\/\/i0.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-5.36.19-PM-1.png?fit=300%2C228&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-5.36.19-PM-1.png?fit=796%2C606&amp;ssl=1\" loading=\"lazy\" class=\"wp-image-509 size-full\" src=\"https:\/\/i0.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-5.36.19-PM-1.png?resize=796%2C606\" alt=\"Arduino IDE - Additional Boards\" width=\"796\" height=\"606\" srcset=\"https:\/\/i0.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-5.36.19-PM-1.png?w=796&amp;ssl=1 796w, https:\/\/i0.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-5.36.19-PM-1.png?resize=600%2C457&amp;ssl=1 600w, https:\/\/i0.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-5.36.19-PM-1.png?resize=300%2C228&amp;ssl=1 300w, https:\/\/i0.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-5.36.19-PM-1.png?resize=768%2C585&amp;ssl=1 768w\" sizes=\"(max-width: 796px) 100vw, 796px\" data-recalc-dims=\"1\" \/><p id=\"caption-attachment-509\" class=\"wp-caption-text\">Arduino IDE &#8211; Additional Boards<\/p><\/div>\n<pre>http:\/\/arduino.esp8266.com\/stable\/package_esp8266com_index.json<\/pre>\n<p>Open the Boards Manager, and add the esp8266. Some versions of the Sonoff have issues with the newest version of the board, I recommend installing 2.3.0<\/p>\n<div id=\"attachment_499\" style=\"width: 809px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-499\" data-attachment-id=\"499\" data-permalink=\"https:\/\/diyfuturism.com\/index.php\/2018\/03\/18\/the-cheapest-wifi-smart-switch-flashing-the-sonoff-basic\/screen-shot-2018-03-18-at-7-11-28-pm\/\" data-orig-file=\"https:\/\/i0.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-7.11.28-PM.png?fit=799%2C450&amp;ssl=1\" data-orig-size=\"799,450\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Board Manager\" data-image-description=\"&lt;p&gt;Board Manager&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Board Manager&lt;\/p&gt;\n\" data-medium-file=\"https:\/\/i0.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-7.11.28-PM.png?fit=300%2C169&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-7.11.28-PM.png?fit=799%2C450&amp;ssl=1\" loading=\"lazy\" class=\"wp-image-499 size-full\" src=\"https:\/\/i0.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-7.11.28-PM.png?resize=799%2C450\" alt=\"Board Manager\" width=\"799\" height=\"450\" srcset=\"https:\/\/i0.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-7.11.28-PM.png?w=799&amp;ssl=1 799w, https:\/\/i0.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-7.11.28-PM.png?resize=600%2C338&amp;ssl=1 600w, https:\/\/i0.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-7.11.28-PM.png?resize=300%2C169&amp;ssl=1 300w, https:\/\/i0.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-7.11.28-PM.png?resize=768%2C433&amp;ssl=1 768w\" sizes=\"(max-width: 799px) 100vw, 799px\" data-recalc-dims=\"1\" \/><p id=\"caption-attachment-499\" class=\"wp-caption-text\">Board Manager<\/p><\/div>\n<h3>HARDWARE<\/h3>\n<p>Here&#8217;s a diagram of what&#8217;s on the board:<\/p>\n<div id=\"attachment_501\" style=\"width: 596px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-501\" data-attachment-id=\"501\" data-permalink=\"https:\/\/diyfuturism.com\/index.php\/2018\/03\/18\/the-cheapest-wifi-smart-switch-flashing-the-sonoff-basic\/screen-shot-2018-03-18-at-6-50-50-pm\/\" data-orig-file=\"https:\/\/i1.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-6.50.50-PM.png?fit=586%2C380&amp;ssl=1\" data-orig-size=\"586,380\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Sonoff Basic esp8266 board\" data-image-description=\"&lt;p&gt;Sonoff Basic esp8266 board&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Sonoff Basic esp8266 board&lt;\/p&gt;\n\" data-medium-file=\"https:\/\/i1.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-6.50.50-PM.png?fit=300%2C195&amp;ssl=1\" data-large-file=\"https:\/\/i1.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-6.50.50-PM.png?fit=586%2C380&amp;ssl=1\" loading=\"lazy\" class=\"size-full wp-image-501\" src=\"https:\/\/i1.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-6.50.50-PM.png?resize=586%2C380\" alt=\"Sonoff Basic esp8266 board\" width=\"586\" height=\"380\" srcset=\"https:\/\/i1.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-6.50.50-PM.png?w=586&amp;ssl=1 586w, https:\/\/i1.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-6.50.50-PM.png?resize=300%2C195&amp;ssl=1 300w\" sizes=\"(max-width: 586px) 100vw, 586px\" data-recalc-dims=\"1\" \/><p id=\"caption-attachment-501\" class=\"wp-caption-text\">Sonoff Basic esp8266 board<\/p><\/div>\n<p>Solder 4 or 5 header pins to the Sonoff Basic to the open through holes:<\/p>\n<div id=\"attachment_495\" style=\"width: 810px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-495\" data-attachment-id=\"495\" data-permalink=\"https:\/\/diyfuturism.com\/index.php\/2018\/03\/18\/the-cheapest-wifi-smart-switch-flashing-the-sonoff-basic\/687474703a2f2f74696e6b65726d616e2e6361742f77702d636f6e74656e742f75706c6f6164732f323031362f30362f70696e6f75745f66726f6e74782e6a7067\/\" data-orig-file=\"https:\/\/i1.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/687474703a2f2f74696e6b65726d616e2e6361742f77702d636f6e74656e742f75706c6f6164732f323031362f30362f70696e6f75745f66726f6e74782e6a7067.jpg?fit=800%2C456&amp;ssl=1\" data-orig-size=\"800,456\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Sonoff Basic pinout\" data-image-description=\"&lt;p&gt;Sonoff Basic pinout&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Sonoff Basic pinout&lt;\/p&gt;\n\" data-medium-file=\"https:\/\/i1.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/687474703a2f2f74696e6b65726d616e2e6361742f77702d636f6e74656e742f75706c6f6164732f323031362f30362f70696e6f75745f66726f6e74782e6a7067.jpg?fit=300%2C171&amp;ssl=1\" data-large-file=\"https:\/\/i1.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/687474703a2f2f74696e6b65726d616e2e6361742f77702d636f6e74656e742f75706c6f6164732f323031362f30362f70696e6f75745f66726f6e74782e6a7067.jpg?fit=800%2C456&amp;ssl=1\" loading=\"lazy\" class=\"size-full wp-image-495\" src=\"https:\/\/i1.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/687474703a2f2f74696e6b65726d616e2e6361742f77702d636f6e74656e742f75706c6f6164732f323031362f30362f70696e6f75745f66726f6e74782e6a7067.jpg?resize=800%2C456\" alt=\"Sonoff Basic pinout\" width=\"800\" height=\"456\" srcset=\"https:\/\/i1.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/687474703a2f2f74696e6b65726d616e2e6361742f77702d636f6e74656e742f75706c6f6164732f323031362f30362f70696e6f75745f66726f6e74782e6a7067.jpg?w=800&amp;ssl=1 800w, https:\/\/i1.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/687474703a2f2f74696e6b65726d616e2e6361742f77702d636f6e74656e742f75706c6f6164732f323031362f30362f70696e6f75745f66726f6e74782e6a7067.jpg?resize=600%2C342&amp;ssl=1 600w, https:\/\/i1.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/687474703a2f2f74696e6b65726d616e2e6361742f77702d636f6e74656e742f75706c6f6164732f323031362f30362f70696e6f75745f66726f6e74782e6a7067.jpg?resize=300%2C171&amp;ssl=1 300w, https:\/\/i1.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/687474703a2f2f74696e6b65726d616e2e6361742f77702d636f6e74656e742f75706c6f6164732f323031362f30362f70696e6f75745f66726f6e74782e6a7067.jpg?resize=768%2C438&amp;ssl=1 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" data-recalc-dims=\"1\" \/><p id=\"caption-attachment-495\" class=\"wp-caption-text\">Sonoff Basic pinout<\/p><\/div>\n<p>We needs pins on VCC, RX, TX, and GND (and the fifth GPIO14 if you want to add a DHT sensor). The pin closest to the button is the power (VCC).<\/p>\n<p><strong>Programmer &#8211; Sonoff\u00a0<\/strong><\/p>\n<ul>\n<li>3V VCC &#8211; 3V VCC<\/li>\n<li>TX &#8211; RX<\/li>\n<li>RX &#8211; TX<\/li>\n<li>GND &#8211; GND<\/li>\n<li>GPIO14 &#8211; Data pin on the DHT22<\/li>\n<\/ul>\n<p>Once you have the pins in place, connect a Dupont cable and attach it to the appropriate pins on the FTDI adapter. On my FTDI adapter, you can choose 3V or 5V with a jumper. Make sure yours is set to 3V for the esp8266.<\/p>\n<p><span style=\"color: #ff0000;\"><strong>!!! WARNING !!!<\/strong><\/span> Never connect the USB adapter and AC power at the same time, it&#8217;s dangerous!<\/p>\n<p><script type=\"text\/javascript\">\namzn_assoc_placement = \"adunit0\";\namzn_assoc_tracking_id = \"diyfuturism-20\";\namzn_assoc_ad_mode = \"manual\";\namzn_assoc_ad_type = \"smart\";\namzn_assoc_marketplace = \"amazon\";\namzn_assoc_region = \"US\";\namzn_assoc_linkid = \"21f902bd48e9dfdd6388735230c6baea\";\namzn_assoc_asins = \"B01N3P763C,B073F472JL,B074N22WFT\";\namzn_assoc_design = \"in_content\";\n<\/script><br \/>\n<script src=\"\/\/z-na.amazon-adsystem.com\/widgets\/onejs?MarketPlace=US\"><\/script><\/p>\n<h3>FLASHING THE FIRMWARE<\/h3>\n<p>There are a lot of options for flashing the Sonoff. I am going to use the simple\u00a0<a href=\"https:\/\/github.com\/KmanOz\/KmanSonoff\" target=\"_blank\" rel=\"noopener\">KmanSonoff<\/a>. If you would like something more full featured, check out <a href=\"https:\/\/github.com\/arendst\/Sonoff-Tasmota\" target=\"_blank\" rel=\"noopener\">Sonoff-Tasmota<\/a>. KmanSonoff is very lightweight and foolproof. It controls the switch, and a DHT22 humidity\/temp sensor if you want. That&#8217;s it.<\/p>\n<p>Download the KmanSonoff repository and the <a href=\"https:\/\/github.com\/Imroy\/pubsubclient\" target=\"_blank\" rel=\"noopener\">non-default MQTT library<\/a> it uses, unzip both. Place the pubsubclient folder in your Arduino\/libraries folder. Now open the KmanSonoff\/arduino\/KmanSonoff_v1.00sc INO file.<\/p>\n<p>In config_sc.h, add your settings, which is mostly MQTT and the topic:<\/p>\n<pre>#define MQTT_SERVER \"192.168.0.100\" \/\/ Your mqtt server ip address\r\n#define MQTT_PORT 1883 \/\/ Your mqtt port\r\n#define MQTT_TOPIC \"home\/office\/coffee_warmer\" \/\/ Base mqtt topic\r\n#define MQTT_USER \"mqtt_user\" \/\/ mqtt username\r\n#define MQTT_PASS \"mqtt_pass\" \/\/ mqtt password\r\n\r\n#define WIFI_SSID \"wifissid\" \/\/ Your WiFi ssid\r\n#define WIFI_PASS \"wifipass\" \/\/ Your WiFi password<\/pre>\n<p>You can also enable the DHT22 if you&#8217;re using it.<\/p>\n<p>Now attach the FTDI programmer to the computer <strong>while holding down the button on the Sonoff.<\/strong> Holding down the button puts it in flashing mode. Now, in the Arduino IDE, select the appropriate port and the &#8220;Generic esp8266&#8221; option for the board. Set Flash Size to &#8220;1M (64K SPIFFS)&#8221; and Flash Mode to &#8220;DOUT&#8221; (note: some boards use DIO, use that if this doesn&#8217;t work for you).<\/p>\n<div id=\"attachment_500\" style=\"width: 342px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-500\" data-attachment-id=\"500\" data-permalink=\"https:\/\/diyfuturism.com\/index.php\/2018\/03\/18\/the-cheapest-wifi-smart-switch-flashing-the-sonoff-basic\/screen-shot-2018-03-18-at-8-20-35-pm\/\" data-orig-file=\"https:\/\/i2.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-8.20.35-PM.png?fit=332%2C425&amp;ssl=1\" data-orig-size=\"332,425\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Arduino Flash Settings\" data-image-description=\"&lt;p&gt;Arduino Flash Settings&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Arduino Flash Settings&lt;\/p&gt;\n\" data-medium-file=\"https:\/\/i2.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-8.20.35-PM.png?fit=234%2C300&amp;ssl=1\" data-large-file=\"https:\/\/i2.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-8.20.35-PM.png?fit=332%2C425&amp;ssl=1\" loading=\"lazy\" class=\"size-full wp-image-500\" src=\"https:\/\/i2.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-8.20.35-PM.png?resize=332%2C425\" alt=\"Arduino Flash Settings\" width=\"332\" height=\"425\" srcset=\"https:\/\/i2.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-8.20.35-PM.png?w=332&amp;ssl=1 332w, https:\/\/i2.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-8.20.35-PM.png?resize=234%2C300&amp;ssl=1 234w\" sizes=\"(max-width: 332px) 100vw, 332px\" data-recalc-dims=\"1\" \/><p id=\"caption-attachment-500\" class=\"wp-caption-text\">Arduino Flash Settings<\/p><\/div>\n<p>Go to Sketch-&gt; Upload. If all went well the LED will flash 4 times when it completes.<\/p>\n<div id=\"attachment_497\" style=\"width: 653px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-497\" data-attachment-id=\"497\" data-permalink=\"https:\/\/diyfuturism.com\/index.php\/2018\/03\/18\/the-cheapest-wifi-smart-switch-flashing-the-sonoff-basic\/screen-shot-2018-03-18-at-6-36-31-pm\/\" data-orig-file=\"https:\/\/i0.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-6.36.31-PM.png?fit=643%2C207&amp;ssl=1\" data-orig-size=\"643,207\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Flashing success\" data-image-description=\"&lt;p&gt;Flashing success&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Flashing success&lt;\/p&gt;\n\" data-medium-file=\"https:\/\/i0.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-6.36.31-PM.png?fit=300%2C97&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-6.36.31-PM.png?fit=643%2C207&amp;ssl=1\" loading=\"lazy\" class=\"size-full wp-image-497\" src=\"https:\/\/i0.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-6.36.31-PM.png?resize=643%2C207\" alt=\"Flashing success\" width=\"643\" height=\"207\" srcset=\"https:\/\/i0.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-6.36.31-PM.png?w=643&amp;ssl=1 643w, https:\/\/i0.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-6.36.31-PM.png?resize=600%2C193&amp;ssl=1 600w, https:\/\/i0.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-6.36.31-PM.png?resize=300%2C97&amp;ssl=1 300w\" sizes=\"(max-width: 643px) 100vw, 643px\" data-recalc-dims=\"1\" \/><p id=\"caption-attachment-497\" class=\"wp-caption-text\">Flashing success<\/p><\/div>\n<p>If you get an &#8220;esp comm&#8221; error you either didn&#8217;t wire it correctly (check the RX \/ TX) or didn&#8217;t hold down the button while plugging in the programmer.<\/p>\n<p>If you didn&#8217;t get 4 flashes at the end of the upload, or nothing is happening when you plug it in, check your board settings.<\/p>\n<p>Make sure you put the board back into it&#8217;s case in the correct orientation (the Sonoff verison number is in the bottom right).<\/p>\n<p>When you plug it into AC power, it will flash 4 times when it connects to the wifi.<\/p>\n<h2>CONNECTING TO HOME ASSISTANT<\/h2>\n<p>To integrate with Home Assistant, I just add a MQTT switch to my switches.yaml file:<\/p>\n<pre>- platform: mqtt\r\n  name: \"Coffee Warmer\"\r\n  state_topic: \"home\/office\/coffee_warmer\/stat\"\r\n  command_topic: \"home\/office\/coffee_warmer\"\r\n  qos: 0\r\n  payload_on: \"on\"\r\n  payload_off: \"off\"\r\n  retain: true<\/pre>\n<h2><img data-attachment-id=\"503\" data-permalink=\"https:\/\/diyfuturism.com\/index.php\/2018\/03\/18\/the-cheapest-wifi-smart-switch-flashing-the-sonoff-basic\/screen-shot-2018-03-18-at-9-40-07-pm\/\" data-orig-file=\"https:\/\/i1.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-9.40.07-PM.png?fit=461%2C290&amp;ssl=1\" data-orig-size=\"461,290\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i1.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-9.40.07-PM.png?fit=300%2C189&amp;ssl=1\" data-large-file=\"https:\/\/i1.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-9.40.07-PM.png?fit=461%2C290&amp;ssl=1\" loading=\"lazy\" class=\"aligncenter size-full wp-image-503\" src=\"https:\/\/i1.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-9.40.07-PM.png?resize=461%2C290\" alt=\"\" width=\"461\" height=\"290\" srcset=\"https:\/\/i1.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-9.40.07-PM.png?w=461&amp;ssl=1 461w, https:\/\/i1.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-9.40.07-PM.png?resize=300%2C189&amp;ssl=1 300w\" sizes=\"(max-width: 461px) 100vw, 461px\" data-recalc-dims=\"1\" \/><\/h2>\n<h2>AUTOMATING!<\/h2>\n<p>My desired functionality is this: I want the mug warmer to turn on when I sit down at my office desk, but only if I&#8217;ve made coffee this morning. I have a Wemo enabled coffee maker that reports it&#8217;s state, a motion detector at my office desk, and the now smart mug warmer.<\/p>\n<p>Using Home Assistant and Node-Red, let&#8217;s make this happen.<\/p>\n<p>I&#8217;ve made a <a href=\"https:\/\/home-assistant.io\/components\/sensor.history_stats\/\" target=\"_blank\" rel=\"noopener\">history stats sensor<\/a> in Home Assistant to count how many times I&#8217;ve made coffee this morning (between 5am &#8211; 12pm). I drink a lot of coffee so this is kind of in the realm of things-I-don&#8217;t-really-want-to-know, but thanks technology.<\/p>\n<pre>- platform: history_stats\r\n  name: Coffee This Morning\r\n  entity_id: sensor.coffeemaker\r\n  state: 'Brewing'\r\n  type: count\r\n  start: '{{ now().replace(hour=5).replace(minute=0).replace(second=0) }}'\r\n  duration:\r\n    hours: 7<\/pre>\n<p>Now I&#8217;m going to make a flow in Node-Red. When motion is detected in my office, check to see if it&#8217;s morning, then check to see if I made coffee. If so, turn on the mug warmer.<\/p>\n<div id=\"attachment_502\" style=\"width: 1012px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-502\" data-attachment-id=\"502\" data-permalink=\"https:\/\/diyfuturism.com\/index.php\/2018\/03\/18\/the-cheapest-wifi-smart-switch-flashing-the-sonoff-basic\/screen-shot-2018-03-18-at-9-27-04-pm\/\" data-orig-file=\"https:\/\/i2.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-9.27.04-PM.png?fit=1002%2C222&amp;ssl=1\" data-orig-size=\"1002,222\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Turn on Mug Warmer Flow\" data-image-description=\"&lt;p&gt;Turn on Mug Warmer Flow&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Turn on Mug Warmer Flow&lt;\/p&gt;\n\" data-medium-file=\"https:\/\/i2.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-9.27.04-PM.png?fit=300%2C66&amp;ssl=1\" data-large-file=\"https:\/\/i2.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-9.27.04-PM.png?fit=854%2C189&amp;ssl=1\" loading=\"lazy\" class=\"size-full wp-image-502\" src=\"https:\/\/i2.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-9.27.04-PM.png?resize=854%2C189\" alt=\"Turn on Mug Warmer Flow\" width=\"854\" height=\"189\" srcset=\"https:\/\/i2.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-9.27.04-PM.png?w=1002&amp;ssl=1 1002w, https:\/\/i2.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-9.27.04-PM.png?resize=600%2C133&amp;ssl=1 600w, https:\/\/i2.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-9.27.04-PM.png?resize=300%2C66&amp;ssl=1 300w, https:\/\/i2.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-9.27.04-PM.png?resize=768%2C170&amp;ssl=1 768w\" sizes=\"(max-width: 854px) 100vw, 854px\" data-recalc-dims=\"1\" \/><p id=\"caption-attachment-502\" class=\"wp-caption-text\">Turn on Mug Warmer Flow<\/p><\/div>\n<p>JSON:<\/p>\n<pre>[{\"id\":\"17607704.59aa59\",\"type\":\"server-state-changed\",\"z\":\"45760804.d260f8\",\"name\":\"Office Motion\",\"server\":\"8ac3cd7f.58d3e\",\"entityidfilter\":\"binary_sensor.office_motion\",\"entityidfiltertype\":\"exact\",\"haltifstate\":\"\",\"x\":130,\"y\":1800,\"wires\":[[\"8b5dd6af.2227a8\"]]},{\"id\":\"8b5dd6af.2227a8\",\"type\":\"switch\",\"z\":\"45760804.d260f8\",\"name\":\"\",\"property\":\"payload\",\"propertyType\":\"msg\",\"rules\":[{\"t\":\"eq\",\"v\":\"on\",\"vt\":\"str\"},{\"t\":\"eq\",\"v\":\"off\",\"vt\":\"str\"}],\"checkall\":\"true\",\"outputs\":2,\"x\":130,\"y\":1840,\"wires\":[[\"271d3505.48f2aa\"],[]]},{\"id\":\"34470c82.d2a044\",\"type\":\"comment\",\"z\":\"45760804.d260f8\",\"name\":\"Mug Warmer On if I made AM Coffee\",\"info\":\"\",\"x\":210,\"y\":1740,\"wires\":[]},{\"id\":\"271d3505.48f2aa\",\"type\":\"time-range-switch\",\"z\":\"45760804.d260f8\",\"name\":\"\",\"lat\":\"37.79952\",\"lon\":\"-122.26872\",\"startTime\":\"05:00\",\"endTime\":\"12:00\",\"startOffset\":0,\"endOffset\":0,\"x\":330,\"y\":1820,\"wires\":[[\"1a21b3e9.857a4c\"],[]]},{\"id\":\"1a21b3e9.857a4c\",\"type\":\"api-current-state\",\"z\":\"45760804.d260f8\",\"name\":\"Coffee This Morning?\",\"server\":\"8ac3cd7f.58d3e\",\"halt_if\":\"\",\"entity_id\":\"sensor.coffee_this_morning\",\"x\":540,\"y\":1820,\"wires\":[[\"b3402460.2ad4d8\"]]},{\"id\":\"b3402460.2ad4d8\",\"type\":\"switch\",\"z\":\"45760804.d260f8\",\"name\":\"\",\"property\":\"payload\",\"propertyType\":\"msg\",\"rules\":[{\"t\":\"gt\",\"v\":\"0\",\"vt\":\"num\"}],\"checkall\":\"true\",\"repair\":false,\"outputs\":1,\"x\":710,\"y\":1820,\"wires\":[[\"688eba8a.db0ab4\"]]},{\"id\":\"688eba8a.db0ab4\",\"type\":\"api-call-service\",\"z\":\"45760804.d260f8\",\"name\":\"Turn on Mug Warmer\",\"server\":\"8ac3cd7f.58d3e\",\"service_domain\":\"switch\",\"service\":\"turn_on\",\"data\":\"{\\\"entity_id\\\":\\\"switch.coffee_warmer\\\"}\",\"mergecontext\":\"\",\"x\":910,\"y\":1820,\"wires\":[[]]},{\"id\":\"8ac3cd7f.58d3e\",\"type\":\"server\",\"z\":\"\",\"name\":\"Home Assistant\",\"url\":\"HASSURL\",\"pass\":\"PASS\"}]<\/pre>\n<p>I already have a flow to turn off my office when I leave, so that will also turn the mug warmer off. See my post on <a href=\"https:\/\/diyfuturism.com\/index.php\/2017\/12\/14\/basic-node-red-flows-for-automating-lighting-with-home-assistant\/\">basic lighting automations with Node-Red<\/a> if you&#8217;re interested in that flow. Since this appliance involves a heating element, I&#8217;m going to set up a secondary auto-off if it&#8217;s left on for more than 3 hours.<\/p>\n<div id=\"attachment_515\" style=\"width: 855px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-515\" data-attachment-id=\"515\" data-permalink=\"https:\/\/diyfuturism.com\/index.php\/2018\/03\/18\/the-cheapest-wifi-smart-switch-flashing-the-sonoff-basic\/screen-shot-2018-03-18-at-11-06-27-pm\/\" data-orig-file=\"https:\/\/i1.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-11.06.27-PM.png?fit=845%2C183&amp;ssl=1\" data-orig-size=\"845,183\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Auto-Off After 3 Hours\" data-image-description=\"&lt;p&gt;Auto-Off After 3 Hours&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Auto-Off After 3 Hours&lt;\/p&gt;\n\" data-medium-file=\"https:\/\/i1.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-11.06.27-PM.png?fit=300%2C65&amp;ssl=1\" data-large-file=\"https:\/\/i1.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-11.06.27-PM.png?fit=845%2C183&amp;ssl=1\" loading=\"lazy\" class=\"size-full wp-image-515\" src=\"https:\/\/i1.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-11.06.27-PM.png?resize=845%2C183\" alt=\"Auto-Off After 3 Hours\" width=\"845\" height=\"183\" srcset=\"https:\/\/i1.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-11.06.27-PM.png?w=845&amp;ssl=1 845w, https:\/\/i1.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-11.06.27-PM.png?resize=600%2C130&amp;ssl=1 600w, https:\/\/i1.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-11.06.27-PM.png?resize=300%2C65&amp;ssl=1 300w, https:\/\/i1.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/Screen-Shot-2018-03-18-at-11.06.27-PM.png?resize=768%2C166&amp;ssl=1 768w\" sizes=\"(max-width: 845px) 100vw, 845px\" data-recalc-dims=\"1\" \/><p id=\"caption-attachment-515\" class=\"wp-caption-text\">Auto-Off After 3 Hours<\/p><\/div>\n<p>JSON:<\/p>\n<pre>[{\"id\":\"c266179c.461328\",\"type\":\"server-state-changed\",\"z\":\"45760804.d260f8\",\"name\":\"Mug Warmer\",\"server\":\"8ac3cd7f.58d3e\",\"entityidfilter\":\"switch.coffee_warmer\",\"entityidfiltertype\":\"exact\",\"haltifstate\":\"\",\"x\":130,\"y\":1940,\"wires\":[[\"55b9c7d3.92e3a8\"]]},{\"id\":\"ec46f198.b5833\",\"type\":\"comment\",\"z\":\"45760804.d260f8\",\"name\":\"Turn Off After 3 Hours\",\"info\":\"\",\"x\":160,\"y\":1900,\"wires\":[]},{\"id\":\"55b9c7d3.92e3a8\",\"type\":\"switch\",\"z\":\"45760804.d260f8\",\"name\":\"\",\"property\":\"payload\",\"propertyType\":\"msg\",\"rules\":[{\"t\":\"eq\",\"v\":\"on\",\"vt\":\"str\"},{\"t\":\"eq\",\"v\":\"off\",\"vt\":\"str\"}],\"checkall\":\"true\",\"repair\":false,\"outputs\":2,\"x\":290,\"y\":1940,\"wires\":[[\"ca2c5756.362d18\"],[\"77659ee6.cecd5\"]]},{\"id\":\"ca2c5756.362d18\",\"type\":\"stoptimer\",\"z\":\"45760804.d260f8\",\"duration\":\"3\",\"units\":\"Hour\",\"payloadtype\":\"num\",\"payloadval\":\"0\",\"name\":\"\",\"x\":490,\"y\":1940,\"wires\":[[\"329c9d6b.6aece2\"],[]]},{\"id\":\"77659ee6.cecd5\",\"type\":\"change\",\"z\":\"45760804.d260f8\",\"name\":\"\",\"rules\":[{\"t\":\"set\",\"p\":\"payload\",\"pt\":\"msg\",\"to\":\"STOP\",\"tot\":\"str\"}],\"action\":\"\",\"property\":\"\",\"from\":\"\",\"to\":\"\",\"reg\":false,\"x\":260,\"y\":2000,\"wires\":[[\"ca2c5756.362d18\"]]},{\"id\":\"329c9d6b.6aece2\",\"type\":\"api-call-service\",\"z\":\"45760804.d260f8\",\"name\":\"Turn off Mug Warmer\",\"server\":\"8ac3cd7f.58d3e\",\"service_domain\":\"switch\",\"service\":\"turn_off\",\"data\":\"{\\\"entity_id\\\":\\\"switch.coffee_warmer\\\"}\",\"mergecontext\":\"\",\"x\":740,\"y\":1940,\"wires\":[[]]},{\"id\":\"8ac3cd7f.58d3e\",\"type\":\"server\",\"z\":\"\",\"name\":\"Home Assistant\",\"url\":\"HASSURL\",\"pass\":\"PASS\"}]<\/pre>\n<p>I now have the world&#8217;s smartest coffee warmer. Truly solving the big problems here.<\/p>\n<div id=\"amzn-assoc-ad-e563a5c1-71ca-40bb-9b1a-d1fe42907986\"><\/div>\n<p><script async src=\"\/\/z-na.amazon-adsystem.com\/widgets\/onejs?MarketPlace=US&#038;adInstanceId=e563a5c1-71ca-40bb-9b1a-d1fe42907986\"><\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"wpm_excerpt clearfix\"><p>Setting up a smart home can be a costly affair, if every device needed an expensive proprietary smart switch you would spend quite a bit of &hellip;<\/p>\n<\/div>","protected":false},"author":1,"featured_media":507,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"World's Smartest Coffee Mug Warmer: Flashing the Sonoff for use with @Home_Assistant & @NodeRed #smarthome #homeautomation #hass #esp8266","jetpack_is_tweetstorm":false},"categories":[8,4,6,7,11,3],"tags":[147,109,110,28,96,36,31,143,42,146,25,145,144,142],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v16.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>The Cheapest WiFi Smart Switch: Flashing the Sonoff Basic - DIY Futurism<\/title>\n<meta name=\"description\" content=\"How to flash a Sonoff smart switch device with open source firmware. Enables MQTT and temperature\/humidity reporting on one of the cheapest WiFi switches you can buy.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/diyfuturism.com\/index.php\/2018\/03\/18\/the-cheapest-wifi-smart-switch-flashing-the-sonoff-basic\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"The Cheapest WiFi Smart Switch: Flashing the Sonoff Basic - DIY Futurism\" \/>\n<meta property=\"og:description\" content=\"How to flash a Sonoff smart switch device with open source firmware. Enables MQTT and temperature\/humidity reporting on one of the cheapest WiFi switches you can buy.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/diyfuturism.com\/index.php\/2018\/03\/18\/the-cheapest-wifi-smart-switch-flashing-the-sonoff-basic\/\" \/>\n<meta property=\"og:site_name\" content=\"DIY Futurism\" \/>\n<meta property=\"article:published_time\" content=\"2018-03-19T05:24:58+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-03-19T06:07:40+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/i0.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/images.duckduckgo-1.jpg?fit=1000%2C547&#038;ssl=1\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"547\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@diyfuturism\" \/>\n<meta name=\"twitter:site\" content=\"@diyfuturism\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"brad\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/diyfuturism.com\/#website\",\"url\":\"https:\/\/diyfuturism.com\/\",\"name\":\"DIY Futurism\",\"description\":\"Adventures in Open Source Smart Home Projects\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/diyfuturism.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/diyfuturism.com\/index.php\/2018\/03\/18\/the-cheapest-wifi-smart-switch-flashing-the-sonoff-basic\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/i0.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/images.duckduckgo-1.jpg?fit=1000%2C547&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/images.duckduckgo-1.jpg?fit=1000%2C547&ssl=1\",\"width\":1000,\"height\":547},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/diyfuturism.com\/index.php\/2018\/03\/18\/the-cheapest-wifi-smart-switch-flashing-the-sonoff-basic\/#webpage\",\"url\":\"https:\/\/diyfuturism.com\/index.php\/2018\/03\/18\/the-cheapest-wifi-smart-switch-flashing-the-sonoff-basic\/\",\"name\":\"The Cheapest WiFi Smart Switch: Flashing the Sonoff Basic - DIY Futurism\",\"isPartOf\":{\"@id\":\"https:\/\/diyfuturism.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/diyfuturism.com\/index.php\/2018\/03\/18\/the-cheapest-wifi-smart-switch-flashing-the-sonoff-basic\/#primaryimage\"},\"datePublished\":\"2018-03-19T05:24:58+00:00\",\"dateModified\":\"2018-03-19T06:07:40+00:00\",\"author\":{\"@id\":\"https:\/\/diyfuturism.com\/#\/schema\/person\/b93619fac07567640bd87cc613a55b7c\"},\"description\":\"How to flash a Sonoff smart switch device with open source firmware. Enables MQTT and temperature\/humidity reporting on one of the cheapest WiFi switches you can buy.\",\"breadcrumb\":{\"@id\":\"https:\/\/diyfuturism.com\/index.php\/2018\/03\/18\/the-cheapest-wifi-smart-switch-flashing-the-sonoff-basic\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/diyfuturism.com\/index.php\/2018\/03\/18\/the-cheapest-wifi-smart-switch-flashing-the-sonoff-basic\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/diyfuturism.com\/index.php\/2018\/03\/18\/the-cheapest-wifi-smart-switch-flashing-the-sonoff-basic\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/diyfuturism.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"The Cheapest WiFi Smart Switch: Flashing the Sonoff Basic\"}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/diyfuturism.com\/#\/schema\/person\/b93619fac07567640bd87cc613a55b7c\",\"name\":\"brad\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/diyfuturism.com\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/7e2d60eb1f322b4ad6040a746946a361?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/7e2d60eb1f322b4ad6040a746946a361?s=96&d=mm&r=g\",\"caption\":\"brad\"},\"description\":\"I'm a professional artist who likes to tinker with building things in my spare time.\",\"sameAs\":[\"https:\/\/twitter.com\/@diyfuturism\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"The Cheapest WiFi Smart Switch: Flashing the Sonoff Basic - DIY Futurism","description":"How to flash a Sonoff smart switch device with open source firmware. Enables MQTT and temperature\/humidity reporting on one of the cheapest WiFi switches you can buy.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/diyfuturism.com\/index.php\/2018\/03\/18\/the-cheapest-wifi-smart-switch-flashing-the-sonoff-basic\/","og_locale":"en_US","og_type":"article","og_title":"The Cheapest WiFi Smart Switch: Flashing the Sonoff Basic - DIY Futurism","og_description":"How to flash a Sonoff smart switch device with open source firmware. Enables MQTT and temperature\/humidity reporting on one of the cheapest WiFi switches you can buy.","og_url":"https:\/\/diyfuturism.com\/index.php\/2018\/03\/18\/the-cheapest-wifi-smart-switch-flashing-the-sonoff-basic\/","og_site_name":"DIY Futurism","article_published_time":"2018-03-19T05:24:58+00:00","article_modified_time":"2018-03-19T06:07:40+00:00","og_image":[{"width":1000,"height":547,"url":"https:\/\/i0.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/images.duckduckgo-1.jpg?fit=1000%2C547&ssl=1","path":"\/var\/www\/html\/wp-content\/uploads\/2018\/03\/images.duckduckgo-1.jpg","size":"full","id":507,"alt":"","pixels":547000,"type":"image\/jpeg"}],"twitter_card":"summary_large_image","twitter_creator":"@diyfuturism","twitter_site":"@diyfuturism","twitter_misc":{"Written by":"brad","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"https:\/\/diyfuturism.com\/#website","url":"https:\/\/diyfuturism.com\/","name":"DIY Futurism","description":"Adventures in Open Source Smart Home Projects","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/diyfuturism.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https:\/\/diyfuturism.com\/index.php\/2018\/03\/18\/the-cheapest-wifi-smart-switch-flashing-the-sonoff-basic\/#primaryimage","inLanguage":"en-US","url":"https:\/\/i0.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/images.duckduckgo-1.jpg?fit=1000%2C547&ssl=1","contentUrl":"https:\/\/i0.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/images.duckduckgo-1.jpg?fit=1000%2C547&ssl=1","width":1000,"height":547},{"@type":"WebPage","@id":"https:\/\/diyfuturism.com\/index.php\/2018\/03\/18\/the-cheapest-wifi-smart-switch-flashing-the-sonoff-basic\/#webpage","url":"https:\/\/diyfuturism.com\/index.php\/2018\/03\/18\/the-cheapest-wifi-smart-switch-flashing-the-sonoff-basic\/","name":"The Cheapest WiFi Smart Switch: Flashing the Sonoff Basic - DIY Futurism","isPartOf":{"@id":"https:\/\/diyfuturism.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/diyfuturism.com\/index.php\/2018\/03\/18\/the-cheapest-wifi-smart-switch-flashing-the-sonoff-basic\/#primaryimage"},"datePublished":"2018-03-19T05:24:58+00:00","dateModified":"2018-03-19T06:07:40+00:00","author":{"@id":"https:\/\/diyfuturism.com\/#\/schema\/person\/b93619fac07567640bd87cc613a55b7c"},"description":"How to flash a Sonoff smart switch device with open source firmware. Enables MQTT and temperature\/humidity reporting on one of the cheapest WiFi switches you can buy.","breadcrumb":{"@id":"https:\/\/diyfuturism.com\/index.php\/2018\/03\/18\/the-cheapest-wifi-smart-switch-flashing-the-sonoff-basic\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/diyfuturism.com\/index.php\/2018\/03\/18\/the-cheapest-wifi-smart-switch-flashing-the-sonoff-basic\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/diyfuturism.com\/index.php\/2018\/03\/18\/the-cheapest-wifi-smart-switch-flashing-the-sonoff-basic\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/diyfuturism.com\/"},{"@type":"ListItem","position":2,"name":"The Cheapest WiFi Smart Switch: Flashing the Sonoff Basic"}]},{"@type":"Person","@id":"https:\/\/diyfuturism.com\/#\/schema\/person\/b93619fac07567640bd87cc613a55b7c","name":"brad","image":{"@type":"ImageObject","@id":"https:\/\/diyfuturism.com\/#personlogo","inLanguage":"en-US","url":"https:\/\/secure.gravatar.com\/avatar\/7e2d60eb1f322b4ad6040a746946a361?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/7e2d60eb1f322b4ad6040a746946a361?s=96&d=mm&r=g","caption":"brad"},"description":"I'm a professional artist who likes to tinker with building things in my spare time.","sameAs":["https:\/\/twitter.com\/@diyfuturism"]}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/03\/images.duckduckgo-1.jpg?fit=1000%2C547&ssl=1","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9q0Cl-7W","jetpack-related-posts":[{"id":718,"url":"https:\/\/diyfuturism.com\/index.php\/2018\/07\/30\/automate-dumb-devices-ir-node-red-home-assistant\/","url_meta":{"origin":492,"position":0},"title":"Automating Dumb Devices with Node-Red and Home Assistant","date":"July 30, 2018","format":false,"excerpt":"Here in coastal California, air conditioning is extremely uncommon. So during a recent heat wave, I got desperate and went down to the big box store in search of some relief and came home with a regular old dumb fan. I'm sure this is the kind of gadget you could\u2026","rel":"","context":"In &quot;Hardware&quot;","img":{"alt_text":"Automating a Dumb Fan","src":"https:\/\/i0.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/07\/Screenshot-from-2018-07-30-125551.png?fit=939%2C759&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":14,"url":"https:\/\/diyfuturism.com\/index.php\/2017\/11\/20\/my-smart-home-hardware-list\/","url_meta":{"origin":492,"position":1},"title":"My Smart Home: Hardware List","date":"November 20, 2017","format":false,"excerpt":"An ongoing list of all the hardware I've gradually acquired. Links are to Amazon, but if you are patient most things can be imported from China for much cheaper. Want to get started in home automation for cheap?\u00a0Check out my\u00a0$200 DIY Smart Home Shopping List to get started with a\u2026","rel":"","context":"In &quot;Hardware&quot;","img":{"alt_text":"","src":"https:\/\/i1.wp.com\/diyfuturism.com\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-27-at-3.21.16-PM.png?fit=1200%2C694&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":104,"url":"https:\/\/diyfuturism.com\/index.php\/2017\/11\/27\/favorite-esp8266-internet-of-things-projects\/","url_meta":{"origin":492,"position":2},"title":"Favorite ESP8266 Internet of Things Projects","date":"November 27, 2017","format":false,"excerpt":"So many good uses for these chips, here are a few I've made and some I still intend to. ESP Easy\u00a0- by far the easiest way to connect a bunch of cheap sensors to an esp8266. I have about 6 of these doing various things. Bed Occupancy Sensor\u00a0- FSR sensor\u2026","rel":"","context":"In &quot;Electronics&quot;","img":{"alt_text":"","src":"https:\/\/i2.wp.com\/diyfuturism.com\/wp-content\/uploads\/2017\/11\/esp.jpg?fit=450%2C328&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":251,"url":"https:\/\/diyfuturism.com\/index.php\/2017\/12\/19\/home-assistant-making-plant-sensors-talk\/","url_meta":{"origin":492,"position":3},"title":"Home Assistant: Making My Plants Talk with IoT Sensors and a Python Script","date":"December 19, 2017","format":false,"excerpt":"Living in an urban city without a garden, I have been exercising my green thumb by accumulating more and more houseplants. I have them tucked away in every light-filled corner, hanging from every rafter in my tall ceilings. Which is a problem, because I have to get a ladder out\u2026","rel":"","context":"In &quot;Config&quot;","img":{"alt_text":"","src":"https:\/\/i2.wp.com\/diyfuturism.com\/wp-content\/uploads\/2017\/12\/33644078760_c2187a3974_o.jpg?fit=1080%2C1080&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":191,"url":"https:\/\/diyfuturism.com\/index.php\/2017\/12\/14\/basic-node-red-flows-for-automating-lighting-with-home-assistant\/","url_meta":{"origin":492,"position":4},"title":"Basic Node-Red Flows for Automating Lighting with Home Assistant","date":"December 14, 2017","format":false,"excerpt":"Smart light bulbs are probably the first thing everyone getting into home automation buys. It is easy to see the applications for them - have the lights come on at night, turn off when you're home, etc. It's very satisfying to have the lights react to the day and your\u2026","rel":"","context":"In &quot;Config&quot;","img":{"alt_text":"","src":"https:\/\/i1.wp.com\/diyfuturism.com\/wp-content\/uploads\/2017\/12\/Screen-Shot-2017-12-14-at-7.49.36-PM.png?fit=835%2C631&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":764,"url":"https:\/\/diyfuturism.com\/index.php\/2018\/12\/16\/my-node-red-smart-alarm-clock-with-snooze\/","url_meta":{"origin":492,"position":5},"title":"My Node-Red Smart Alarm Clock with Snooze","date":"December 16, 2018","format":false,"excerpt":"Definitely one of my very favorite features of my smart house is my alarm clock. Which is funny because I am not a morning person\u00a0at all\u00a0and hate getting up. But the daily grind is made a little better by having my house gently wake me by fading in lights and\u2026","rel":"","context":"In &quot;Config&quot;","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/diyfuturism.com\/wp-content\/uploads\/2018\/12\/david-von-diemar-291597-unsplash.jpg?fit=1200%2C734&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/diyfuturism.com\/index.php\/wp-json\/wp\/v2\/posts\/492"}],"collection":[{"href":"https:\/\/diyfuturism.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/diyfuturism.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/diyfuturism.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/diyfuturism.com\/index.php\/wp-json\/wp\/v2\/comments?post=492"}],"version-history":[{"count":9,"href":"https:\/\/diyfuturism.com\/index.php\/wp-json\/wp\/v2\/posts\/492\/revisions"}],"predecessor-version":[{"id":516,"href":"https:\/\/diyfuturism.com\/index.php\/wp-json\/wp\/v2\/posts\/492\/revisions\/516"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/diyfuturism.com\/index.php\/wp-json\/wp\/v2\/media\/507"}],"wp:attachment":[{"href":"https:\/\/diyfuturism.com\/index.php\/wp-json\/wp\/v2\/media?parent=492"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/diyfuturism.com\/index.php\/wp-json\/wp\/v2\/categories?post=492"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/diyfuturism.com\/index.php\/wp-json\/wp\/v2\/tags?post=492"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}