This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
en:domotique:garagebox [2025/02/10 19:43] – created kodein | en:domotique:garagebox [2025/02/18 14:21] (current) – [Résultats] kodein | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | FIXME **This page is not fully translated, yet. Please help completing the translation.**\\ //(remove this paragraph once the translation is finished)// | ||
- | |||
====== Why I want home automation for my separate garages too ====== | ====== Why I want home automation for my separate garages too ====== | ||
As William would say : //"Why not ?"// LOL | As William would say : //"Why not ?"// LOL | ||
Line 24: | Line 22: | ||
But I'll have to think on how to have the sensors and actuators far away from the core of the system. | But I'll have to think on how to have the sensors and actuators far away from the core of the system. | ||
- | ===== Choix technologiques | + | ===== Tech choices |
- | A l' | + | At first I wanted to buy ready to use zigbee |
- | Donc je me suis penché sur d'autres options et ce qui me semble le plus simple serait une solution à base de [[https:// | + | So I searched other solutions. The simplest one I've found would be a [[https:// |
- | Ça tourne sur pcb de dev ESP32/ | + | It runs on ESP32, ESP8366 and even RP2040 |
- | La communication avec le serveur se fait en wifi (faudra check si le wifi de la maison arrive jusque là).\\ | + | |
- | Mais le système permet de faire des automatismes en local, ce qui le rend auto-suffisant. Dans mon cas, Home Assistant ne serait là que pour collecter des données, changer des paramètres, | + | |
- | Une autre option serait d'abandonner ESPHome, de continuer avec des ESP32, mais de la gamme C6 (haute performances) | + | Connection to the server would be done over wifi (I'll have to check if house wifi also cover the garage). |
- | De plus ces deux modèles sont aussi compatibles | + | |
- | ===== Choix matériel électronique | + | What's cool is that the microcontroller can do standalone automation. The connection to home assistant would only serve to get sensor readings, change settings, modify automation or be used as remote for lights. |
- | Je me suis basé sur le listing du site ESPHome | + | |
+ | Another solution would be to use zigbee ready ESP32 like ESP32-C6 (high performances) | ||
+ | |||
+ | Moreover those ESP32 are also Matter | ||
+ | ===== Parts selection | ||
+ | I used ESPHome' | ||
=== Core === | === Core === | ||
- | <gallery left& | + | <gallery left& |
- | C'est le système central de la mini installation, les capteurs et actionneurs s'y connectent via les différents | + | This is the core of the small home automation |
- | Ces cartes semblent souvent capables de supporter un large panel de tensions en alimentation. Je pense donc l'alimenter via un transfo 230V AC - 12V DC. | + | Those boards can often be powered with a large array of voltages. I'll probably use a 12V DC power brick. |
- | Certains modèles possèdent un connecteur | + | Some version of those ESP32 come with an ipex connector instead of the PCB antenna. Allowing us to move the antenna away from the ESP and to use a more efficient external antenna to get better radio signal. |
- | === Capteur lumière et UV === | + | === Light and UV sensor |
- | <gallery left& | + | <gallery left& |
- | C'est grace à lui que le core va pouvoir vérifier si la luminosité ambiante justifie l'allumage du spot extérieur. | + | This sensor will allow to check if ambient light is low enough for the spot to be turned on or not. |
- | Connecté sur le BUS I²C. | + | It talk to the MCU using I²C bus. |
- | === Capteur de présence | + | === Presence sensor |
- | <gallery left& | + | <gallery left& |
- | Comme c'est un détecteur de présence, le timer est moins utile : tant que quelqu' | + | |
- | Connecté en UART et/ou GPIO qui remonte uniquement si une présence est détectée ou non (mais ne permet pas de toucher aux paramètres, | + | As it's not a movement detector even if people stay still their presence is detected. So timer is less useful than with movement detector. It integrates some off delay to prevent tuning off then back on if people are on the outer fringe of the area covered by the detector. |
- | === Capteur température, | + | |
- | <gallery left& | + | |
- | Connecté en I²C. | + | It's connected using UART. |
- | === Actionneur lumière | + | === Temperature, |
- | <gallery left& | + | <gallery left& |
- | Connecté sur un GPIO. | + | It speaks I²C. |
- | ====== | + | === Light actuator === |
- | J'ai acheté | + | <gallery left& |
- | * 5 ESP32 " | + | |
+ | GPIO is the only language it talks. | ||
+ | ====== | ||
+ | I bought | ||
+ | * 5 ESP32 | ||
* 1 ESP32-C6 (zigbee) | * 1 ESP32-C6 (zigbee) | ||
* 1 ESP32-H2 (zigbee) | * 1 ESP32-H2 (zigbee) | ||
* 2 LD2420 (radar) | * 2 LD2420 (radar) | ||
- | * 1 LTR390 (lumière) | + | * 1 LTR390 (light) |
* 2 BME280 (t°) | * 2 BME280 (t°) | ||
- | * 5 relais avec optocoupleurs | + | * 5 relays |
- | * 2 kits solaires avec un porte li-ion | + | * 2 solar kits with 18650 socket |
- | * 1 DC-DC converter | + | * 1 DC-DC converter |
- | Ça devrait me permettre de réaliser quelques essais sans trop me prendre le choux. | + | |
===== Test001 ESPHome ===== | ===== Test001 ESPHome ===== | ||
- | Autant débuter par un truc simple sans faire non plus dans le simpliste (j'ai pas envie de juste lire/écrire des GPIO), donc récupérer les données d'un capteur de t° et les remonter au central domotique. | + | I'll start directly trying to use I²C bus. I don't want to loose time trying to read/write GPIO since it's too easy. So I'll try to plug a BME280 on the ESP32. |
- | Si j'arrive déjà à faire ça, ça veut dire que le esp32 parle via I²C au capteur et transmet les valeurs via wifi au serveur domotique. | + | |
- | Le tout sera alimenté directement par un chargeur | + | If I get that to work most of the hardest work will be done. |
+ | |||
+ | I'll directly power the whole thing using ESP32' | ||
==== Firmware ==== | ==== Firmware ==== | ||
- | Le plus complexe pour moi, c'est faire le programme. N' | + | I never used ESPHome |
- | === Initialiser le core === | + | |
- | Dans un premier temps, je suis passé par l' | + | === Initialise the ESP === |
- | Ce qui a permis d' | + | At first I used ESPHome Device Builder's GUI from my Home Assistant |
- | Mais dès que le code s'est étoffé, le raspi s'est retrouvé à bout de souffle pendant la compilation. | + | But as soon as I added some bus and sensor definitions, the rapberry pi running Home Assistant gave up on life while trying to compile code. xD |
- | Pour soulager ce pauvre raspi il a fallu installer les outils CLI ESPHome | + | To fix this, I installed |
- | === Voyons ce code === | + | === Let's take a peek at the code === |
<code yaml> | <code yaml> | ||
name: test001 | name: test001 | ||
Line 125: | Line 128: | ||
- platform: homeassistant | - platform: homeassistant | ||
id: homeassistant_time</ | id: homeassistant_time</ | ||
- | Ici on a tout le setup de base du module ESPHome, j'y ai ajouté une sync avec l' | + | We have here the basic setup of the ESP32. I added time sync because I may add some (local) automation using time of the day. And it's easy to add syncing with HA server. |
<code yaml> | <code yaml> | ||
sda: GPIO21 | sda: GPIO21 | ||
Line 132: | Line 135: | ||
id: bus_a | id: bus_a | ||
</ | </ | ||
- | On initialise le bus I²C sur les pins 21 pour SDL et 22 pour SDA et on le désigne par l' | + | Initialising the I²C bus, getting it all sweet and ready to talk with some peripherals. |
<code yaml> | <code yaml> | ||
sensor: | sensor: | ||
Line 143: | Line 146: | ||
humidity: | humidity: | ||
name: " | name: " | ||
- | On définit d' | + | We first define the kind of sensor, here a BME280 |
- | Ensuite, petite subtilité, mon capteur n'était pas détecté par l'ESP. J'ai poussé un sketch | + | Then I had to define the 0x76 address because the default one is 0x77 so the ESP couldn't establish the connection to the BME. I had to use an address sniffer |
- | Puis les différentes valeurs à remonter au serveur et le nom sous lequel les afficher. J'ai laissé les noms par défauts donnés sur le site ESPHome parce que c'est avant tout un proto, il n'est pas destiné à être utilisé tel quel. | + | Finally we define the names that will be shown in Home Assistant for the various readings made by the sensor.\\ |
==== Hardware ==== | ==== Hardware ==== | ||
- | C'est très simple de câbler un capteur | + | Wiring |
- | * GND sur GND | + | * GND on GND |
- | * 3.3V sur 3.3V | + | * 3.3V on 3.3V |
- | * SDA sur gpio 21 | + | * SDA on gpio 21 |
- | * SCL sur gpio 22 | + | * SCL on gpio 22 |
- | <gallery center& | + | <gallery center& |
==== Résultats ==== | ==== Résultats ==== | ||
- | Dans un premier temps je n'avais que ça : | + | As I said earlier the default I²C address wasn't the one used by my BME so at first I had that result |
- | <gallery center& | + | <gallery center& |
- | Après avoir corrigé l' | + | After using the right address |
- | <gallery center& | + | <gallery center& |
- | C'est officiellement un grand succès! | + | Huge success! (I'm making a note here) |
- | ==== Améliorations ==== | ||
- | Il va être nécessaire d' | ||
- | ==== Ajout LTR390 ==== | + | |
- | Ajouter le capteur lumière et UV est vraiment | + | ==== Adding a LTR390 ==== |
+ | It's quite trivial | ||
<code yaml> | <code yaml> | ||
uv_index: | uv_index: | ||
Line 177: | Line 179: | ||
name: "Light Sensor Counts" | name: "Light Sensor Counts" | ||
</ | </ | ||
- | <gallery center& | + | <gallery center& |
- | Et ça fonctionne directement. | + | And it just works. |
+ | <gallery center& | ||
+ | ==== Addind a LD2420 ==== | ||
+ | This radar isn't harder to wire than the previous two devices : | ||
+ | * 3.3V on 3.3V | ||
+ | * GND on GND | ||
+ | * RX on TX0 ESP | ||
+ | * OT1 on RX0 ESP (on older LD2420 firmware TX may be on OT2) | ||
- | + | Then you need to initialize the UART. Since we already use an UART for logs, you have to keep them from mixing up. | |
- | ==== Ajout LD2420 ==== | + | <code yaml>logger: |
- | Le radar à ondes millimétriques est assez simple à raccorder physiquement, | + | id: logz |
- | * 3.3V sur 3.3V | + | […] |
- | * GND sur GND | + | uart: |
- | * RX sur TX0 coté ESP | + | tx_pin: |
- | * OT2 ou OT1 (en fonction de la version de firmware) sur RX0 coté ESP | + | rx_pin: |
- | Si on rajoute un cinquième fil, on peut avoir le retour sur GPIO de la présence détectée ou non et éventuellement pouvoir utiliser des modes plus économes en énergie sur l'ESP avec le GPIO qui vient le réveiller. Dans mon cas, pas très utile, le montage ne tournant pas sur batterie. | + | |
- | + | ||
- | Il faut d' | + | |
- | <code yaml> | + | |
- | tx_pin: | + | |
- | rx_pin: | + | |
baud_rate: 115200 | baud_rate: 115200 | ||
+ | id: radar | ||
</ | </ | ||
- | Ensuite, le code pour le module n'est pas extrêmement complexe (c'est principalement attribuer à des variables | + | That prevents from getting logs on the sensor channel and inversely.\\ |
- | <code yaml> | + | I' |
- | text_sensor: | + | The rest of the code isn't complex but there are a lot of parameters so it's quite lengthier than the previous devices. Moreover it's the default code I found on ESPHome website I did no change on it. So as of now, I'll only put what I change in the code to prevent having boring large slabs of code everywhere. |
- | - platform: ld2420 | + | |
- | fw_version: | + | |
- | name: LD2420 Firmware | + | |
- | sensor: | + | So, with all this the sensor |
- | - platform: ld2420 | + | I guess in an open space like in front of the garage and with a well calibrated sensor it should return more accurate readings. |
- | moving_distance: | + | |
- | name : Moving Distance | + | |
- | binary_sensor: | + | ==== Automation ==== |
- | - platform: ld2420 | + | |
- | has_target: | + | |
- | name: Presence | + | |
- | select: | + | ===== Now the same using zigbee ===== |
- | - platform: ld2420 | + | I want to evaluate how harder it would be to make the same device using " |
- | operating_mode: | + | Because most of my current devices are using that radio communications, so it would be great to keep going with it. |
- | name: Operating Mode | + | |
- | number: | + | |
- | - platform: ld2420 | + | |
- | presence_timeout: | + | |
- | name: Detection Presence Timeout | + | |
- | min_gate_distance: | + | |
- | name: Detection Gate Minimum | + | |
- | max_gate_distance: | + | |
- | name: Detection Gate Maximum | + | |
- | + | ||
- | gate_select: | + | |
- | name: Select Gate to Set | + | |
- | still_threshold: | + | |
- | name: Set Still Threshold Value | + | |
- | move_threshold: | + | |
- | name: Set Move Threshold Value | + | |
- | + | ||
- | gate_move_sensitivity: | + | |
- | name: Move Calibration Sensitivity Factor | + | |
- | gate_still_sensitivity: | + | |
- | name: Still Calibration Sensitivity Factor | + | |
- | </ | + | |
- | ===== On garde globalement les mêmes, mais en zigbee ===== | + | |
- | Ouais, pour tester et comparer le rapport emmerdement/ | + | |
- | J' | + |