             }
         }
     }
+}
+
+float get_temperature_value()
+{
+    int sensor_value;
+    float resistance = 0.0f;
+    sensor_value = analogRead(TEMPERATURE_SENSOR);
+    // temperature mapping to celsius
+    resistance=(float)(1023-sensor_value)*10000/sensor_value;
+    return 1/(log(resistance/10000)/THERMISTOR_VALUE+1/298.15)-273.15;
+}
+
+float get_voltage_value()
+{
+    // voltage probing (takes 2s)
+    long sum=0;
+    for(int i=0;i<1000;i++)
+    {  
+        sum=voltage_value+sum;
+        voltage_value=analogRead(VOLTAGE_SENSOR);
+        delay(2);
+    }   
+    // voltage mapping
+    return 10*(sum/1000)*4980/(1023.00*1000) * (12.96/14.07); // voltmeter used to determine last factor
+}
+
+void set_led_bar()
+{
+    // set led bar accordingly to solar value
+    led_bar_value = round((voltage_value-10.0)/4.0*10); // min: 10V max: 14V
+    led_bar_value = max(min(led_bar_value,10),0); // make sure led_bar_value is in range 0-10
+    led_bar.set_LED_Range(1,led_bar_value);
 }
            Serial.print(", \"plant3_value\": ");
            Serial.print(plant3_value);
            Serial.print(", \"battery_value\": ");
            Serial.print(battery_value);
            Serial.print(", \"light_value\": ");
            Serial.print(light_value);
            Serial.print(", \"temperature_value\": ");
            Serial.print(temperature);
            Serial.println(" }");
        }


#include "LED_Bar.h"
#include <math.h>

// analog sensor mapping
#define PLANT_SENSOR_1 A0
#define PLANT_SENSOR_2 A1
#define PLANT_SENSOR_3 A2
#define VOLTAGE_SENSOR A3
#define LIGHT_SENSOR A4
#define TEMPERATURE_SENSOR A5

#define THERMISTOR_VALUE 3975 //B value of the thermistor

LED_Bar led_bar;

int led_pin = 3;
int relay_pin = 4;
