Compare commits
No commits in common. "dd52c93675ea8a9484f839c260ed1156e9a66207" and "670a8a3c86ed5251d5ebe7edc55357beb8467463" have entirely different histories.
dd52c93675
...
670a8a3c86
22
README.org
22
README.org
@ -25,24 +25,4 @@
|
|||||||
cat /dev/ttyACM0
|
cat /dev/ttyACM0
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
If you get a /Permission denied/, you have to add your user to the group of the serial port (in this case /dev/ttyACM0).
|
If you get a /Permission denied/, try running the command as a superuser (e.g. *sudo*)
|
||||||
|
|
||||||
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
|
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -1,14 +0,0 @@
|
|||||||
#define LED_BUILTIN D4
|
|
||||||
|
|
||||||
void setup() {
|
|
||||||
pinMode(LED_BUILTIN,OUTPUT);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop() {
|
|
||||||
digitalWrite(LED_BUILTIN,LOW);
|
|
||||||
delay(1000);
|
|
||||||
|
|
||||||
digitalWrite(LED_BUILTIN,HIGH);
|
|
||||||
delay(1000);
|
|
||||||
}
|
|
Binary file not shown.
Binary file not shown.
@ -1,94 +0,0 @@
|
|||||||
#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:
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
Binary file not shown.
Binary file not shown.
@ -1,23 +0,0 @@
|
|||||||
#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);
|
|
||||||
}
|
|
Binary file not shown.
Binary file not shown.
@ -1,33 +0,0 @@
|
|||||||
#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);
|
|
||||||
}
|
|
Binary file not shown.
Binary file not shown.
@ -1,40 +0,0 @@
|
|||||||
#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);
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
#!/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…
Reference in New Issue
Block a user