Seguidamente se definen el tipo de variables a utilizar y su velocidad, y se revisa si hay lectura del sensor DHT11. float tempC=0.0,Humi=0.0; LGPRSUDP u; char payload[180]; char le[4]; String response; void setup() { LTask.begin(); LWiFi.begin(); dht.begin(); Serial.begin(9600); En la siguiente excursión se procede a revisar la conexión Wi-Fi, si esta está disponible se procede a enviar los datos a Ubidots a través de Wi-Fi, en el código se definen los protocolos para él envió de los datos haca la página web de Ubidots. Serial.println("Connecting to AP"); LWiFi.connect(WIFI_AP, LWiFiLoginInfo(WIFI_AUTH, WIFI_PASSWORD)); if(!LBTServer.begin((uint8_t*)"LinkIT ING.Electronica")) { Serial.println("Fail to start BT."); return; } Serial.println("BT server is started.");
} boolean wifi_status(LWifiStatus ws){ switch(ws){ case LWIFI_STATUS_DISABLED: return false; break; case LWIFI_STATUS_DISCONNECTED: return false; break; case LWIFI_STATUS_CONNECTED: return true; break; } return false; } void loop() { if (LWIFI_STATUS_CONNECTED == true){ Serial.println("Connecting to Ubidots..."); LWiFiClient c; while (!c.connect(URL, 80)) { Serial.println("Retrying to connect..."); delay(100); } Serial.println("Connected!"); while(1) { LWifiStatus ws = LWiFi.status(); boolean status = wifi_status(ws); if(!status){ Serial.println("Connecting to AP"); while (0 == LWiFi.connect(WIFI_AP, LWiFiLoginInfo(WIFI_AUTH, WIFI_PASSWORD))) { delay(500); } } if(dht.read()) { tempC = dht.readTemperature(); Humi = dht.readHumidity(); } String payload = "{\"value\":"+ String(dht.readTemperature()) + "}"; String le = String(payload.length()); if(!c.connected()){ while (!c.connect(URL, 80)){ delay(100); } Serial.println("Client reconnected!");
} c.print(F("POST /api/v1.6/variables/")); c.print(VARID1); c.println(F("/values HTTP/1.1")); c.println(F("User-Agent: LinKit One/1.0")); c.print(F("X-Auth-Token: ")); c.println(TOKEN); c.println(F("Connection: close")); c.println(F("Content-Type: application/json")); c.print(F("Content-Length: ")); c.println(le); c.print(F("Host: ")); c.println(URL); c.println(); c.println(payload); c.println(); int v; while(c.available()){ v = c.read(); if(v < 0){ Serial.println("No response."); break; } } delay(1000); } } Si la comunicación Wi-Fi no está disponible se procede a preguntar si GPRS está disponible si es así los datos se envían directamente a través de GPRS, se debe definir el APN del operador celular que se esté utilizando en este caso se utiliza TIGO Colombia por lo que se define (web.colombiamovil.com.co) y se lleva al código de la siguiente manera:
else { Serial.println("Attach to GPRS network"); // Attach to GPRS network - need to add timeout LGPRS.attachGPRS("web.colombiamovil.com.co","",""); if(dht.read()) { tempC = dht.readTemperature(); Humi = dht.readHumidity(); } save_values(tempC); if(LBTServer.connected()) { // echo back all received data if(dht.read()) { tempC = dht.readTemperature(); Humi = dht.readHumidity(); } }
Birthday (Mi cumpleaños es el ... de .....) 5. Photo (school appropriate). 6. Proper heading (on the back of project). 7. Title on the front (Mi AUTOBIOGRAFíA).
Soy Juan Smith. It's John Smith. 3. An excuse about why you could not attend your friend Alicia's party last Saturday. ➱. You must use at least one preterite verb ...
Tuesdays 8:30 am to 9:30 am. Sept. 13, 20, 27, Oct. 4, 18, 25, Nov. 1, 8. (No class October 11). To register for classes at Madison Elementary,. Contact the Healthy Start office at. (626) 396-5782. For more information and questions, contact Brittany
Yes, please include me in the school directory! ☐ Yes! I pledge to give 2 hours to our school this year. 1. The Types of Opportunities I'm Most Interested In Are:.
attend preschool education, lag behind grades in school and drop out from schools. Segregation would also make more likely that the non student young from ...