This circuit is designed to interface an ESP32C3 Supermini microcontroller with an OLED display, multiple pushbuttons, and a potentiometer. The circuit allows for the reading of the potentiometer value to determine a fuel level, which is then displayed on the OLED screen. The pushbuttons can be used to reset the fuel level or perform other actions.
GPIO05 connected to Pin 3 (out) of Pushbutton
GPIO06 connected to Pin 3 (out) of Pushbutton
GPIO07 connected to Pin 3 (out) of Pushbutton
GPIO08 connected to SDA of OLED 1.3"
GPIO09 connected to SCL of OLED 1.3"
GPIO00 connected to Output of Potentiometer
GPIO01 connected to pin1 of Resistor (5k Ohm)
3.3V connected to VCC of Potentiometer and VCC of OLED 1.3"
GND connected to GND of Pushbutton, GND of Potentiometer, and GND of OLED 1.3"
Pin 4 (out) connected to GND of ESP32C3 Supermini
Pin 4 (out) connected to pin1 of Resistor (20k Ohm)
Pin 4 (out) connected to Pin 4 (out) of Pushbutton
GND connected to GND of ESP32C3 Supermini
Output connected to GPIO00 of ESP32C3 Supermini
VCC connected to 3.3V of ESP32C3 Supermini
pin1 connected to GND of ESP32C3 Supermini
pin2 connected to Pin 4 (out) of Pushbutton
pin1 connected to GPIO01 of ESP32C3 Supermini
pin2 connected to GND of ESP32C3 Supermini
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
/*
* This code reads the potentiometer value to determine the fuel level and
* displays the remaining fuel and estimated distance on an OLED screen.
* Pushbuttons can be used to reset the fuel level or perform other actions.
*/
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
#define POT_PIN A0
#define BUTTON1_PIN 5
#define BUTTON2_PIN 6
#define BUTTON3_PIN 7
void setup() {
pinMode(POT_PIN, INPUT);
pinMode(BUTTON1_PIN, INPUT_PULLUP);
pinMode(BUTTON2_PIN, INPUT_PULLUP);
pinMode(BUTTON3_PIN, INPUT_PULLUP);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
display.print("Initializing...");
display.display();
delay(2000);
}
void loop() {
int potValue = analogRead(POT_PIN);
float fuelLevel = map(potValue, 0, 1023, 0, 100);
float distance = fuelLevel * 10; // Assume 10 km per unit of fuel
display.clearDisplay();
display.setCursor(0, 0);
display.print("Fuel Level: ");
display.print(fuelLevel);
display.print("%");
display.setCursor(0, 10);
display.print("Distance: ");
display.print(distance);
display.print(" km");
display.display();
if (digitalRead(BUTTON1_PIN) == LOW) {
// Reset fuel level or perform other actions
}
if (digitalRead(BUTTON2_PIN) == LOW) {
// Perform other actions
}
if (digitalRead(BUTTON3_PIN) == LOW) {
// Perform other actions
}
delay(500);
}
This documentation provides a comprehensive overview of the circuit, detailing each component, its connections, and the code used for operation.