Outils pour utilisateurs

Outils du site


start:esp32:uart

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:esp32:uart [2024/10/07 16:19] gerardadminstart:esp32:uart [2025/02/23 10:48] (Version actuelle) – [Liens web] admin
Ligne 3: Ligne 3:
 =====Liaison UART entre 2 esp32 :===== =====Liaison UART entre 2 esp32 :=====
  
-le schéma:+=== Commentaires === 
 + 
 +Le but c'est de faire clignoter une LED sur l'esp32 Slave qui sera pilotée par l'esp32  Master en envoyant 0 pour eteindre et 1 pour allumé la LED et cela via une liaison serie ou UART entre les 2 esp32 . L'UART 2 sera utilisée dans notre exemple. 
 + 
 + 
 + 
 +=== Materiels === 
 + 
 +    -- 2 ESP32 
 +    -- 1 breadboard 
 +    -- 1 Led 5 mm 
 +    -- 1 resistance 1/4w 1khoms 
 +    -- 2 PC avec ports USB ou 2 alimentations 5V 1A 
 +    -- Fils de cablage dupont 15 cm 
 +===le schéma:===
  
 ^ESPMaster^ESPSlave^ ^ESPMaster^ESPSlave^
Ligne 12: Ligne 26:
 | | GND  ( A cote P23) | | | GND  ( A cote P23) |
  
-{{:start:esp32:0uiijxnie0vv0gq7.png?direct&300 |}}+{{ :start:esp32:0uiijxnie0vv0gq7.png?direct&300 |}}
  
 +=== Programmes Master et Slave ===
  
 <code c Programme_Master.ino> <code c Programme_Master.ino>
Ligne 20: Ligne 35:
 void setup() void setup()
 { {
-SerialPort.begin(15200, SERIAL_8N1, 16, 17);+    SerialPort.begin(115200, SERIAL_8N1, 16, 17);
 } }
 void loop() void loop()
 { {
-SerialPort.print(1); +    SerialPort.print(1); 
-delay(5000); +    delay(5000); 
-SerialPort.print(0); +    SerialPort.print(0); 
-delay(5000);+    delay(5000);
 } }
 </code> </code>
Ligne 38: Ligne 53:
 void setup() void setup()
 { {
-Serial.begin(9600); +    Serial.begin(9600); 
-SerialPort.begin(15200, SERIAL_8N1, 16, 17); +    SerialPort.begin(115200, SERIAL_8N1, 16, 17); 
-pinMode(LED, OUTPUT);+    pinMode(LED, OUTPUT);
 } }
 void loop() void loop()
 { {
-if (SerialPort.available()) +    if (SerialPort.available()) 
-+    
-char number = SerialPort.read(); +       char number = SerialPort.read(); 
-if (number == '0') { +       if (number == '0') { 
-digitalWrite(LED, LOW); +       digitalWrite(LED, LOW); 
-Serial.print("0"); /* verification reception 0 */ +       Serial.print("0"); /* verification reception 0 */ 
-+       
-if (number == '1') { +       if (number == '1') { 
-digitalWrite(LED, HIGH); +          digitalWrite(LED, HIGH); 
-Serial.print("1"); /* verification reception 1 */ +          Serial.print("1"); /* verification reception 1 */ 
-+       
-}+   }
 } }
 </code> </code>
  
 <note important>NOTA important : <note important>NOTA important :
-BRANCHER les ESP32 sur des PC ou des alimentations différentes , branché sur la même alimentation cela ne fonctionne pas.... ???? +    *** BRANCHER les ESP32 sur des PC ou des alimentations différentes** , branché sur la même alimentation cela ne fonctionne pas.... ???? 
-j ai essayé à 115200 Bauds : cela fonctionne aussi +    -j ai essayé à 115200 Bauds : cela fonctionne aussi 
-J ai essayé 1 secondes pour le "delay" sur l'esp32 master : cela fonctionne .+    -J ai essayé 1 secondes pour le "delay" sur l'esp32 master : cela fonctionne .
 </note> </note>
 +
 +==== Liens web ====
 +
 +[[https://randomnerdtutorials.com/esp32-uart-communication-serial-arduino/|esp32-uart-communication-serial-arduino EN]]
 +
 +[[https://docs.espressif.com/projects/esp-idf/en/v4.3/esp32/api-reference/peripherals/uart.html|Doc UART ESP32 Expressif EN]]
 +
/home/chanteri/www/fablab37110/data/attic/start/esp32/uart.1728310785.txt.gz · Dernière modification : 2024/10/07 16:19 de gerardadmin