Fire up the ESP32

Web Designer - - Web Workshop -

Em­u­lat­ing web things is bor­ing. Es­pres­sif’s ESP32 lets us build some­thing real Es­pres­sif does not of­fer its core li­braries via the Ar­duino de­ploy­ment sys­tem – in­stead, code must be down­loaded us­ing Github via the com­mand git clone https://github.com/me-no-dev/ es­pasyncweb­server. Com­press the con­tents of the re­ceived repos­i­tory to cre­ate a file called Es­pasyncweb­server.zip, and in­stall it us­ing the Man­age Li­braries op­tion of the Ar­duino IDE. Re­peat the process with the sec­ond li­brary, which re­sides at https://github.com/me-no-dev/ asynctcp. A full ar­chive can also be found at http://www. ta­mogge­mon.com/test/2018/ esp32-webthings-libs.zip. Fi­nally, click Sketch → In­clude Li­brary → Man­age Li­braries, look for “Ar­duino­j­son” and se­lect ver­sion 5.13.2 for in­stal­la­tion – beta ver­sions of V6 are not sup­ported. The fi­nal miss­ing li­brary is called webthing, as of this writ­ing, ver­sion 0.4.1 is cur­rent.

CRE­ATE A SKETCH

Our pro­gram starts off by in­clud­ing a set of head­ers pro­vid­ing ac­cess to the hardware. We con­nect an LED to GPIO 12 in or­der to let our thing emit in­for­ma­tion to the out­side world. Things ex­pose a set of prop­er­ties. In the case of the Ar­duino li­brary, cre­ate a few global vari­ables to hold sta­tus and other in­for­ma­tion: The bulk of the code is re­spon­si­ble for the es­tab­lish­ment of a Wifi con­nec­tion. Be sure to re­place ssid and pass­word with val­ues ap­pli­ca­ble to your lo­cal net­work. Once the Wifi stack is con­nected to a net­work, in­for­ma­tion about the IP ad­dress can be emit­ted to the se­rial mon­i­tor of the IDE: The last part of the pro­gram pro­vides CPU time to the adapter dur­ing in­vo­ca­tions of the loop() func­tion: When done, in­stall the pro­gram on your ESP32 and note down the URL emit­ted in the se­rial mon­i­tor – in the fol­low­ing steps, we as­sume http://192.168.1.105/things/led

Newspapers in English

Newspapers from UK

© PressReader. All rights reserved.