meta données pour cette page
Différences
Ci-dessous, les différences entre deux révisions de la page.
| projets:maison:systeme_d_arrosage_automatique [2026/10/02 11:58] – créée - modification externe 127.0.0.1 | projets:maison:systeme_d_arrosage_automatique [2026/10/15 19:32] (Version actuelle) – Regroupement du tutoriel vers projets:electronique:systeme_d_arrosage_automatique ; anciennes révisions conservées wikiadmin | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| - | ====== Système d' | ||
| - | ^ Auteur | ||
| - | ^ Catégories | ||
| - | {{projets: | ||
| - | |||
| - | système d' | ||
| - | |||
| - | > **Licence :** CERN Open Hardware Licence v1.2 | ||
| - | |||
| - | Mot(s)-clé(s) : | ||
| - | |||
| - | ==== Introduction ==== | ||
| - | |||
| - | Ce système permet d' | ||
| - | |||
| - | ==== Liste des matériaux ==== | ||
| - | |||
| - | * Un module pompe avec capteur d' | ||
| - | |||
| - | * Un microcontrôleur type ESP32 ( = 8 €) | ||
| - | |||
| - | * Une afficheur OLED 0.91" I2C ( = 4 €) | ||
| - | |||
| - | * connecteur femelle type HY2.0 4P ( = 0.6 €) | ||
| - | |||
| - | * Fils souple (coloré) | ||
| - | |||
| - | ==== Liste des outils ==== | ||
| - | |||
| - | * Une imprimante 3D avec ces outils | ||
| - | |||
| - | * Logiciel de conception 3D (CAO) | ||
| - | |||
| - | * Ordinateur (PC, Raspberry pi 3 ou 4, ...) avec logiciel IDE Thonny | ||
| - | |||
| - | * Fer à souder et étain | ||
| - | |||
| - | * pinces de sertissage / dénudage | ||
| - | |||
| - | - {{projets: | ||
| - | - {{projets: | ||
| - | - {{projets: | ||
| - | - {{projets: | ||
| - | |||
| - | ==== Etape n°1 - câblage ==== | ||
| - | |||
| - | <WRAP group> | ||
| - | |||
| - | <WRAP half column> | ||
| - | **Choix des fils:** | ||
| - | |||
| - | * Les fils standard de câblage d' | ||
| - | |||
| - | * préférable de choisir les couleurs noir et rouge pour les alimentations et des autres couleur pour GPIO. | ||
| - | |||
| - | //NB: ce projet nécessite peu des fils (langueur total max 20 cm)// | ||
| - | |||
| - | **Câblage du ESP32 et l' | ||
| - | câbler les 3 éléments comme indiquer dans le diagramme (voir figure), utiliser des langueurs des fils la plus court possible, sachant que l' | ||
| - | </ | ||
| - | |||
| - | <WRAP half column> | ||
| - | {{projets: | ||
| - | {{projets: | ||
| - | {{projets: | ||
| - | {{projets: | ||
| - | {{projets: | ||
| - | </ | ||
| - | |||
| - | </ | ||
| - | <WRAP clear /> | ||
| - | |||
| - | ==== Etape n°2 - Boitier (impression 3D) et assemblage ==== | ||
| - | |||
| - | <WRAP group> | ||
| - | |||
| - | <WRAP half column> | ||
| - | * Le boitier du système se compose de trois parties (capot supérieur, couvercle inférieur et la partie latérale) cette décomposition facilite l' | ||
| - | |||
| - | Lien Thingiverse vers le fichier format F3D | ||
| - | [[https:// | ||
| - | |||
| - | * Le boitier peux être imprimé sans utilisation de mâtereaux support et sans paramètres particuliers. | ||
| - | |||
| - | * le boitier est des dimensions (38mm*18.5mm*14mm) permet d' | ||
| - | |||
| - | **L' | ||
| - | //M5Stamp C3 est collé sur le capot inférieur de telle façon soit accessible par USB-C du côté et on fixe de l' | ||
| - | //Enfin l' | ||
| - | </ | ||
| - | |||
| - | <WRAP half column> | ||
| - | {{projets: | ||
| - | {{projets: | ||
| - | {{projets: | ||
| - | {{projets: | ||
| - | {{projets: | ||
| - | </ | ||
| - | |||
| - | </ | ||
| - | <WRAP clear /> | ||
| - | |||
| - | ==== Etape n°3 - Programmation ==== | ||
| - | |||
| - | [[Step_Content:: | ||
| - | OLED dispaly 128*32 with I2C | ||
| - | M5STACK Watering Unit - Soil Moisture Sensor and Water Pump | ||
| - | import of libraries | ||
| - | |||
| - | < | ||
| - | from machine import Pin, SoftI2C, ADC | ||
| - | from time import sleep | ||
| - | import ssd1306 | ||
| - | import gfx | ||
| - | import framebuf | ||
| - | |||
| - | </ | ||
| - | |||
| - | Pin for moisture sensor | ||
| - | |||
| - | < | ||
| - | moisure = ADC(Pin(4)) | ||
| - | |||
| - | </ | ||
| - | |||
| - | Attenuation of the ADCA gain for analog read | ||
| - | |||
| - | < | ||
| - | moisure.atten(ADC.ATTN_11DB) | ||
| - | |||
| - | </ | ||
| - | |||
| - | Pin for pump control | ||
| - | |||
| - | < | ||
| - | pump = Pin(6, Pin.OUT) | ||
| - | |||
| - | </ | ||
| - | |||
| - | Threshold irrigation point | ||
| - | |||
| - | < | ||
| - | threshold_point = 45 | ||
| - | |||
| - | </ | ||
| - | |||
| - | I2C setup and initialisation | ||
| - | |||
| - | < | ||
| - | i2c = SoftI2C(scl = Pin(9), sda = Pin(8)) | ||
| - | |||
| - | </ | ||
| - | |||
| - | OLED object creation and setup | ||
| - | |||
| - | < | ||
| - | oled = ssd1306.SSD1306_I2C(128, | ||
| - | |||
| - | </ | ||
| - | |||
| - | bytearray of empty droplet icon | ||
| - | |||
| - | < | ||
| - | droplet = bytearray(b' | ||
| - | |||
| - | </ | ||
| - | |||
| - | bytearray of smiley face icon | ||
| - | |||
| - | < | ||
| - | smiley_face = bytearray(b' | ||
| - | |||
| - | </ | ||
| - | |||
| - | bytearray of sad face icon | ||
| - | |||
| - | < | ||
| - | sad_face = bytearray(b' | ||
| - | |||
| - | </ | ||
| - | |||
| - | bytearray of filled droplet icon | ||
| - | |||
| - | < | ||
| - | icon = [ | ||
| - | [0,0], | ||
| - | [0,0], | ||
| - | [0,0], | ||
| - | [0,0], | ||
| - | [0,0], | ||
| - | [16,2], | ||
| - | [16,2], | ||
| - | [15,4], | ||
| - | [14,6], | ||
| - | [14,6], | ||
| - | [13,8], | ||
| - | [12,10], | ||
| - | [12,10], | ||
| - | [11,12], | ||
| - | [11,12], | ||
| - | [11,12], | ||
| - | [10,14], | ||
| - | [10,14], | ||
| - | [10,14], | ||
| - | [10,14], | ||
| - | [10,14], | ||
| - | [10,14], | ||
| - | [10,14], | ||
| - | [10,14], | ||
| - | [11,12], | ||
| - | [11,12], | ||
| - | [13,8], | ||
| - | [15,4], | ||
| - | [0,0], | ||
| - | [0,0], | ||
| - | [0,0], | ||
| - | [0,0], | ||
| - | ] | ||
| - | |||
| - | </ | ||
| - | |||
| - | Creation of frame buffer from icons | ||
| - | |||
| - | < | ||
| - | frameD = framebuf.FrameBuffer(droplet, | ||
| - | frameH = framebuf.FrameBuffer(smiley_face, | ||
| - | frameS = framebuf.FrameBuffer(sad_face, | ||
| - | |||
| - | </ | ||
| - | |||
| - | defintion of values converting function in range (min, max) | ||
| - | |||
| - | < | ||
| - | def convert(x, in_min, in_max, out_min, out_max): | ||
| - | return (x - in_min) * (out_max - out_min) // (in_max - in_min) + out_min | ||
| - | |||
| - | </ | ||
| - | < | ||
| - | LmoisureLevel = [] | ||
| - | AvmoisureLevel = 0 | ||
| - | |||
| - | </ | ||
| - | |||
| - | get 50 values of moisture and calculate the average | ||
| - | |||
| - | < | ||
| - | while True: | ||
| - | moisureLevel = moisure.read() | ||
| - | LmoisureLevel.append(moisureLevel) | ||
| - | if len(LmoisureLevel) == 50: | ||
| - | AvmoisureLevel = sum(LmoisureLevel)/ | ||
| - | LmoisureLevel.pop(0) | ||
| - | AvmoisureLevel = int(AvmoisureLevel) | ||
| - | moisure_string = str(AvmoisureLevel) | ||
| - | |||
| - | </ | ||
| - | |||
| - | clear OLED display | ||
| - | |||
| - | < | ||
| - | oled.fill(0) | ||
| - | |||
| - | </ | ||
| - | |||
| - | display texte | ||
| - | |||
| - | < | ||
| - | oled.text(' | ||
| - | |||
| - | </ | ||
| - | |||
| - | Convert the analog value to moisture level (0%-100%) | ||
| - | |||
| - | < | ||
| - | AvmoisureLevel = convert(AvmoisureLevel, | ||
| - | w = int(AvmoisureLevel/ | ||
| - | |||
| - | </ | ||
| - | |||
| - | display moisture level | ||
| - | |||
| - | < | ||
| - | oled.text(str(AvmoisureLevel) +" | ||
| - | |||
| - | </ | ||
| - | |||
| - | display emplty droplet icon | ||
| - | |||
| - | < | ||
| - | oled.blit(frameD, | ||
| - | |||
| - | </ | ||
| - | |||
| - | display droplet level | ||
| - | |||
| - | < | ||
| - | for y,row in enumerate(icon): | ||
| - | for p in range(row[1]): | ||
| - | if (y < 32 - w): | ||
| - | oled.pixel(99+row[0]+p, | ||
| - | else: | ||
| - | oled.pixel(99+row[0]+p, | ||
| - | |||
| - | </ | ||
| - | |||
| - | Control pump at given threshold point and display emoji | ||
| - | |||
| - | < | ||
| - | if(AvmoisureLevel < threshold_point): | ||
| - | pump.value(1) | ||
| - | oled.blit(frameS, | ||
| - | else: | ||
| - | pump.value(0) | ||
| - | oled.blit(frameH, | ||
| - | oled.show()]] | ||
| - | |||
| - | </ | ||
| - | |||
| - | / | ||
| - | |||
| - | ===== Notes et références ===== | ||
| - | |||
| - | **Références: | ||
| - | [[https:// | ||
| - | [[https:// | ||
| - | [[https:// | ||