/*
* This sketch demonstrates how to scan WiFi networks.
* The API is almost the same as with the WiFi Shield library,
* the most obvious difference being the different file you need to include:
*/
#include "WiFi.h"
#ifdef __cplusplus
extern "C" {
#endif
uint8_t temprature_sens_read();
#ifdef __cplusplus
}
#endif
uint8_t temprature_sens_read();
int entrada_A = 27;
int entrada_B = 25;
int salida_A = 20;
int salida_B = 26;
bool A = false;
bool B = false;
void setup()
{
Serial.begin(115200);
pinMode(entrada_A, INPUT);
pinMode(entrada_B, INPUT);
pinMode(salida_A, OUTPUT);
pinMode(salida_B, OUTPUT);
// Se especifica al equipo de estación cliente y se desconecta si lo estuviera de algun AP.
WiFi.mode(WIFI_STA);
WiFi.disconnect();
delay(100);
Serial.println("Inicialización WiFi Exitosa");
btStop();
Serial.println("Stopping BT");
}
void loop()
{
scan_Red();
eco_AyB();
}
void scan_Red(){
Serial.println("Se inicia escaneo");
// La WiFi.scanNetworks retornara el número de redes WiFi encontradas.
int n = WiFi.scanNetworks();
Serial.println("Escaneo exitoso");
if (n == 0) {
Serial.println("No se encontrardon redes");
} else {
Serial.print(n);
Serial.println(" Redes encontradas");
for (int i = 0; i < n; ++i) {
// Se eimprime en la terminal de serial del IDE los SSID y el RSSI de las redes encontradas.
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) == WIFI_AUTH_OPEN)?" ":"*");
delay(10);
}
}
Serial.println("");
Serial.print("Temperature: ");
// Convert raw temperature in F to Celsius degrees
Serial.print((temprature_sens_read() - 32) / 1.8);
Serial.println(" C");
// Se espera un tiempo para realizar un nuevo reconocimiento de redes WiFi.
// delay(2000);
}
void eco_AyB(){
A = digitalRead(entrada_A);
Serial.println("Leer A");
if (A == true){
digitalWrite(salida_A, HIGH);
Serial.println("Escribir ECO de A");
if(A == false){
digitalWrite(salida_A, LOW);
}
}
B = digitalRead(entrada_B);
Serial.println("Leer B");
if (B == true){
digitalWrite(salida_B, HIGH);
Serial.println("Escribir ECO de B");
if(B == false){
digitalWrite(salida_B, LOW);
}
}
}