You are on page 1of 6

Home

Paragliding

ESP8266Projects
QuickStartGuide
LuaLoaderforWindows
ESP8266forDummies
ESP8266ControlledOutlet
WiFiHotspotFinder
WifiConnectedButton
AskGoogleforthetime
ACPowerMonitor
RainGaugeMonitor

MSP430Projects
GoProController
KISSThermostat
TemperatureLogger

HamRadioCalls
C31LJ
VE3SUN
AB6WM
LZ/G0RZJ
HB0/G0RZJ
CO/VE3SUN
VE3GEJ

Projects
GoProCamera
InternationalBeacon
Project
HamLocatorMap
BeaconMonitor
KiteAerialPhotography
IP9100A
CottageCam

Downloads
DXMonitor
DOSBeam1.11
HamPopTSR
Qrate

Travels
ParaglidingNomadness
GreenlandandArctic
Colombia
Morocco
Turkey
Pyrenees
Cuba
Postcards

ForSale
ESP8266boards
ESP12boards

Travel

Photos

Software

HamRadio

History

Contact

ESP8266QuickStart
ThispageismeanttobeaquickintroductiontotheESP8266forthosewhoare
confusedbyalloftheinformationavailableonthevariousblogsandforumswhojust
wanttotryoutthisexcitingboardintheshortestpossibletime.Thisguideisfor
WindowsuserswhowanttousetheNodeMCUenvironment.
Notcountingwaitingforhardwaretoshiptoyou(110days),youshouldbeableto
useyourESP8266forsomethingusefulinlessthananhour.Ready?

WhatdoIneedtobuy?
YouwillneedanESP8266developmentboard.ThereareseveralESP8266boards
available,usuallynumberedESP01throughESP12.Checkthepinsoftheactual
boardyouorderwiththeinformationfromyoursourceastherapiddevelopmentof
theseproductshasledtoconfusionandduplicationofboardidentificationnumbers.
Thepricesvaryfromaround$2forasimpleESP01to$15foracompleteboard
withUSBtoserialand3.3voltregulator.TheESP01isasimpleboardtostartwith.
TheESP12ispopularbecauseofitssizeandthenumberofpinsbroughttotheside
oftheboard.Recently,moredevelopmentboardshavebecomeavailablewith
additionalsensors,relays,LEDsandvoltageregulatorsontheboard.
A3voltpowersupply.TheESP8266runsonanythingfrom2.8to3.5volts,soa
coupleofAAbatterieswillwork.Mostofususea3.3voltregulatedpowersource.
Maximumcurrentdrawis300mA,souseasupplythatcansupply500mAtobe
safe.Moreisbetter.Aweakorpoorqualitysupplywillcausetheboardtoreset
unexpectedlyandmakedebuggingdifficult.TheNodeMCUDevelopmentBoardhasa
USBto3.3Vpowersupplyontheboard.
AUSBtoserialadapter.Thisshouldbea3.3voltcompatiblemodel.Itis
possibletolevelconvertifyoualreadyhavea5voltadapter.TheNodeMCU
DevelopmentBoardhastheUSBtoserialinterfaceontheboard.Whenyoureceive
youradapter,verifythattheactualvoltageoutputis3.3voltsassomecheap
adaptershavebeenfoundtobemislabelled.Anyofthefollowingshould
work:FTDi,CH340,FT232RL.

WhatdoIneedtodownload?
TheESP8266boardyouboughtmayhaveoneofmanydifferentfirmwareversions
onit.ManycomewithATfirmwareforserialcommunications.Somecomewithno
userfirmwareatall.IrecommendtheNodeMCULuafirmwareasastartingpoint
becauseitgivesyouaninteractiveprogramminglanguagewhichallowsyouto
experimentandbuildsimpleworkingprogramswithoutalotofeffort.Ifyouarenot
familiarwithLua,youwillfindthatitisnothardtolearn,atleastforthesimple
tasksneededtogetstarted.
ThetoolyouwillusetoflashtheNodeMCUfirmwareonyourESP8266boardis
thenodemcuflasher.Itisopensourceongithub.Gotothenodemcuflasher
pageandchooseWin32orWin64dependingonyourcomputersystem.Clickon
ESP8266Flasher.exeandthenrightclickonViewRawandSaveLinkAs...to
downloadtheapplicationtoyourPC.Orusethedirectlinksbelow:
ESP8266Flasher.exeforWin32

ESP01boards
NodeMCUdevelopment
boards

Associations
NCDXF
URA
SLVARC
SCCARC
IARU
RAC
NCCC
CCO

ESP8266Flasher.exeforWin64

WhatdoIhavetoconnect?
TheactualconnectionswilldependontheboardyouhaveandtheUSBtoserial
adapteryouareusing.

FAQ
WhoisPeterJennings?
WhereisPeter?

ConnectWithMe
Twitter
Facebook
LinkedIn

Power.
+3.3voltstoVcc
ground
Communications.
TxDontheboardtoRxDontheadapter
RxDontheboardtoTxDontheadapter
Ground
Jumpers.
ConnectVcctoCH_PDtoenablethechip
ConnectGPI0toGNDtoenableflashreprogramming

HowdoIinstallNodeMCUonmyESP8266?
PlugtheUSBtoserialadapterintoyourPC.Mostadaptersareautomatically
recognizedbyWindows7and8.UsersofXPorolderversionsofWindowsmayneed
adriverwhichshouldbesuppliedbythemanufactureroftheUSBadapter.The
adapterwillappearasanewCOMportonyoursystem.ChecktheDeviceManagerif
necessary.
RunESP8266Flasher.exe

IfyouonlyhaveoneCOMdevice,theportwillappearautomatically.Ifyouhave
morethanone,selectthecorrectonefromthedropdownmenu.
TheflasherprogramcomeswithdefaultNodeMCUfirmwareinmemory.Thisis
unlikelytobethelatestversion,buttogetstartedquickly,usethedefaultinternal
image.Later,youcandownloadthelatestfirmware,thenselectthe[Config]taband
choosethenew.binfile.Selectthe0x7C000defaultand0x7E000blanksections.
Unchecktheboxforthe0x10000IROMsection.
ClickonFlash(E)tostarttheprogrammingprocess.IftheMACaddressesdon't
appearwithinafewseconds,disconnectthepowertotheboardandreconnectit.If
itstilldoesn'twork,checkyourconnections.Makesurethatthejumperbetween
GNDandGPIO0istheresothattheboardisinreflashmode.
Reflashingthechipwilltakeacoupleofminutes.Whenthejobisdone,disconnect
powerfromtheboardandremovethejumperfromGNDtoGPIO0toleave
reflashmode.
YouarenowreadytoprogramtheESP8266foryourownapplication.

HowdoIcommunicatewiththeESP8266?
TheNodeMCULuafirmwareyouhavejustinstalledcommunicateswiththePCover

theseriallink.YoucanusePuTTY,SimpleTerm,oranyotherterminalprogramthat
youliketowriteLuaprogramsorenterdirectcommandstotheboard.Thedefault
speedis9600baud,butthatcanbechangedtoanyotherbaudrateonceyouhave
establishedcommunications.

LuaLoader
LuaLoaderisaWindowsprogramforuploadingfilestotheESP8266andworking
withtheLuaserialinterface.Aswellasbeingasimpleterminalprogram,ithasbuilt
inLuacommandbuttonsthatmakeiteasytointeractandexperimentwiththe
ESP8266board.
Download:LuaLoader.zip
LuaLoader.exeisasimpleWindowsapplicationthatrequiresnospecialinstallation.

FromtheSettingsmenu,selectCOMPortSettingsandchoosetheappropriate
COMportforyourUSBtoserialadapter.Don'tchangeanyothersetting.
ClickingbuttonsonLuaLoadersendscommandstotheboard.Poweryourboardand
watchfortheinitialmessage.Afterdisplayingsomefunnycharacters(theseare
firmwareresetparameterssentat74880baud),youshouldseetheversion
informationoftheNodeMCUbuild:
NodeMCU0.9.5build20150107poweredbyLua5.1.4
LuaLoaderwillwarnyouifalaterfirmwarebuildisavailable.
Afterbooting,NodeMCUwillattempttorunafilecalledinit.luainflashmemory.
Sinceyouhaven'tputitthere,itwillreportanerrorandshowthe>prompt.You
arenowreadytointeractwithLuaontheESP8266.
ClicktheHeapbuttontodisplaytheamountofRAM
available.LuaLoaderwilltypethecommand=
node.heap()andtheESP8266willrespondwith23016or
someothervalue,followedbythe>promptagain.

HowdoIconnecttoanAccessPoint?

EntertheSSIDandpasswordofyour
closestaccesspointintheappropriatetext
boxonLuaLoader.ClickSetAP.LuaLoader
willtypethecommandstosettheWiFi
modeandconnect.Thisinformationis
savedinflashmemoryandwillbe
remembereduntilchanged,evenifthe
boardispowereddown.
Clickthe

WiFibuttontochecktheconnectionstatus.

ClickGetIPtoconfirmthattheESP8266isconnectedtoyouraccesspoint.

ClicktheSurveybuttontolist
theavailableaccesspointsvisible
totheESP8266.TheSSID,
authenticationmode,signal
strength,MACaddressand
channelareshown.
AllofthecommandstypedbyLuaLoadercanbeenteredmanually,orsavedinafile
toberunautomatically.

HowdoIreadaGPIOinput?
TheLuafunctiongpio.read(pin)readsthevalueoftheinputspecifiedbypinifthe
GPIOhasbeensetupasaninput.
LuaLoadermakesthiseasytotest.
Selectpin3GPIO0fromtheGPIO
dropdownmenu,selectinputand
floatingfromthemodedropdown
menus.ClickSet.Then,clickRead.
Thecurrentpinvaluewillbe0or
1.Inthiscase,1asthatpinisheld
highnormally.
NotethatifGPIO0islowonreset,thechipwillenterreflashingmode,soyoumust
ensurethatanyuseofthatGPIO0foruserinputishighwhenthedeviceispowered
onorreset.
Toreadthevalueoftheinputpinrepeatedly,inLuaLoader,clickontheclockbeside
theReadbutton.Note,thatifyouareusingtheNodeMCUdevelopmentboard,the
buttonmarkedFLASHwillchangethevaluefrom1to0whenthebuttonispressed
asitisconnectedtoGPIO0andground.Thereadratecanbechangedinthe
Settingsmenu.

HowdoIsenddatatoaserver?
Thedemoscripthttpget.luaconnectstothiswebserverandsendsthetimeittook
toconnect(inmicroseconds)andtheamountofheap(RAM)availableatthattime.
Downloadthescripttoyourcomputer,thenuploadittoyourESP8266using
theUploadFilebutton.
testedonNodeMCU0.9.5build20141222...20150108
sendsconnectiontimeandheapsizetohttp://benlo.com/esp8266/test.php
print('httpget.luastarted')
Tstart=tmr.now()
conn=nil
conn=net.createConnection(net.TCP,0)
showtheretrievedwebpage
conn:on("receive",function(conn,payload)
success=true
print(payload)
end)
onceconnected,requestpage(sendparameterstoaphpscript)
conn:on("connection",function(conn,payload)
print('\nConnected')
conn:send("GET/esp8266/test.php?"
.."T="..(tmr.now()Tstart)
.."&heap="..node.heap()
.."HTTP/1.1\r\n"
.."Host:benlo.com\r\n"
.."Connection:close\r\n"
.."Accept:*/*\r\n"
.."UserAgent:Mozilla/4.0"
.."(compatible;esp8266Lua;"

.."WindowsNT5.1)\r\n"
.."\r\n")
end)
whendisconnected,letitbeknown
conn:on("disconnection",function(conn,payload)print('\nDisconnected')end)

conn:connect(80,'benlo.com')
ConnecttoyouraccesspointfirstusingtheSetAPbutton.Thisisnotnormally
necessaryifyouhavesetthecorrectAPsincethelasttimeyouflashednew
firmware.
Usethedofilebuttontorunthefileyouhavejustuploaded.
Thecontentsoftheretrievedpageshouldbedisplayed.

Feelfreetousemyserverforafewtests,butpleasechangetoyourownwebserver
orsignupforoneofthepublicinternetofthingsservers,suchasthingspeak.com.
Claudiuchiruhaspostedanexampleofsendingtemperature(usingan
inexpensiveBS18B20I2Csensor)tothingspeak.com.
ThissimplescriptisallittakestomakeusefulgadgetsfromthesimplestESP01
board.Theboardcanbeconnectedsothatitreceivespowerwhenadeviceison,a
buttonispressed,motionisdetected,amagnettripsareedswitch,etc.etc.
Thephpscriptwillreceivethesignalandcanbeprogrammedtosendanemail,
sendansms,pushanotificationtoyourphone,orsimplylogeventsforfuture
reference.
OurwellpumpisnowmonitoredbyanESP01runningasimplescriptonceevery
30secondswhenthepowerison.Aswellasloggingtheactivityandsendingadaily
emailreport,thescriptsendsoutemergencynotificationsifthepumprunsformore
than2hours,orhasn'trunformorethan36hours.
AmotiondetectorwitharelayturnsonanotherESP01whichrunsthesame
programbutcallsadifferentphpscripttoalertmewhenthereismotioninfrontof
thehouse.Myphonereceivesthealertbeforethedoorbellispressed.

HowdoImaketheprogramrunautomatically?
WhentheESP8266starts,itrunstheinit.luafile.Simplycreateafile
calledinit.luawhichrunsthefilewithyourprograminstructions.Itisalsoagood
placetoinitializeanyvariablesyouareusing,suchastheSSIDoftheaccesspoint.
Whiledebugging,itisagoodideatouseatimertocallyourfileafterafewseconds.
Ifyoumakeamistake,causingacrash,youwillhaveafewsecondstostopthe
timerwiththetmr.stopbuttonbeforetheprogramstartstorunagain.Forthe
exampleabove,onelinewilldo:
tmr.alarm(0,10000,0,function()dofile('httpget.lua')end)
Armtimernumber0toexecutethefunctiondofile('httpget.lua')in10seconds.

HowcanIlearnmore?
TheHelpmenuofLuaLoaderhasalargenumberoflinkstoESP8266andLua
resourcesforconvenientaccesswhileprogramming.Thereisalsoamenuitem
linkingfilesonyourcomputeryoumayhavedownloadedforreference.
UsefulLinks:
NodeMCULuaAPIReference
Theesp8266communityforum.Lotsofsamplescripts.
TechnicalOverviewoftheESP8266byNurdspace
Lua.org,homeoftheLualanguage.
NodeMCUgithubLuasourceandlatestbinaries
EspressifSystems,manufactureroftheESP8266

You might also like