Skip to content

Instantly share code, notes, and snippets.

@pawl
Last active December 19, 2020 05:49
Show Gist options
  • Select an option

  • Save pawl/73a1ccfbf2b2be6f934e651b39c51082 to your computer and use it in GitHub Desktop.

Select an option

Save pawl/73a1ccfbf2b2be6f934e651b39c51082 to your computer and use it in GitHub Desktop.

Revisions

  1. pawl revised this gist Dec 19, 2020. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions lcdthermocouple_oled.c
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,10 @@
    // also:
    // https://randomnerdtutorials.com/esp32-ssd1306-oled-display-arduino-ide/
    // http://www.esp32learning.com/code/esp32-and-max6675-example.php
    // parts:
    // * HiLetgo DC 3-5V MAX6675 Module + K Type Thermocouple Temperature Sensor
    // * UCTRONICS 0.96 Inch OLED Module 12864 128x64 Yellow Blue SSD1306 Driver I2C
    // * ESP32

    #include <max6675.h>
    #include <Wire.h>
  2. pawl revised this gist Dec 19, 2020. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions lcdthermocouple_oled.c
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,7 @@

    #include <max6675.h>
    #include <Wire.h>
    // also requires Adafruit Bus IO Library
    #include <Adafruit_GFX.h>
    #include <Adafruit_SSD1306.h>

  3. pawl revised this gist Dec 19, 2020. No changes.
  4. pawl created this gist Dec 19, 2020.
    51 changes: 51 additions & 0 deletions lcdthermocouple_oled.c
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,51 @@
    // based on the lcdthermocouple example
    // also:
    // https://randomnerdtutorials.com/esp32-ssd1306-oled-display-arduino-ide/
    // http://www.esp32learning.com/code/esp32-and-max6675-example.php

    #include <max6675.h>
    #include <Wire.h>
    #include <Adafruit_GFX.h>
    #include <Adafruit_SSD1306.h>

    #define SCREEN_WIDTH 128 // OLED display width, in pixels
    #define SCREEN_HEIGHT 64 // OLED display height, in pixels

    int thermoDO = 19; // SO
    int thermoCS = 23;
    int thermoCLK = 5; // SCK

    MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);

    // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
    Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

    void setup() {
    Serial.begin(9600);

    if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
    }
    delay(2000);

    }

    void loop() {
    display.clearDisplay();

    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.setCursor(0, 1);
    display.println("Paul's Thermometer");

    display.setTextSize(5);
    display.setTextColor(WHITE);
    display.setCursor(0, 20);
    display.print((int) thermocouple.readFahrenheit());
    display.println("F");

    display.display();

    delay(200);
    }