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 | ||
esp32 [2018/01/02 22:07] 88.164.131.165 [Installation de l'environnement de développement] |
esp32 [2020/12/31 10:48] 91.175.66.34 [ESP32 ARDUINO] |
||
---|---|---|---|
Ligne 10: | Ligne 10: | ||
* Intègre un microcontrôleur 32 bits performants et de nombreux périphériques (ADC **12bit**, DAC, 3xUART, PWM, I2C, SPI, etc ...) | * Intègre un microcontrôleur 32 bits performants et de nombreux périphériques (ADC **12bit**, DAC, 3xUART, PWM, I2C, SPI, etc ...) | ||
* S'alimente directement en USB | * S'alimente directement en USB | ||
- | * etc ... | + | * etc. |
{{::esp32-wroom.jpg?200|}} | {{::esp32-wroom.jpg?200|}} | ||
Ligne 42: | Ligne 42: | ||
===== Brochage ===== | ===== Brochage ===== | ||
+ | |||
+ | ==== PINOUT ==== | ||
+ | |||
+ | {{::esp32_pinout.jpg?direct}} | ||
+ | {{::esp32_oled_pinout.jpg?direct}} | ||
==== ESP-WROOM-32 ==== | ==== ESP-WROOM-32 ==== | ||
Ligne 79: | Ligne 84: | ||
* Vérifier la compilation et le transfert | * 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 86: | Ligne 204: | ||
* [[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|}} | ||