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 22:03] 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|}}
  
Line 14: Line 20:
 Ponemos esta URL en file > preferences > Additional Boards Manager URLs:  Ponemos esta URL en file > preferences > Additional Boards Manager URLs: 
   https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json   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 Ahora vamos a tools > Board: “Arduino Uno” y seleccionamos Boards Manager. Buscamos esp32 y damos a install
Line 29: Line 37:
  
 const char* ssid     = "pitufina";         // The SSID (name) of the Wi-Fi network you want to connect to const char* ssid     = "pitufina";         // The SSID (name) of the Wi-Fi network you want to connect to
-const char* password = "reyvisigodo";     // The password of the Wi-Fi network+const char* password = "********";     // The password of the Wi-Fi network
  
 void setup() { void setup() {
Line 65: Line 73:
 </code> </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);
 +  Serial.println("Connecting");
 +  while(WiFi.status() != WL_CONNECTED) {
 +    delay(500);
 +    Serial.print(".");
 +  }
 +  Serial.println("");
 +  Serial.print("Connected to WiFi network with IP Address: ");
 +  Serial.println(WiFi.localIP());
 + 
 +  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();
 +  }
 +}
 +</code>
  
 ====== Python ====== ====== Python ======
Line 135: Line 213:
  
 En Tools > Board: "Arduino Uno" > ESP32 Arduino  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.1612735393.txt.gz · Last modified: 2021/02/07 22:03 by jose