Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP32-Based Temperature Monitoring System with GC9A01 Display

View and Edit Project In Cirkit DesignerImage of ESP32-Based Temperature Monitoring System with GC9A01 Display

Circuit Documentation

Summary

This circuit involves an ESP32 microcontroller, a GC9A01 display, and a temperature sensor. The ESP32 reads temperature data from the temperature sensor and displays it on the GC9A01 display. The brightness of the display is controlled by a potentiometer.

Component List

ESP32

GC9A01

Temperature Sensor

Wiring Details

ESP32

GC9A01

Temperature Sensor

Code Documentation

ESP32 Code

/*
 * This Arduino Sketch is for an ESP32 microcontroller that reads temperature
 * data from a temperature sensor and displays it on a GC9A01 display. The
 * brightness of the display is controlled by a potentiometer.
 */

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <OneWire.h>
#include <DallasTemperature.h>

#define SCREEN_WIDTH 240
#define SCREEN_HEIGHT 240
#define OLED_RESET    -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

#define ONE_WIRE_BUS 13
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

#define POT_PIN 36

void setup() {
  Serial.begin(115200);
  if(!display.begin(SSD1306_I2C_ADDRESS, OLED_RESET)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }
  display.display();
  delay(2000);
  display.clearDisplay();
  sensors.begin();
}

void loop() {
  sensors.requestTemperatures();
  float temperatureC = sensors.getTempCByIndex(0);
  int potValue = analogRead(POT_PIN);
  int brightness = map(potValue, 0, 4095, 0, 255);
  display.ssd1306_command(SSD1306_SETCONTRAST);
  display.ssd1306_command(brightness);
  display.clearDisplay();
  display.setTextSize(2);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(0, 10);
  display.print(F("Temp: "));
  display.print(temperatureC);
  display.print(F(" C"));
  display.display();
  delay(1000);
}

GC9A01 Code

#include <TFT_eSPI.h> // Include the graphics library (this includes the sprite functions)

#define ONE_WIRE_BUS 13
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

#define POT_PIN 36

TFT_eSPI tft = TFT_eSPI();  // Invoke custom library

void setup() {
  Serial.begin(115200);
  tft.init();
  tft.setRotation(1);
  sensors.begin();
}

void loop() {
  sensors.requestTemperatures();
  float temperatureC = sensors.getTempCByIndex(0);
  int potValue = analogRead(POT_PIN);
  int brightness = map(potValue, 0, 4095, 0, 255);
  tft.fillScreen(TFT_BLACK);
  tft.setTextColor(TFT_WHITE, TFT_BLACK);
  tft.setTextSize(2);
  tft.setCursor(0, 10);
  tft.printf("Temp: %.2f C", temperatureC);
  tft.setBrightness(brightness); // Adjust brightness if supported by the library
  delay(1000);
}

This documentation provides a comprehensive overview of the circuit, including a summary, detailed component list, wiring details, and the code used for the microcontrollers.