User Tools

Site Tools


informatica:arduino:esp32

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
informatica:arduino:esp32 [2021/02/07 20:26] joseinformatica:arduino:esp32 [2022/10/24 22:12] (current) jose
Line 1: Line 1:
-ESP32+====== Ejemplos: ====== 
 +**Estación Metereológica:**\\ 
 +https://github.com/NewbieMakerLearning/Servidor_Estacion_Meteo
  
 +====== Bateria bien montada ======
 +https://emariete.com/medidor-co2-con-bateria-bien-hecho/
 +
 +====== ESP32 ======
 {{:informatica:arduino:esp32_01.png|}} {{:informatica:arduino:esp32_01.png|}}
  
-https://randomnerdtutorials.com/install-esp32-filesystem-uploader-arduino-ide/+====== ARDUINO IDE ====== 
 +Nos descargamos la última versión de Arduino IDE, tiene que ser por encima de la 1.6
  
-/usr/share/arduino/tools+Descargamos un plugin para poder conectar con esp32:
  
-wget https://github.com/me-no-dev/arduino-esp32fs-plugin/releases/download/1.0/ESP32FS-1.0.zip+https://github.com/espressif/arduino-esp32
  
-Abrimos arduino IDE y ya nos aparece tools > ESP32 sketch data upload+https://github.com/espressif/arduino-esp32/blob/master/docs/arduino-ide/boards_manager.md 
 + 
 +Ponemos esta URL en file > preferences > Additional Boards Manager URLs:  
 +  https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json 
 + 
 +Tarda un ratillo en descargárselas 
 + 
 +Ahora vamos a tools > Board: “Arduino Uno” y seleccionamos Boards Manager. Buscamos esp32 y damos a install 
 + 
 +En Tools > Board: “Arduino Uno” > ESP32 Arduino  
 + 
 +Reiniciamos Arduino. Nos aseguramos que python apunte a python3 instalando python-is-python3 
 +  sudo apt install python-is-python3 
 + 
 +Código de ejemplo. Conecta a wifi y nos da la ip. Una vez subido tenemos que reiniciar esp32 (desconectando usb)
  
 <code> <code>
-#include "WiFi.h" + 
-  +#include <WiFi.h>        // Include the Wi-Fi library 
-const char* ssid = "yourNetworkName"; + 
-const char* password =  "yourNetworkPass"; +const char* ssid     = "pitufina";         // The SSID (name) of the Wi-Fi network you want to connect to 
- +const char* password = "********";     // The password of the Wi-Fi network 
 void setup() { void setup() {
-  +  Serial.begin(115200);         // Start the Serial communication to send messages to the computer 
-  Serial.begin(115200); +  delay(10); 
- +  Serial.println('\n'); 
 +   
 +  WiFi.begin(ssid, password);             // Connect to the network 
 +  Serial.print("Connecting to "); 
 +  Serial.print(ssid); 
 + 
 +  while (WiFi.status() != WL_CONNECTED) { // Wait for the Wi-Fi to connect 
 +    delay(500); 
 +    Serial.print('.'); 
 +  } 
 + 
 +  Serial.println('\n'); 
 +  Serial.println("Connection established!");   
 +  Serial.print("IP address:\t"); 
 +  Serial.println(WiFi.localIP());         // Send the IP address of the ESP8266 to the computer 
 +
 + 
 +void loop() {  
 +   
 +
 +</code> 
 + 
 +La salida que nos da es esta: 
 +<code> 
 +
 + 
 +Connection established! 
 +IP address: 192.168.1.97 
 + 
 +</code> 
 + 
 +HAcer petición GET y POST 
 +<code> 
 + 
 +#include <WiFi.h>        // Include the Wi-Fi library 
 +#include <HTTPClient.h> 
 + 
 +const char* ssid     = "mi_red";         // The SSID (name) of the Wi-Fi network you want to connect to 
 +const char* password = "*********";     // The password of the Wi-Fi network 
 + 
 +//Your Domain name with URL path or IP address with path 
 +String serverName = "http://192.168.1.200/esp32"; 
 + 
 +// the following variables are unsigned longs because the time, measured in 
 +// milliseconds, will quickly become a bigger number than can be stored in an int. 
 +unsigned long lastTime = 0; 
 +// Timer set to 10 minutes (600000) 
 +//unsigned long timerDelay = 600000; 
 +// Set timer to 5 seconds (5000) 
 +unsigned long timerDelay = 5000; 
 + 
 +void setup() { 
 +  Serial.begin(115200);  
   WiFi.begin(ssid, password);   WiFi.begin(ssid, password);
-  +  Serial.println("Connecting"); 
-  while (WiFi.status() != WL_CONNECTED) {+  while(WiFi.status() != WL_CONNECTED) {
     delay(500);     delay(500);
-    Serial.println("Connecting to WiFi..");+    Serial.print(".");
   }   }
 +  Serial.println("");
 +  Serial.print("Connected to WiFi network with IP Address: ");
 +  Serial.println(WiFi.localIP());
    
-  Serial.println("Connected to the WiFi network"); +  Serial.println("Timer set to 5 seconds (timerDelay variable), it will take 5 seconds before publishing the first reading."); 
- +
 + 
 +void loop() { 
 +  //Send an HTTP POST request every 10 minutes 
 +  if ((millis() - lastTime) > timerDelay) { 
 +    //Check WiFi connection status 
 +    if(WiFi.status()== WL_CONNECTED){ 
 +      HTTPClient http; 
 + 
 +      String serverPath = serverName + "?temperature=24.37"; 
 +       
 +      // Your Domain name with URL path or IP address with path 
 +      http.begin(serverPath.c_str()); 
 +       
 +      // Send HTTP GET request 
 +      int httpResponseCode = http.GET(); 
 +       
 +      if (httpResponseCode>0) { 
 +        Serial.print("HTTP Response code: "); 
 +        Serial.println(httpResponseCode); 
 +        String payload = http.getString(); 
 +        Serial.println(payload); 
 +      } 
 +      else { 
 +        Serial.print("Error code: "); 
 +        Serial.println(httpResponseCode); 
 +      } 
 +      // Free resources 
 +      http.end(); 
 +    } 
 +    else { 
 +      Serial.println("WiFi Disconnected"); 
 +    } 
 +    lastTime = millis(); 
 +  }
 } }
-  
-void loop() {} 
 </code> </code>
  
Line 91: Line 201:
 Hard resetting via RTS pin... Hard resetting via RTS pin...
 </code> </code>
 +
 +====== Arduino IDE ======
 +https://github.com/espressif/arduino-esp32
 +
 +https://github.com/espressif/arduino-esp32/blob/master/docs/arduino-ide/boards_manager.md
 +
 +Ponemos esta URL en file > preferences > Additional Boards Manager URLs:
 +  https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json
 +
 +Ahora vamos a tools > Board: "Arduino Uno" y seleccionamos Boards Manager. Buscamos esp32 y damos a install
 +
 +En Tools > Board: "Arduino Uno" > ESP32 Arduino 
 +
 +
 +====== Energia y consumo ======
 +https://lastminuteengineers.com/esp32-sleep-modes-power-consumption/
 +
 +====== Pantalla e-paper ======
 +https://www.youtube.com/watch?v=1xQqc6ZCXdw
informatica/arduino/esp32.1612729581.txt.gz · Last modified: 2021/02/07 20:26 by jose