Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Home Automation with MicroPython, the ESP8266 and Google Home

Dale Humby
October 16, 2020

Home Automation with MicroPython, the ESP8266 and Google Home

In this IoT talk we will demo a home automation project by wiring up a switch to an ESP8266, write and load a MicroPython web service on the hardware, link it to Home Assistant.

This is a live hardware build and coding session. All hardware will be locally sourced, the instructions and code will be on GitHub.

https://github.com/dalehumby/DevFest2020

Dale Humby

October 16, 2020
Tweet

More Decks by Dale Humby

Other Decks in Technology

Transcript

  1. Home Automation
    with MicroPython, the
    ESP8266 and Google Home
    Dale Humby
    CTO, Nomanini
    Google Cloud Developer Expert

    View Slide

  2. Smart Home

    View Slide

  3. Smart Home

    View Slide

  4. Level 1:
    Getting Started

    View Slide

  5. Get started: Switch a lamp on

    View Slide

  6. R120
    communica.co.za
    Get started: Switch a lamp on

    View Slide

  7. R120
    communica.co.za
    Get started: Switch a lamp on

    View Slide

  8. R120
    communica.co.za
    Get started: Switch a lamp on

    View Slide

  9. R120
    communica.co.za
    Get started: Switch a lamp on

    View Slide

  10. R120
    communica.co.za
    Get started: Switch a lamp on

    View Slide

  11. R120
    communica.co.za
    Get started: Switch a lamp on

    View Slide

  12. Get started: Switch a lamp on
    WiFi

    View Slide

  13. Get started: Switch a lamp on
    WiFi Internet

    View Slide

  14. Get started: Switch a lamp on
    WiFi Internet

    View Slide

  15. Level 2:
    Open Source

    View Slide

  16. View Slide

  17. tasmota.github.io/docs/Getting-Started/

    View Slide

  18. tasmota.github.io/docs/Getting-Started/
    R80
    communica.co.za/products/bmt-ftdi-
    usb-to-ser-converter

    View Slide

  19. tasmota.github.io/docs/Getting-Started/
    R80
    communica.co.za/products/bmt-ftdi-
    usb-to-ser-converter

    View Slide

  20. R1,400
    communica.co.za

    View Slide

  21. WiFi

    View Slide

  22. WiFi

    View Slide

  23. WiFi

    View Slide

  24. WiFi
    Internet

    View Slide

  25. Raspberry Pi 4
    vs
    Odroid C4

    View Slide

  26. View Slide

  27. Price ±R1,400
    1.5 - 2 GHz CPU
    4 GB RAM
    Gigabit Ethernet
    Low power < 5W
    40 PIN GPIO

    View Slide

  28. Price ±R1,400
    1.5 - 2 GHz CPU
    4 GB RAM
    Gigabit Ethernet
    Low power < 5W
    40 PIN GPIO
    Debian 10 / Raspberry OS
    Onboard WiFi + Bluetooth LE
    2x mini-HDMI
    2x USB2 + 2xUSB3
    5V USB type-C
    Needs heatsink!

    View Slide

  29. Price ±R1,400
    1.5 - 2 GHz CPU
    4 GB RAM
    Gigabit Ethernet
    Low power < 5W
    40 PIN GPIO
    Debian 10 / Raspberry OS
    Onboard WiFi + Bluetooth LE
    2x mini-HDMI
    2x USB2 + 2xUSB3
    5V USB type-C
    Needs heatsink!
    Ubunt 20.04 / Android 9
    1x full-size HDMI
    4x USB3
    Voltage range 5-17 V

    View Slide

  30. Home Automation
    Software Stack

    View Slide

  31. View Slide

  32. View Slide

  33. View Slide

  34. View Slide

  35. View Slide

  36. Home Assistant: Home automation
    Mosquitto MQTT broker: Pub/Sub protocol
    Prometheus: Time series database
    Grafana: Visualisation
    Node-Red: Flow-based software control
    Home Automation / IoT Stack

    View Slide

  37. View Slide

  38. View Slide

  39. Because micro-SD cards fail

    View Slide

  40. github.com/dalehumby/rpi-provision
    +
    Ready-made
    images on
    Docker Hub
    Because micro-SD cards fail

    View Slide

  41. View Slide

  42. View Slide

  43. View Slide

  44. View Slide

  45. View Slide

  46. View Slide

  47. View Slide

  48. View Slide

  49. View Slide

  50. View Slide

  51. View Slide

  52. View Slide

  53. View Slide

  54. github.com/dockersamples/docker-swarm-visualizer

    View Slide

  55. Level 3:
    Build your own
    hardware

    View Slide

  56. How much prepaid
    electricity do I have
    left?
    Where is all my
    electricity going?

    View Slide

  57. kWh remaining

    View Slide

  58. kWh remaining
    1,000 flashes per kWh

    View Slide

  59. kWh remaining
    1,000 flashes per kWh
    “API... what?”,
    said Plessey

    View Slide

  60. 1,000 flashes per kWh
    LDR sensor (R20) https://www.communica.co.za/products/bmt-ambient-light-sensor
    D1 Mini (R85) https://www.communica.co.za/products/bmt-esp8266ex-nodemcu-wifi-board
    Screen Scrapers for Hardware Hackers

    View Slide

  61. 1,000 flashes per kWh
    LDR sensor (R20) https://www.communica.co.za/products/bmt-ambient-light-sensor
    D1 Mini (R85) https://www.communica.co.za/products/bmt-esp8266ex-nodemcu-wifi-board
    Screen Scrapers for Hardware Hackers

    View Slide

  62. 1,000 flashes per kWh
    LDR sensor (R20) https://www.communica.co.za/products/bmt-ambient-light-sensor
    D1 Mini (R85) https://www.communica.co.za/products/bmt-esp8266ex-nodemcu-wifi-board
    Screen Scrapers for Hardware Hackers

    View Slide

  63. 1,000 flashes per kWh ESP8266
    D1 Mini
    LDR sensor (R20) https://www.communica.co.za/products/bmt-ambient-light-sensor
    D1 Mini (R85) https://www.communica.co.za/products/bmt-esp8266ex-nodemcu-wifi-board
    Screen Scrapers for Hardware Hackers

    View Slide

  64. https://en.wikipedia.org/wiki/ESP8266
    https://www.espressif.com/
    ESP8266
    From Espressif Systems
    ... The Arduino killer

    View Slide

  65. https://en.wikipedia.org/wiki/ESP8266
    https://www.espressif.com/
    ESP8266
    From Espressif Systems
    ... The Arduino killer
    32-bit CPU
    80 MHz clock
    160 kB RAM + 4 MB Flash
    Integrated WiFi + TCP/IP stack
    16 GPIO pins / I2C / SPI / UART / ADC
    Cheap - used “everywhere”

    View Slide

  66. View Slide

  67. View Slide

  68. View Slide

  69. View Slide

  70. Let’s
    get coding

    View Slide

  71. View Slide

  72. Putting it all
    together

    View Slide

  73. github.com/dalehumby/powermeter

    View Slide

  74. github.com/dalehumby/powermeter

    View Slide

  75. github.com/dalehumby/powermeter

    View Slide

  76. github.com/dalehumby/powermeter

    View Slide

  77. Beyond

    View Slide

  78. View Slide

  79. Swarm mode: Natively managing a cluster of Docker Engines

    View Slide

  80. View Slide

  81. k3s.io
    Lightweight kubernetes

    View Slide

  82. k3s.io
    Lightweight kubernetes
    PXE / Network boot
    worker nodes

    View Slide

  83. k3s.io
    Lightweight kubernetes
    PXE / Network boot
    worker nodes

    View Slide

  84. TensorFlow Lite
    coral.ai/products/dev-bo
    ard-mini
    $99
    nvidia.com/en-us/auton
    omous-machines/jetson-
    store/
    $99
    dog

    View Slide

  85. View Slide

  86. home-assistant.io/integrations/google_assistant/

    View Slide

  87. home-assistant.io/integrations/google_assistant/

    View Slide

  88. Resources
    MicroPython docs.micropython.org/en/latest/esp8266/tutorial/intro.html
    Home Assistant home-assistant.io
    Mosquitto MQTT mosquitto.org
    Where to buy {hardware}
    Communica
    communica.co.za
    Build Actions on Google Assistant
    codelabs.developers.google.com/codelabs/actions-1
    Dale Humby
    github.com/dalehumby
    [email protected]
    dalehumby.com
    We’re hiring
    nomanini.com/careers

    View Slide