Arnov Sharma
Published © MIT

Temperature Card

The Temperature Card is a wearable XIAO and SSD1306-based device that displays the current temperature using an SHT40 sensor.

BeginnerFull instructions provided1 hour927
Temperature Card

Things used in this project

Hardware components

Seeed Studio XIAO ESP32C3
×1
Grove - Temperature&Humidity Sensor (SHT40)
Seeed Studio Grove - Temperature&Humidity Sensor (SHT40)
×1
Grove - OLED Display 0.66" (SSD1306)- IIC - 3.3V/5V
Seeed Studio Grove - OLED Display 0.66" (SSD1306)- IIC - 3.3V/5V
×1

Software apps and online services

Fusion
Autodesk Fusion
Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Seeed Studio Fusion PCB/PCBA
Seeed Studio Fusion PCB/PCBA

Story

Read more

Custom parts and enclosures

BASE

Schematics

cad file

SCH

Code

code

C/C++
#include "Adafruit_SHT4x.h"
#include <Wire.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>

#define OLED_WIDTH 128
#define OLED_HEIGHT 64

#define OLED_ADDR   0x3C

Adafruit_SHT4x sht4 = Adafruit_SHT4x();

Adafruit_SSD1306 display(OLED_WIDTH, OLED_HEIGHT);

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

display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR);
display.clearDisplay();

Serial.println("Adafruit SHT4x test");
  if (! sht4.begin()) {
    Serial.println("Couldn't find SHT4x");
    while (1) delay(1);
  }
  Serial.println("Found SHT4x sensor");
  Serial.print("Serial number 0x");
  Serial.println(sht4.readSerial(), HEX);

  sht4.setPrecision(SHT4X_HIGH_PRECISION);
  switch (sht4.getPrecision()) {
     case SHT4X_HIGH_PRECISION: 
       Serial.println("High precision");
       break;
     case SHT4X_MED_PRECISION: 
       Serial.println("Med precision");
       break;
     case SHT4X_LOW_PRECISION: 
       Serial.println("Low precision");
       break;
  }

  // You can have 6 different heater settings
  // higher heat and longer times uses more power
  // and reads will take longer too!
  sht4.setHeater(SHT4X_NO_HEATER);
  switch (sht4.getHeater()) {
     case SHT4X_NO_HEATER: 
       Serial.println("No heater");
       break;
     case SHT4X_HIGH_HEATER_1S: 
       Serial.println("High heat for 1 second");
       break;
     case SHT4X_HIGH_HEATER_100MS: 
       Serial.println("High heat for 0.1 second");
       break;
     case SHT4X_MED_HEATER_1S: 
       Serial.println("Medium heat for 1 second");
       break;
     case SHT4X_MED_HEATER_100MS: 
       Serial.println("Medium heat for 0.1 second");
       break;
     case SHT4X_LOW_HEATER_1S: 
       Serial.println("Low heat for 1 second");
       break;
     case SHT4X_LOW_HEATER_100MS: 
       Serial.println("Low heat for 0.1 second");
       break;
  }

}

void loop() {

 sensors_event_t humidity, temp;
  
  uint32_t timestamp = millis();
  sht4.getEvent(&humidity, &temp);// populate temp and humidity objects with fresh data
  timestamp = millis() - timestamp;

  display.clearDisplay();          //TEMP
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(38, 0);
  display.println("TEMP");

//  display.display();

 
  display.setTextSize(1);                 //TEMP VALUE
  display.setTextColor(WHITE);
  display.setCursor(0, 20);
  display.println("---------------------");

  display.display();
 

          
  display.setTextSize(3);                 //TEMP VALUE
  display.setTextColor(WHITE);
  display.setCursor(22, 30);
  display.println(temp.temperature);
  display.display();
  delay(10);

}

Credits

Arnov Sharma

Arnov Sharma

308 projects • 306 followers
Just your average MAKER

Comments