From 771223dd74d09c67ca94919adf9b69ccfe8372fd Mon Sep 17 00:00:00 2001 From: Roy Joseph Argumido <57471158+rjargumido@users.noreply.github.com> Date: Fri, 20 Mar 2020 18:55:46 +0800 Subject: [PATCH] Delete wifiLeaf.ino --- Individual Systems/wifiLeaf/wifiLeaf.ino | 120 ----------------------- 1 file changed, 120 deletions(-) delete mode 100644 Individual Systems/wifiLeaf/wifiLeaf.ino diff --git a/Individual Systems/wifiLeaf/wifiLeaf.ino b/Individual Systems/wifiLeaf/wifiLeaf.ino deleted file mode 100644 index da3b009..0000000 --- a/Individual Systems/wifiLeaf/wifiLeaf.ino +++ /dev/null @@ -1,120 +0,0 @@ -/* - The S.A.R.I.B.O. Leaf Module - NodeMCU 12E esp8266 Module Code - Systematic and Automated Regulation of Irrigation systems for Backyard farming Operations - Version 1.02.04 Revision March 18, 2020 - - SARIBO PROTOTYPE FOR WIFI COMMUNICATION - LEAF MODULE - Compatible to SARIBO Version 1.02.04 and higher - Revision March 20, 2020 - - BSD 3-Clause License - Copyright (c) 2020, Roy Joseph Argumido (rjargumido@outlook.com) - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - 3. Neither the name of the copyright holder nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include - -WiFiClient client; - -const char* wifiName = "SARIBO Server - Argumido"; -const char* wifiPass = "1234567890"; -const char * host = "192.168.4.1"; -const int port = 80; - -const size_t capacity = JSON_OBJECT_SIZE(5); -DynamicJsonDocument data(capacity); - - -void setup() { - Serial.begin(115200); - delay(10); - - WiFi.mode(WIFI_STA); - WiFi.begin(wifiName, wifiPass); - - while (WiFi.status() != WL_CONNECTED) { - Serial.print("Conecting to "); - Serial.print(wifiName); - Serial.println("..."); - delay(250); - } -} - -void loop() { - String payload = ""; - - Serial.print("Connecting to "); - Serial.print(host); - Serial.print(" @ port "); - Serial.println(port); - if (!client.connect(host, port)) { - Serial.println("Error establishing connection to "); - Serial.print(host); - Serial.print(" @ port "); - Serial.println(port); - return; - } - - data["datesent"] = "April+1,+2020"; - data["timesent"] = "10:32:24+PM"; - data["origin"] = "92EC9416"; - data["request"] = 11; - data["value"] = 678; - - serializeJson(data, payload); - - String url = "/data/?value=" + payload; - - // This will send the request to the server - client.print(String("GET ") + url + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n"); - - unsigned long timeout = millis(); - while(client.available() == 0) { - Serial.println("Can't find Server! Reconnecting..."); - if(millis() - timeout == 1000) { - Serial.println("Server timeout: 1 second."); - } else if(millis() - timeout == 2000) { - Serial.println("Server timeout: 2 seconds."); - } else if(millis() - timeout == 3000) { - Serial.println("Server timeout: 3 seconds."); - } else if(millis() - timeout == 4000) { - Serial.println("Server timeout: 4 seconds."); - } else if(millis() - timeout == 5000) { - Serial.print("Unable to establish connection to the Server!\n Terminating connection to ."); - Serial.print(wifiName); - client.stop(); - Serial.print("Disconnected to server."); - return; - } - } - - Serial.print("Data sent: "); - Serial.println(payload); - delay(1000); -}