// Potentiometer is connected to GPIO 34 (Analog ADC1_CH6)
const int solarVPin = 36;
const int windVPin = 39;
const int solarPOT = 35;
const int windPOT = 27;
const int batteryPOT = 26;
const int loadPOT = 25;
// variable for storing the potentiometer value
float solarVoltage = 0;
float windVoltage = 0;
float solarSetting = 0;
float windSetting = 0;
float batterySetting = 0;
float loadSetting = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("\nHello, ESP32!");
// pinMode(potPin, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
readPower();
readManualSetting();
delay(500);
}
void readPower(){
// Reading voltage value
solarVoltage = (analogRead(solarVPin) * 6.6)/4096;
windVoltage = (analogRead(windVPin) * 6.6)/4096;
Serial.print("⚡ Voltage: ☀️");
Serial.print(solarVoltage);
Serial.print("V : 💨");
Serial.print(windVoltage);
Serial.println("V");
}
void readManualSetting(){
solarSetting = map(analogRead(solarPOT),0,4096,0,100);
windSetting = map(analogRead(windPOT),0,4096,0,100);
batterySetting = map(analogRead(batteryPOT),0,4096,0,100);
loadSetting = map(analogRead(loadPOT),0,4096,0,100);
Serial.print("💻 Setting: ☀️ ");
Serial.print(solarSetting);
Serial.print("% : 🍃 ");
Serial.print(windSetting);
Serial.print("% : 🔋 ");
Serial.print(batterySetting);
Serial.print("% : 💡 ");
Serial.print(loadSetting);
Serial.println("%");
}
/*
build_flags =
-Os
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
-DUSER_SETUP_LOADED=1
; Define the TFT driver, pins etc. here:
;-DTFT_PARALLEL_8_BIT=1
-DILI9488_DRIVER=1
-DTFT_WIDTH=320
-DTFT_HEIGHT=480
-DTFT_CS=15
-DTFT_DC=2
-DTFT_RST=4
-DTFT_MISO=19
-DTFT_MOSI=23
-DTFT_SCLK=18
-DTFT_BL=32
-DTFT_BACKLIGHT_ON=1
;-DTOUCH_CS=21
-DLOAD_GLCD=1
-DLOAD_FONT2=1
-DLOAD_FONT4=1
-DLOAD_FONT6=1
-DLOAD_FONT7=1
-DLOAD_FONT8=1
-DLOAD_GFXFF=1
-DSMOOTH_FONT=1
-DSPI_FREQUENCY=27000000
*/