Outils pour utilisateurs

Outils du site


start:arduino:esp32:smarthome

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
start:arduino:esp32:smarthome [2023/04/28 18:24] – [Test Capteur_Temp] gerardadminstart:arduino:esp32:smarthome [2023/12/10 10:26] (Version actuelle) – [GPIO ESP32 Et Capteurs/Actionneurs] gerardadmin
Ligne 16: Ligne 16:
 ===== GPIO ESP32 Et Capteurs/Actionneurs ===== ===== GPIO ESP32 Et Capteurs/Actionneurs =====
  
 +    *GPIO 05 => SERVO Fenetre
     *GPIO 12 => LED     *GPIO 12 => LED
-    *GPIO 16 => Bouton Gauche +    *GPIO 13 => SERVO Porte Avant
-    *GPIO 27 => Bouton Droit+
     *GPIO 14 => PIR(Detection presence ON=1 OFF=0)     *GPIO 14 => PIR(Detection presence ON=1 OFF=0)
-    *GPIO 25 => BUZZER +    *GPIO 16 => Bouton Gauche 
-    *GPIO 13 => SERVO Porte Avant  +    *GPIO 17 => DHT11 Temperature
-    *GPIO 05 => SERVO Fenetre +
-    *GPIO 34 => Capteur Humidite +
-    *GPIO 26 => LED Neopixel (4)+
     *GPIO 18 => Ventilateur Sens 1     *GPIO 18 => Ventilateur Sens 1
     *GPIO 19 => Ventilateur Sens 2     *GPIO 19 => Ventilateur Sens 2
 +    *GPIO 21=SDA => I2C(1)
 +    *GPIO 22=SCL => I2C(1)
     *GPIO 23 => Gaz     *GPIO 23 => Gaz
-    *GPIO 17 => DHT11 Temperature +    *GPIO 25 => BUZZER 
-    *I2C  0x27 => Afficheur +    *GPIO 26 => LED Neopixel (4 leds RVB) 
-    *I2C  0x28 => RFID , Carte = 131233147231 , Badge = 243636633+    *GPIO 27 => Bouton Droit 
 +    *GPIO 34 => Capteur Humidite 
 +    *I2C  0x27 => Afficheur : LCD 16X2  
 +    *I2C  0x28 => RFID MFRC522 , Carte = 131233147231 , Badge = 243636633 
 + 
 +{{ :start:arduino:esp32:capture_d_ecran_du_2023-12-10_10-17-41.png?direct&600 |}} 
 + 
 +{{ :start:arduino:esp32:capture_d_ecran_du_2023-12-10_10-20-32.png?direct&600 |}} 
  
 ==== Test Variation LED ==== ==== Test Variation LED ====
Ligne 592: Ligne 599:
       {       {
         boolean btn_val = digitalRead(btn1);         boolean btn_val = digitalRead(btn1);
 +        {
         if(btn_val == 1)  //If the button is released         if(btn_val == 1)  //If the button is released
           btn_count++;    //Automatically increments by 1 to count the clicked button times            btn_count++;    //Automatically increments by 1 to count the clicked button times 
Ligne 877: Ligne 885:
 //********************************************************************************** //**********************************************************************************
  
 +</code>
 +
 +
 +==== Test Password avec Bouton ====
 +
 +<code c Test_password_bouton.ino>
 +#include <Wire.h>
 +#include <LiquidCrystal_I2C.h>
 +LiquidCrystal_I2C mylcd(0x27,16,2);
 +#include "OneButton.h"
 +// Setup a new OneButton on pin 16.  
 +OneButton button1(16, true);
 +// Setup a new OneButton on pin 27.  
 +OneButton button2(27, true);
 +#include <ESP32_Servo.h>
 +Servo myservo;
 +int servoPin = 13;
 +String password = "";
 +String correct_p = "-.-";  //The correct password for the password door
 +
 +// setup code here, to run once:
 +void setup() {
 +  Serial.begin(115200);
 +  mylcd.init();
 +  mylcd.backlight();
 +  // link the button 1 functions.
 +  button1.attachClick(click1);
 +  button1.attachLongPressStop(longPressStop1);
 +  // link the button 2 functions.
 +  button2.attachClick(click2);
 +  button2.attachLongPressStop(longPressStop2);
 +
 +  myservo.attach(servoPin);
 +  mylcd.setCursor(0, 0);
 +  mylcd.print("Enter password");
 +}
 +
 +void loop() {
 +  // keep watching the push buttons:
 +  button1.tick();
 +  button2.tick();
 +  delay(10);
 +}
 +
 +// ----- button 1 callback functions
 +// This function will be called when the button1 was pressed 1 time (and no 2. button press followed).
 +void click1() {
 +  Serial.print(".");
 +  password = password + '.';
 +  mylcd.setCursor(0, 1);
 +  mylcd.print(password);
 +} // click1
 +
 +// This function will be called once, when the button1 is released after being pressed for a long time.
 +void longPressStop1() {
 +  Serial.print("-");
 +  password = password + '-';
 +  mylcd.setCursor(0, 1);
 +  mylcd.print(password);
 +} // longPressStop1
 +
 +// ... and the same for button 2:
 +void click2() {
 +  Serial.println(password);
 +  if(password == correct_p)
 +  {
 +    myservo.write(180);  //Open the door if the password is correct
 +    mylcd.clear();
 +    mylcd.setCursor(0, 0);
 +    mylcd.print("open");
 +  }
 +  else
 +  {
 +    mylcd.clear();
 +    mylcd.setCursor(0, 0);
 +    mylcd.print("error");
 +    delay(2000);
 +    mylcd.clear();
 +    mylcd.setCursor(0, 0);
 +    mylcd.print("input again");
 +  }
 +  password = "";
 +} // click2
 +
 +void longPressStop2() {
 +  //Serial.println("Button 2 longPress stop");
 +   myservo.write(0);  //Close the door
 +   mylcd.clear();
 +   mylcd.setCursor(0, 0);
 +   mylcd.print("close");
 +} // longPressStop2
 </code> </code>
  
/home/chanteri/www/fablab37110/data/attic/start/arduino/esp32/smarthome.1682699046.txt.gz · Dernière modification : 2023/04/28 18:24 de gerardadmin