// https://microcontrollerslab.com/esp32-pinout-use-gpio-pins/
// https://github.com/espressif/arduino-esp32
// https://github.com/espressif/arduino-esp32/tree/master/cores/esp32
// https://github.com/johnrickman/LiquidCrystal_I2C
//--------------------------------------------------
// Includes:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
//--------------------------------------------------
// Globals:
// LCD Objekt erzeugen
// - I2C Adresse: 0x27
// - Zeichen pro Zeile: 16
// - Anzahl Zeilen: 2
LiquidCrystal_I2C myLCD = LiquidCrystal_I2C(0x27, 16, 2);
//--------------------------------------------------
void setup() {
// Init USART:
Serial.begin(115200);
// Init LCD:
myLCD.init();
myLCD.backlight();
}
//--------------------------------------------------
void loop() {
// Read Pin 39
int32_t adc = analogRead(39);
int32_t mV = (float)adc / 4095.0 * 3300.0;
// Write USART
Serial.printf("ADC %ld, %ld mV\n", adc, mV);
// Write LCD (1. Zeile, links)
myLCD.setCursor(0, 0);
myLCD.printf("%-4ld", adc);
// Write LCD (1. Zeile, rechts)
myLCD.setCursor(13, 0);
myLCD.printf("%03lX", adc);
// Write LCD (2. Zeile, links)
myLCD.setCursor(0, 1);
myLCD.printf("%ld mV ", mV);
// Wait 250ms (4Hz)
delay(250);
}