/*
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);
}
nano:12
nano:11
nano:10
nano:9
nano:8
nano:7
nano:6
nano:5
nano:4
nano:3
nano:2
nano:GND.2
nano:RESET.2
nano:0
nano:1
nano:13
nano:3.3V
nano:AREF
nano:A0
nano:A1
nano:A2
nano:A3
nano:A4
nano:A5
nano:A6
nano:A7
nano:5V
nano:RESET
nano:GND.1
nano:VIN
nano:12.2
nano:5V.2
nano:13.2
nano:11.2
nano:RESET.3
nano:GND.3
batt_sol:VCC
batt_sol:GND
batt_sol:Batt_pos
batt_wind:VCC
batt_wind:GND
batt_wind:Batt_pos
vcc1:VCC