<h3id="a-lua-based-firmware-for-wifi-soc-esp8266"><aname="user-content-a-lua-based-firmware-for-wifi-soc-esp8266"href="#a-lua-based-firmware-for-wifi-soc-esp8266"class="headeranchor-link"aria-hidden="true"><spanclass="headeranchor"></span></a>A lua based firmware for wifi-soc esp8266</h3>
<h1id="flash-the-firmware"><aname="user-content-flash-the-firmware"href="#flash-the-firmware"class="headeranchor-link"aria-hidden="true"><spanclass="headeranchor"></span></a>Flash the firmware</h1>
<p>nodemcu_512k.bin: 0x00000<br/><br/>
for most esp8266 modules, just pull GPIO0 down and restart.<br/><br/>
You can use the <ahref="https://github.com/nodemcu/nodemcu-flasher">nodemcu-flasher</a> to burn the firmware.</p>
<h1id="connect-the-hardware-in-serial"><aname="user-content-connect-the-hardware-in-serial"href="#connect-the-hardware-in-serial"class="headeranchor-link"aria-hidden="true"><spanclass="headeranchor"></span></a>Connect the hardware in serial</h1>
<h4id="connect-to-your-ap"><aname="user-content-connect-to-your-ap"href="#connect-to-your-ap"class="headeranchor-link"aria-hidden="true"><spanclass="headeranchor"></span></a>Connect to your ap</h4>
<h4id="manipulate-hardware-like-a-arduino"><aname="user-content-manipulate-hardware-like-a-arduino"href="#manipulate-hardware-like-a-arduino"class="headeranchor-link"aria-hidden="true"><spanclass="headeranchor"></span></a>Manipulate hardware like a arduino</h4>
<h4id="or-a-simple-http-server"><aname="user-content-or-a-simple-http-server"href="#or-a-simple-http-server"class="headeranchor-link"aria-hidden="true"><spanclass="headeranchor"></span></a>Or a simple http server</h4>
<divclass="codehilite"><pre><spanclass="c1">-- A simple http server</span>
<h4id="if-you-want-to-run-something-when-system-started"><aname="user-content-if-you-want-to-run-something-when-system-started"href="#if-you-want-to-run-something-when-system-started"class="headeranchor-link"aria-hidden="true"><spanclass="headeranchor"></span></a>If you want to run something when system started</h4>
<divclass="codehilite"><pre><spanclass="c1">--init.lua will be excuted</span>
<spanclass="n">file</span><spanclass="p">.</span><spanclass="n">writeline</span><spanclass="p">(</span><spanclass="s">[[print("Hello, do this at the beginning.")]]</span><spanclass="p">)</span>
<spanclass="n">node</span><spanclass="p">.</span><spanclass="n">restart</span><spanclass="p">()</span><spanclass="c1">-- this will restart the module.</span>
</pre></div>
<h4id="with-below-code-you-can-telnet-to-your-esp8266-now"><aname="user-content-with-below-code-you-can-telnet-to-your-esp8266-now"href="#with-below-code-you-can-telnet-to-your-esp8266-now"class="headeranchor-link"aria-hidden="true"><spanclass="headeranchor"></span></a>With below code, you can telnet to your esp8266 now</h4>
<divclass="codehilite"><pre><spanclass="c1">-- a simple telnet server</span>
<spanclass="n">node</span><spanclass="p">.</span><spanclass="n">output</span><spanclass="p">(</span><spanclass="n">s_output</span><spanclass="p">,</span><spanclass="mi">0</span><spanclass="p">)</span><spanclass="c1">-- re-direct output to function s_ouput.</span>
<spanclass="n">node</span><spanclass="p">.</span><spanclass="n">input</span><spanclass="p">(</span><spanclass="n">l</span><spanclass="p">)</span><spanclass="c1">-- works like pcall(loadstring(l)) but support multiple separate line</span>
<spanclass="n">node</span><spanclass="p">.</span><spanclass="n">output</span><spanclass="p">(</span><spanclass="kc">nil</span><spanclass="p">)</span><spanclass="c1">-- un-regist the redirect output function, output goes to serial</span>
<spanclass="k">end</span><spanclass="p">)</span>
<spanclass="nb">print</span><spanclass="p">(</span><spanclass="s2">"</span><spanclass="s">Welcome to NodeMcu world."</span><spanclass="p">)</span>
<spanclass="k">end</span><spanclass="p">)</span>
</pre></div>
<h4id="use-ds18b20-module-extends-your-esp8266"><aname="user-content-use-ds18b20-module-extends-your-esp8266"href="#use-ds18b20-module-extends-your-esp8266"class="headeranchor-link"aria-hidden="true"><spanclass="headeranchor"></span></a>Use DS18B20 module extends your esp8266</h4>
<divclass="codehilite"><pre><spanclass="c1">-- read temperature with DS18B20</span>
<h1id="check-this-out"><aname="user-content-check-this-out"href="#check-this-out"class="headeranchor-link"aria-hidden="true"><spanclass="headeranchor"></span></a>Check this out</h1>