Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Esp8266 Workshop


Published on

Workshop given at my employer regarding the ESP8266, a nifty IoT chip. Covers some topics and some basic getting started information.

Published in: Engineering
  • Be the first to comment

Esp8266 Workshop

  1. 1. PROGRAM • Theoretical • What is the ESP8266 • Writing your own code • Cool projects • Considerations • Practical • Making something with the ESP8266
  2. 2. ABOUT ME • Embedded enthusiast • Don’t plug it in, take it apart! • Personal projects • LightSaga • Ikea lamp • Ambilight • Blog on
  3. 3. WHAT IS A ESP8266 • Wireless SoC • Has GPIO, I2C, ADC, SPI, PWM and some other nice acronyms • It’s fast! Running at 80MHz (or 160MHz if you’re brave) • 64KBytes of instruction RAM, 96KBytes of data RAM and 64KBytes boot ROM • Has a Winbond W25Q40BVNIG SPI flash for your code • RISC architecture (in case you care) • Core is a 106micro Diamond Standard core (LX3) made by Tensilica • ESP8266 chip is made by Espressif • It’s cheap enough to be put in everything and anything
  5. 5. NODEMCU • An open source firmware aimed on the IoT platform. It has the ability to run easy to code LUA scripts, making it easy to program the ESP8266. Based on LUA 5.1.4 (without debug and os module). Build-in json, file, timer, pwm, i2c, spi, 1-wire, net, mqtt, coap, gpio, wifi, adc, uart and system api. • Example of http server in using NodeMCU: srv=net.createServer(net.TCP) srv:listen(80,function(conn) conn:on("receive",function(conn,payload) print(payload) conn:send("<h1> Hello, NodeMCU.</h1>”) end) end)
  6. 6. ARDUINO • Starting with 1.6.4, Arduino allows installation of third-party platform packages using Boards Manager. • ESP8266 chip in the Arduino environment. ESP8266WiFi library bundled with this project has the same interface as the WiFi Shield library, making it easy to re-use existing code and libraries. • Lot’s of libraries to benefit from for interfacing different hardware components. • More user friendly way of writing code, more examples available.
  7. 7. COMMUNITY •, very active community • Support from Espressif, regular releases of SDKs (their latest is MIT licensed) • Google! • Downsides • Fragmented information. • Chinese documents & quality • Different versions
  8. 8. WRITING YOUR OWN CODE • Get a SDK • Linux • ESP-open-sdk • Windows • Made by some Russian, supports Eclipse • Look at samples • Blinky • Interrupt examples • Your own project • Flashing
  9. 9. BLINKY – INIT FUNCTION //Init function void ICACHE_FLASH_ATTR user_init() { gpio_init(); // Initialize the GPIO subsystem. PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2); // Set GPIO2 to output mode gpio_output_set(0, BIT2, BIT2, 0); // Set GPIO2 low os_timer_disarm(&some_timer); // Disarm timer os_timer_setfn(&some_timer, (os_timer_func_t *)some_timerfunc, NULL); // Setup timer os_timer_arm(&some_timer, 1000, 1); / /Arm the timer, 1000 is the fire time in ms, 0 for once and 1 for repeating system_os_task(user_procTask, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen); // Start os task }
  10. 10. BLINKY – TIMER & OS FUNCTION // Do blinky stuff void some_timerfunc(void *arg) { if (GPIO_REG_READ(GPIO_OUT_ADDRESS) & BIT2) { // Check if GPIO2 is HIGH gpio_output_set(0, BIT2, BIT2, 0); // Set GPIO2 to LOW } else { gpio_output_set(BIT2, 0, BIT2, 0); // Set GPIO2 to HIGH } } //Do nothing function static void ICACHE_FLASH_ATTR user_procTask(os_event_t *events) { os_delay_us(10); }
  11. 11. COOL PROJECTS • MQTT • Project running MQTT messaging on the ESP8266, very useful for IoT applications such as reporting temperature and more. • HTTP deamon • Made by Sprite_TM (Dutch & GoT moderator), running a webserver on an ESP to serve a site that allows control of GPIO. • ESP8266 powerstrip • Phoqus is playing with ESP8266s too, SAP wants to focus on IoT and @jpenninkhof is making awesome things such as a ESP8266 controlled powerstrip. Check it out on his website: through-mqtt/ • Many more!!! Check or…
  12. 12. MQTT? • MQTT (MQ Telemetry Transport) is a very simple, extremely efficient publish/subscribe reliable messaging protocol. A protocol that enabled devices to open a connection, keep it open using very little power and receive events or commands with as little as 2 bytes of overhead. A protocol that has the things built in that you need for reliable behavior in an unreliable or intermittently connected wireless environments. Things such as “last will & testament” so all apps know immediately if a client disconnects ungracefully, “retained message” so any user re- connecting immediately gets the very latest business information, etc.
  13. 13. CONSIDERATIONS • ESP8266 is 3.3V, logic level converter needed for 5V hardware • Antenna yields various results • Chinese quality • Pick the right ESP8266 for you • Put code in flash • Don’t give up!
  14. 14. HANDS-ON • Driving WS2812b LED ring with ESP8266 • Connecting all the parts together • Find a way to interface with the LEDs • Control it! (Maybe esphttpd? Or simple UDP listener…) • Please beware of the following points • Check the polarity on your PSU • Power and ground rails should be connected through in the middle • Ground first, power later • Logic level of WS2812b is 5V, ESP8266 is 3.3V