Skip to content

Instantly share code, notes, and snippets.

@m0rph03nix
Last active September 14, 2023 14:05
Show Gist options
  • Save m0rph03nix/aae023e6e513928f2ebc6d8f8a05ddd8 to your computer and use it in GitHub Desktop.
Save m0rph03nix/aae023e6e513928f2ebc6d8f8a05ddd8 to your computer and use it in GitHub Desktop.

Setup

IDE :

  • Arduino IDE 2 (déjà installé, recommandé)

Arduino :

  • Board
    • In File --> Preferences -> Additionnal boards mana... add https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json
    • In Tools --> Board -> Boards Manager, look for ESP32 and install it
    • In Tools --> Board select TTGO LoRa32-OLED (even though this borad has no LoRa...)
  • Dependencies :
    • TFT_eSPI
      • In User_Setup_Select.h, select Setup25_TTGO_T_Display
    • PubSubClient
  • Check relevant exemples in File --> Exemples
  • Compile & Upload a program in your board with the "arrow button"

If Serial error appears : pip3 install pyserial

MQTT broker :

  • local : mosquitto

  • online : hivemq

    Port 1883 not open between CPE and "outside"

Domotic assistant :

Practical work reports

  • Your work will hand-over on GitLab
    • The Git repository will be created by YOUR TEACHER with your gitlab IDs (tell him with who you are)
  • Your repository will be organized exctly so:
  - images_videos
  
  - Part1
    - ESP
      - ESP_motor.ino   
      - ESP_temp.ino    
    - Python
      - *.py
    - HA
      - *.yaml
    - README.md

  - Part2
    - ESP
      - ESP_motor.yaml 
      - ESP_temp.yaml 
    - HA
      - *.yaml
    - README.md

  - Part3
    - ESP
      - ESP_motor.ino   
      - ESP_temp.ino   
    - Python
      - *.py
    - HA
      - *.yaml
    - README.md
    
  - README.md
  • Every student should commit (not only one per group)

Project steps :

Every folowing steps must be descibed in a README.md file at the root of your code repository.
A very short vidéo (~15-20 seconds) for each part must show the working features

Part 1:

  • ESP Board 1:

    • Read an analog value and send its value scaled on 8 bits to Serial. A potentiometer will simulate a temperature sensor. Code a simple filter (average for exemple) to avoid a noisy temperature.

    • Test mqtt publisher on ESP32 (with hivemq and mosquitto)

    • Merge the 2 previous codes to publish analog value as a temperature (0 to 255°) on topic /I102/<yourname>/temperature

  • ESP Board 2:

    • Test mqtt sucriber on ESP32 (with hivemq and mosquitto)

    • Test moving servo motor

    • Merge the 2 previous codes to subscribe the motor angle from topic /I102/<yourname>/air_flow

  • Write a python script to link the 2 topics : If temperature changed, then change the airflow with a function

  • Try to do the same scenario but with Home Assistant (no python script)

Part 2:

  • Do the same as Part 1 but with ESPHome instead of MQTT. There is no need to write a python script, it should be linked with ESPHome.

💡 Find some help here

Part 3:

  • With the "NRF Connect" App, try to find the temperature UUID and bytes of the BLE thermometer

  • ESP (Board 1):

    • Read temperature as a BLE client
    • Send temperature on Serial
    • Display the temperature on the board screen
  • On your computer with python:

    • Read temperature as a BLE client (you can use 'bleak')
    • Send it with MQTT on /I102/<yourname>/temperature
    • Test it with the Part 1 workflow

Part 4:

  • Suggest and make a project with MQTT, BLE and a domotic assistant of your choice (Home Assistant is highly recommanded).
  • Select one option available to enhance your project:
    • Easy :
      • Nice ESP32 Human Machine Interface (screen + buttons)
      • Use other sensors
      • Use another kind of ESP32 board
    • Medium
      • Turn ON/OFF an X10 plug
      • Link a vocal assistant to your domotic assistant
    • Hard
      • Make a MQTT device with a STM32F746G Board
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment