/*
  Battery simulation for Green Factory

*/

float voltage_Batt_Sol;
float voltage_Batt_Wind;
float Sol_Voltage;
float Wind_Voltage;



void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  pinMode(A7, INPUT);
  pinMode(A6, INPUT);

}

void loop() {
  // We can't use bridge divider in simulation (WIP wokwi side)
  // so we cheat by giving a range of 0 to 5
  // and we tweak it by a ratio of 16/1023 (1023 bits adc, range of 0 to 16V)

  // Read ADC values
  voltage_Batt_Sol = analogRead(A6);
  voltage_Batt_Wind = analogRead(A7);

  // Calculate the "true" value 
  Sol_Voltage = ((voltage_Batt_Sol) / 1023 ) *16;
  Wind_Voltage = ((voltage_Batt_Wind) / 1023 ) *16;

  // Print of calculated values (and formatting)
  Serial.print("Solar Battery Voltage : ");
  // Serial.print(Sol_Voltage);
  Serial.print(voltage_Batt_Sol);
  Serial.print("V    |   ");
  Serial.print("Wind Battery Voltage : ");
  // Serial.print(Wind_Voltage);
  Serial.print(voltage_Batt_Wind);
  Serial.println("V");
  delay(100);
}

batteryBreakout
batteryBreakout