Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente Prochaine révision Les deux révisions suivantes | ||
esp32 [2018/01/02 00:49] 88.164.131.165 [ESP-WROOM-32] |
esp32 [2018/05/01 11:39] 88.164.131.165 [Brochage] |
||
---|---|---|---|
Ligne 42: | Ligne 42: | ||
===== Brochage ===== | ===== Brochage ===== | ||
+ | |||
+ | ==== PINOUT ==== | ||
+ | |||
+ | {{:undefined:esp32_pinout.jpg?direct|}} | ||
==== ESP-WROOM-32 ==== | ==== ESP-WROOM-32 ==== | ||
Ligne 53: | Ligne 57: | ||
==== Installation de l'environnement de développement ==== | ==== Installation de l'environnement de développement ==== | ||
[[https://projetsdiy.fr/programmer-cartes-esp32-ide-arduino-macos-windows-arm-raspberry/|Procédure d'installation de l'environnement ARDUINO]] | [[https://projetsdiy.fr/programmer-cartes-esp32-ide-arduino-macos-windows-arm-raspberry/|Procédure d'installation de l'environnement ARDUINO]] | ||
+ | |||
+ | * Installer l'environnement ARDUINO : [[https://www.arduino.cc/en/Main/Software]] | ||
+ | * Télécharger l'add-on pour l'ESP32 : [[https://github.com/espressif/arduino-esp32]] | ||
+ | * Deziper l'add-on dans le répertoire : Mes Documents\Arduino\hardware\espressif\esp32 | ||
+ | |||
+ | {{::esp32_install_directory.png?400|}} | ||
+ | |||
+ | * Executer get.exe qui se trouve dans le répetoire Mes Documents\Arduino\hardware\espressif\esp32\tools | ||
+ | * L'executable get.exe va télécharger et intégrer l'add-on dans l'environnement ARDUINO | ||
+ | |||
+ | <note>L'executable get.exe va télécharger 3 fichiers ZIP qui seront téléchargés dans le répertoire dist (esptool-4dab24e-windows.zip, mkspiffs-0.2.1-windows.zip et xtensa-esp32-elf-win32-1.22.0-75-gbaf03c2-5.2.0.zip) </note> | ||
+ | |||
+ | * Démarrer l'environnement ARDUINO et vérifier que l'ESP32 apparait bien dans les types de carte : | ||
+ | |||
+ | {{::esp32_arduino.png?400|}} | ||
+ | |||
+ | * Brancher votre carte ESP32, vérifier le port COM qui lui a été attribué : | ||
+ | |||
+ | {{::esp32_cp210x.png?200|}} | ||
+ | |||
+ | * Créer un nouveau sketch, sélectionner la carte: ESP32 Dev Module et le port qui lui a été associé | ||
+ | |||
+ | {{::esp32_arduino2.png?300|}} | ||
+ | |||
+ | * Vérifier la compilation et le transfert | ||
+ | |||
+ | ==== 1er sketch de test - clignotement LED ==== | ||
+ | |||
+ | <note>Ma carte intègre une LED sur la sortie IO2 </note> | ||
+ | |||
+ | <code> | ||
+ | void setup() { | ||
+ | // put your setup code here, to run once: | ||
+ | pinMode(2, OUTPUT); // set pin to input | ||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | // put your main code here, to run repeatedly: | ||
+ | |||
+ | digitalWrite(2, HIGH); // sets the LED on | ||
+ | delay(200); // waits for a second | ||
+ | digitalWrite(2, LOW); // sets the LED off | ||
+ | delay(800); | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | ==== Sketch exemples ==== | ||
+ | |||
+ | <note>De nombreux exemples sont fournis dans le répertoire : Documents\Arduino\hardware\espressif\esp32\libraries</note> | ||
+ | |||
+ | ==== Sketch transmission wifi ==== | ||
+ | |||
+ | Le sketch ci dessous va transmettre une trame toutes les secondes vers un serveur UDP. | ||
+ | Remplacer par **your-ssid** par le nom de votre réseau WIFI, **your-password** par le mot de passe de votre réseau WIFI et 192.168.1.10 par l'adresse IP de votre PC. | ||
+ | |||
+ | <code> | ||
+ | /* | ||
+ | * This sketch sends random data over UDP on a ESP32 device | ||
+ | * | ||
+ | */ | ||
+ | #include <WiFi.h> | ||
+ | #include <WiFiUdp.h> | ||
+ | |||
+ | // WiFi network name and password: | ||
+ | const char * networkName = "**your-ssid**"; | ||
+ | const char * networkPswd = "**your-password**"; | ||
+ | |||
+ | //IP address to send UDP data to: | ||
+ | // either use the ip address of the server or | ||
+ | // a network broadcast address | ||
+ | const char * udpAddress = "**192.168.1.10**"; | ||
+ | const int udpPort = 2205; | ||
+ | |||
+ | //Are we currently connected? | ||
+ | boolean connected = false; | ||
+ | |||
+ | //The udp library class | ||
+ | WiFiUDP udp; | ||
+ | |||
+ | void setup(){ | ||
+ | // Initilize hardware serial: | ||
+ | Serial.begin(115200); | ||
+ | | ||
+ | //Connect to the WiFi network | ||
+ | connectToWiFi(networkName, networkPswd); | ||
+ | } | ||
+ | |||
+ | void loop(){ | ||
+ | //only send data when connected | ||
+ | if(connected){ | ||
+ | //Send a packet | ||
+ | udp.beginPacket(udpAddress,udpPort); | ||
+ | udp.printf("Seconds since boot: %u", millis()/1000); | ||
+ | udp.endPacket(); | ||
+ | } | ||
+ | //Wait for 1 second | ||
+ | delay(1000); | ||
+ | } | ||
+ | |||
+ | void connectToWiFi(const char * ssid, const char * pwd){ | ||
+ | Serial.println("Connecting to WiFi network: " + String(ssid)); | ||
+ | |||
+ | // delete old config | ||
+ | WiFi.disconnect(true); | ||
+ | //register event handler | ||
+ | WiFi.onEvent(WiFiEvent); | ||
+ | | ||
+ | //Initiate connection | ||
+ | WiFi.begin(ssid, pwd); | ||
+ | |||
+ | Serial.println("Waiting for WIFI connection..."); | ||
+ | } | ||
+ | |||
+ | //wifi event handler | ||
+ | void WiFiEvent(WiFiEvent_t event){ | ||
+ | switch(event) { | ||
+ | case SYSTEM_EVENT_STA_GOT_IP: | ||
+ | //When connected set | ||
+ | Serial.print("WiFi connected! IP address: "); | ||
+ | Serial.println(WiFi.localIP()); | ||
+ | //initializes the UDP state | ||
+ | //This initializes the transfer buffer | ||
+ | udp.begin(WiFi.localIP(),udpPort); | ||
+ | connected = true; | ||
+ | break; | ||
+ | case SYSTEM_EVENT_STA_DISCONNECTED: | ||
+ | Serial.println("WiFi lost connection"); | ||
+ | connected = false; | ||
+ | break; | ||
+ | } | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | L'ESP32 va transmettre toutes les secondes une trame vers le port 3333 de votre PC. | ||
+ | Pour visualiser les trames envoyées, il suffit d'utiliser un serveur UDP comme [[https://www.hw-group.com/products/hercules/index_en.html|HERCULE]] | ||
+ | |||
+ | Démarrer HERCULE et dans l'onglet UDP mettre 3333 dans le port à utiliser puis cliquer sur "Listen" | ||
+ | |||
+ | {{::hercule_esp32.png?400|}} | ||
===== Liens utiles ===== | ===== Liens utiles ===== | ||
Ligne 60: | Ligne 203: | ||
* [[https://projetsdiy.fr/esp8266/esp32-iot/|Projets DIY - Excellent site avec pas mal d'infos en français]] | * [[https://projetsdiy.fr/esp8266/esp32-iot/|Projets DIY - Excellent site avec pas mal d'infos en français]] | ||
+ | |||
+ | Schema de la carte de developpement ESP32 DEVKIT V1 www.doit.am | ||
+ | {{::schematicsforesp32.pdf|}} | ||