#include #include #include #include WiFiMulti wifiMulti; const char* ssid = "OSU_Access"; const char* password = ""; int dryValue = 4095; int wetValue = 1358; int percentageDryValue = 0; int percentageWetValue = 100; const char *server = "https://web.engr.oregonstate.edu/~ariasmai/ENGR%20103/MoisturePercentagePost.php"; String postData; String postVariable = "MoisturePercentage="; WiFiClient client; void setup() { Serial.begin(115200); WiFi.begin(ssid,password); Serial.print("Connecting to WiFi"); while (WiFi.status() != WL_CONNECTED) { Serial.print("."); delay(500); } Serial.println("Connected to the WiFi network"); Serial.print("IP address "); Serial.println(WiFi.localIP()); } void loop() { HTTPClient http; int rawValue = analogRead(34); Serial.print("Raw Sensor Value: "); Serial.print(rawValue); Serial.print(" | "); float percentageValue = map(rawValue, dryValue, wetValue, percentageDryValue, percentageWetValue); Serial.print("MoisturePercentage = "); Serial.print(percentageValue); Serial.println("%"); delay(100); String result; if ((percentageValue >= 41) && (percentageValue <= 80)) { result = "1"; } else if ((percentageValue <= 40)) { result = "2"; } else { result = "3"; } postData = postVariable + result; http.begin("https://web.engr.oregonstate.edu/~ariasmai/ENGR%20103/MoisturePercentagePost.php"); http.addHeader("Content-Type", "application/x-www-form-urlencoded"); int httpCode = http.POST(postData); //Serial.println(httpCode); if(httpCode > 0 ) { if(httpCode == HTTP_CODE_OK){ String payload = http.getString(); Serial.println(payload); } else { Serial.printf("[HTTP] GET... code: %d\n", httpCode); } http.end(); // End this Request } delay(100); }