#include <Arduino.h>

#include <WiFi.h>
#include <WiFiMulti.h>

#include <HTTPClient.h>

#define USE_SERIAL Serial

WiFiMulti wifiMulti;

void setup() {

// Established pinmode setup for rgb pins
pinMode(OUTPUT,32);
pinMode(OUTPUT,33);

    Serial.begin(115200);

    
//connects to ssid and empty password

    wifiMulti.addAP("OSU_Access", "");

}

void loop() {
  
    // wait for WiFi connection
    // Connects to the html file and gets the data
    if((wifiMulti.run() == WL_CONNECTED)) {

        HTTPClient http;
        http.begin("https://web.engr.oregonstate.edu/~sakatac/myData.csv"); //HTTP
        int httpCode = http.GET();
    // if the payload is found it will print it. This can be found on the Serial Monitor
 if(httpCode == HTTP_CODE_OK) {
        String payload = http.getString();
          }

 

  
//int Kelvin = (((float(payload) / 1023) * 5) * 100);
//int Celsius = Kelvin - 273.15;
int (payload);
//takes the payload and converts the payload into farenheit. Celsius to Farenheit. 
int Fahrenheit = (int(payload) * 1.8) + 32;

Serial.println(Fahrenheit);

 //if the temperture is above 75 then it will display a light and also a different color when its below 75
if (Fahrenheit>75) {
  digitalWrite(HIGH,32);
  digitalWrite(LOW,32) ;
  
} else if (Fahrenheit<75) {
  digitalWrite(HIGH,33);
  digitalWrite(LOW,33) ;
   
  }
    }
}
  
