Compare commits
	
		
			6 Commits
		
	
	
		
			670a8a3c86
			...
			dd52c93675
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| dd52c93675 | |||
| 90b6e93e41 | |||
| 5b43ce94b6 | |||
| dd9301b14e | |||
| a856e1c96b | |||
| 6250b49538 | 
							
								
								
									
										22
									
								
								README.org
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								README.org
									
									
									
									
									
								
							| @ -25,4 +25,24 @@ | ||||
|   cat /dev/ttyACM0 | ||||
| #+END_SRC | ||||
| 
 | ||||
|    If you get a /Permission denied/, try running the command as a superuser (e.g. *sudo*)  | ||||
|    If you get a /Permission denied/, you have to add your user to the group of the serial port (in this case /dev/ttyACM0). | ||||
|     | ||||
|    To check the group of the device: | ||||
| 
 | ||||
| #+BEGIN_SRC sh | ||||
|   ls -la /dev/ttyACM0 | ||||
| #+END_SRC | ||||
| 
 | ||||
|    Then add your user to the group (in this case the group is dialout and the user is user) | ||||
| 
 | ||||
| #+BEGIN_SRC sh | ||||
|   sudo usermod -aG dialout user | ||||
| #+END_SRC | ||||
| 
 | ||||
| ** ESP8266 | ||||
|     | ||||
|    During the *Week 4*, we used the NodeMCU instead of the Arduino uno, in this case to compile and upload the sketch (in this case we'll use the sketch Test): | ||||
| 
 | ||||
| #+BEGIN_SRC sh | ||||
|   ./compile_mcu.sh Test | ||||
| #+END_SRC | ||||
|  | ||||
							
								
								
									
										
											BIN
										
									
								
								Week 4/Blink/Blink.esp8266.esp8266.nodemcuv2.bin
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Week 4/Blink/Blink.esp8266.esp8266.nodemcuv2.bin
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Week 4/Blink/Blink.esp8266.esp8266.nodemcuv2.elf
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Week 4/Blink/Blink.esp8266.esp8266.nodemcuv2.elf
									
									
									
									
									
										Executable file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										14
									
								
								Week 4/Blink/Blink.ino
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								Week 4/Blink/Blink.ino
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,14 @@ | ||||
| #define LED_BUILTIN D4 | ||||
| 
 | ||||
| void setup() { | ||||
|   pinMode(LED_BUILTIN,OUTPUT); | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| void loop() { | ||||
|   digitalWrite(LED_BUILTIN,LOW); | ||||
|   delay(1000); | ||||
| 
 | ||||
|   digitalWrite(LED_BUILTIN,HIGH); | ||||
|   delay(1000); | ||||
| } | ||||
							
								
								
									
										
											BIN
										
									
								
								Week 4/DHT11 HTTP/DHT11 HTTP.esp8266.esp8266.nodemcuv2.bin
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Week 4/DHT11 HTTP/DHT11 HTTP.esp8266.esp8266.nodemcuv2.bin
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Week 4/DHT11 HTTP/DHT11 HTTP.esp8266.esp8266.nodemcuv2.elf
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Week 4/DHT11 HTTP/DHT11 HTTP.esp8266.esp8266.nodemcuv2.elf
									
									
									
									
									
										Executable file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										94
									
								
								Week 4/DHT11 HTTP/DHT11 HTTP.ino
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										94
									
								
								Week 4/DHT11 HTTP/DHT11 HTTP.ino
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,94 @@ | ||||
| #include <DHT.h> | ||||
| #include <DHT_U.h> | ||||
| #include <ESP8266WiFi.h> | ||||
| 
 | ||||
| #define DHTPIN D2 | ||||
| #define DHTTYPE DHT11 | ||||
| 
 | ||||
| const char* ssid     = "FundamentosRedes"; | ||||
| const char* password = "00000005"; | ||||
| 
 | ||||
| const char* host = "192.168.10.155"; | ||||
| const uint16_t port = 80; | ||||
| 
 | ||||
| DHT dht(DHTPIN, DHTTYPE); | ||||
| 
 | ||||
| void setup() { | ||||
|   // put your setup code here, to run once:
 | ||||
| Serial.begin(9600); | ||||
| dht.begin(); | ||||
| 
 | ||||
| Serial.println(); | ||||
| Serial.println(); | ||||
| Serial.print("CONECTANDO A.... "); | ||||
| Serial.println(ssid); | ||||
| 
 | ||||
| //WiFi.mode(WIFI_STA);
 | ||||
| WiFi.begin(ssid, password); | ||||
| 
 | ||||
| while (WiFi.status() != WL_CONNECTED) { | ||||
|  delay(500); | ||||
|  Serial.print("."); | ||||
| } | ||||
| 
 | ||||
| Serial.println(""); | ||||
| Serial.println("WiFi CONECTADA"); | ||||
| Serial.println("IP address: "); | ||||
| Serial.println(WiFi.localIP()); | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| void loop() { | ||||
| // obtenemos valores dht11
 | ||||
| 
 | ||||
| delay(2000); | ||||
| float humedad = dht.readHumidity(); | ||||
| float temperatura = dht.readTemperature(); | ||||
| Serial.print(F("Humedad:")); | ||||
| Serial.print(humedad); | ||||
| Serial.print(F("% Temperatura: :")); | ||||
| Serial.print(temperatura); | ||||
| Serial.println(F("ºC")); | ||||
| 
 | ||||
| Serial.print("CONECTANDO A.."); | ||||
| Serial.println(host); | ||||
| 
 | ||||
|   // Use WiFiClient class to create TCP connections
 | ||||
|   WiFiClient client; | ||||
|   if (!client.connect(host, port)) { | ||||
|     Serial.println("connection failed"); | ||||
|     return; | ||||
|   } | ||||
| 
 | ||||
|   //Creamos la URL para mandar al servidor 
 | ||||
|   String url = "/NODEMCU/DHT11/DHT11.php"; | ||||
|   String Temperatura = "?Temperatura="; | ||||
|   String Humedad = "&Humedad="; | ||||
| 
 | ||||
|   client.print(String("GET ") + url + Temperatura + temperatura + Humedad + humedad + " HTTP/1.1\r\n" + | ||||
|               "Host: " + host +"\r\n" + | ||||
|               "Connection: close\r\n\r\n"); | ||||
|   unsigned long timeout = millis(); | ||||
|   while (client.available() == 0){ | ||||
|     if (millis() - timeout > 5000) { | ||||
|       Serial.println(">>> Servidor Timeout !!!");   | ||||
|       client.stop(); | ||||
|       return; | ||||
|     }   | ||||
|   } | ||||
| 
 | ||||
|   while (client.available()){ | ||||
|     String line = client.readStringUntil('\r'); | ||||
|     Serial.print(line);   | ||||
|   } | ||||
| 
 | ||||
|   Serial.println(); | ||||
|   Serial.println("Cerrando conexión"); | ||||
| 
 | ||||
|   delay(60000); | ||||
|    | ||||
|    | ||||
|   // put your main code here, to run repeatedly:
 | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
							
								
								
									
										
											BIN
										
									
								
								Week 4/Screen/Screen.esp8266.esp8266.nodemcuv2.bin
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Week 4/Screen/Screen.esp8266.esp8266.nodemcuv2.bin
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Week 4/Screen/Screen.esp8266.esp8266.nodemcuv2.elf
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Week 4/Screen/Screen.esp8266.esp8266.nodemcuv2.elf
									
									
									
									
									
										Executable file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										23
									
								
								Week 4/Screen/Screen.ino
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								Week 4/Screen/Screen.ino
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,23 @@ | ||||
| #include <Wire.h> | ||||
| #include <LiquidCrystal_I2C.h> | ||||
| 
 | ||||
| //CREAMOS EL OBJETO LCD CON LA DIRECCIÓN ESCANEADA 0X27, 16 COLUMNAS Y 2 FILAS
 | ||||
| LiquidCrystal_I2C lcd(0x27,16,2); | ||||
| 
 | ||||
| void setup() { | ||||
|   // Inicializar el LCD
 | ||||
|   lcd.init(); | ||||
|   //Encender la luz de fondo.
 | ||||
|   lcd.backlight(); | ||||
|   // Escribimos el Mensaje en el LCD.
 | ||||
|   lcd.print("Hola Mundo"); | ||||
| } | ||||
| 
 | ||||
| void loop() { | ||||
|   //Ubicamos el cursor en la primera posición(columna:0) de la segunda línea(fila:1)
 | ||||
|   lcd.setCursor(0, 1); | ||||
|   // Escribimos el número de segundos transcurridos
 | ||||
|   lcd.print(millis()/1000); | ||||
|   lcd.print(" Segundos"); | ||||
|   delay(100); | ||||
| } | ||||
							
								
								
									
										
											BIN
										
									
								
								Week 4/WiFi/WiFi.esp8266.esp8266.nodemcuv2.bin
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Week 4/WiFi/WiFi.esp8266.esp8266.nodemcuv2.bin
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Week 4/WiFi/WiFi.esp8266.esp8266.nodemcuv2.elf
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Week 4/WiFi/WiFi.esp8266.esp8266.nodemcuv2.elf
									
									
									
									
									
										Executable file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										33
									
								
								Week 4/WiFi/WiFi.ino
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								Week 4/WiFi/WiFi.ino
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,33 @@ | ||||
| #include <ESP8266WiFi.h> | ||||
| 
 | ||||
| const char* ssid     = "FundamentosRedes"; | ||||
| const char* password = "00000005"; | ||||
| 
 | ||||
| void setup() { | ||||
|   Serial.begin(115200); | ||||
|   Serial.println(""); | ||||
|   Serial.print("CONECTANDO A SSID:"); | ||||
|   Serial.println(ssid); | ||||
| 
 | ||||
|   WiFi.begin(ssid, password); | ||||
| 
 | ||||
|   while (WiFi.status() != WL_CONNECTED) { | ||||
|     delay(500); | ||||
|     Serial.print("."); | ||||
|   } | ||||
|   Serial.print("Conectado. Dirección IP: "); | ||||
|   Serial.println(WiFi.localIP()); | ||||
| } | ||||
| 
 | ||||
| void loop() { | ||||
|   if( WiFi.status() == WL_CONNECTED){ | ||||
|     Serial.println(""); | ||||
|     Serial.print("Conectado. Dirección IP: "); | ||||
|     Serial.println(WiFi.localIP()); | ||||
|   } | ||||
|   else{ | ||||
|     Serial.println(""); | ||||
|     Serial.println("WiFi no conectada"); | ||||
|   } | ||||
|   delay(1000); | ||||
| } | ||||
							
								
								
									
										
											BIN
										
									
								
								Week 4/Wifi-Scan/Wifi-Scan.esp8266.esp8266.nodemcuv2.bin
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Week 4/Wifi-Scan/Wifi-Scan.esp8266.esp8266.nodemcuv2.bin
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Week 4/Wifi-Scan/Wifi-Scan.esp8266.esp8266.nodemcuv2.elf
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Week 4/Wifi-Scan/Wifi-Scan.esp8266.esp8266.nodemcuv2.elf
									
									
									
									
									
										Executable file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										40
									
								
								Week 4/Wifi-Scan/Wifi-Scan.ino
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								Week 4/Wifi-Scan/Wifi-Scan.ino
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,40 @@ | ||||
| #include "ESP8266WiFi.h" | ||||
| 
 | ||||
| void setup() { | ||||
|   Serial.begin(115200); | ||||
|  //CONFIGURAMOS LA WIFI EN MODO ESTACIÓN Y DESCONECTAMOS DEL ACCES POINT SI PREVIAMENTE ESTABA CONECTADO A UN AP.
 | ||||
|   WiFi.mode(WIFI_STA); | ||||
|   WiFi.disconnect(); | ||||
|   delay(100); | ||||
|   Serial.println("Configuración Wifi realizada"); | ||||
| } | ||||
| 
 | ||||
| void loop() { | ||||
|   Serial.println("Escaneo de Redes Wifi:"); | ||||
|   // La función scanNetwoks() nos devuelve el número de redes encontradas.
 | ||||
|   int n = WiFi.scanNetworks(); | ||||
|   Serial.println("Escaneo Realizado"); | ||||
|   // si n=0 es que no hemos encontrado ninguna red wifi
 | ||||
|   if (n == 0) { | ||||
|     Serial.println("Ninguna red encontrada"); | ||||
|   } | ||||
|  else { | ||||
|     Serial.print(n); | ||||
|     Serial.println(" Redes Wifi encontradas:"); | ||||
|     for (int i = 0; i < n; ++i) { | ||||
|       //Imprimimos el SSDI de cada red wifi encontrada
 | ||||
|       Serial.print(i + 1); | ||||
|       Serial.print(": "); | ||||
|       Serial.print(WiFi.SSID(i)); | ||||
|       Serial.print(" ("); | ||||
|       Serial.print(WiFi.RSSI(i)); | ||||
|       Serial.print(")"); | ||||
|       Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE) ? " " : "*"); | ||||
|       delay(10); | ||||
|     } | ||||
|   } | ||||
|   Serial.println(""); | ||||
|   // EspEramos 50.000 ms antes de repetir el escaneo. Si quisiéramos 
 | ||||
|   // realizar un solo escaneo deberíamos poner el código del look en el setup.
 | ||||
|   delay(50000); | ||||
| } | ||||
							
								
								
									
										9
									
								
								compile_mcu.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										9
									
								
								compile_mcu.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,9 @@ | ||||
| #!/bin/sh | ||||
| 
 | ||||
| if [ $# -lt 1 ]; then | ||||
|     echo "Usage: compile.sh <Project>" | ||||
| fi | ||||
| 
 | ||||
| project=$1 | ||||
| 
 | ||||
| arduino-cli compile --fqbn esp8266:esp8266:nodemcuv2 "$project" && arduino-cli upload -p /dev/ttyUSB0 --fqbn esp8266:esp8266:nodemcuv2 "$project" | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user