Keval Doshi
Published © GPL3+

Arduino OLED Temperature Display with Real Time Clock

In this article, we are going to make an Arduino weather clock which will tell us the time, date and temperature.

IntermediateFull instructions provided2 hours5,948
Arduino OLED Temperature Display with Real Time Clock

Things used in this project

Hardware components

Arduino Uno
×1
Adafruit DS3231 RTC
×1
Pmod OLED
Digilent Pmod OLED
×1
Texas Instruments LM35 Temperature Sensor
×1
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1

Story

Read more

Schematics

arduino-weather-clock_bb_r3RznyasiL.jpg

Arduino weather clock bb (1) r3rznyasil

Code

Code snippet #4

Plain text
  display.clearDisplay();
  display.setTextColor(WHITE);
  display.setTextSize(2);
  display.setCursor(0,0);
  display.print("  Weather ");
  display.setCursor(0,17);
  display.print("  Clock ");
  display.display();
  delay(5000);

Code snippet #5

Plain text
 output = analogRead(sensor_pin);
  temp =(output*500)/1023;
  display.clearDisplay();
  display.setTextSize(2);
  display.setCursor(20,0);
  display.print(rtc.getTimeStr());
  display.setTextSize(1);
  display.setCursor(0,15);
  display.print(rtc.getDateStr());
  display.setTextSize(1);
  display.setCursor(70,15);
  display.print(rtc.getDOWStr());

Code snippet #6

Plain text
#include 
#include 
DS3231 rtc(SDA, SCL);
#define OLED_MOSI 11
#define OLED_CLK 13
#define OLED_DC 9
#define OLED_CS 10
#define OLED_RESET 8
Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
const int sensor_pin = A0;
float temp;  
float output;

void setup() 
{
  pinMode(sensor_pin,INPUT);
  rtc.begin();
  display.begin(SSD1306_SWITCHCAPVCC);
  //rtc.setDOW(WEDNESDAY);     // Set Day-of-Week to SUNDAY
  //rtc.setTime(19, 02, 0);     // Set the time to 12:00:00 (24hr format)
  //rtc.setDate(7, 12, 2017);   // Set the date to June 6th, 2017
  display.clearDisplay();
  display.setTextColor(WHITE);
  display.setTextSize(2);
  display.setCursor(0,0);
  display.print("  Weather ");
  display.setCursor(0,17);
  display.print("  Clock ");
  display.display();
  delay(5000);
}

void loop()
{
  output = analogRead(sensor_pin);
  temp =(output*500)/1023;
  display.clearDisplay();
  display.setTextSize(2);
  display.setCursor(20,0);
  display.print(rtc.getTimeStr());
  display.setTextSize(1);
  display.setCursor(0,15);
  display.print(rtc.getDateStr());
  display.setTextSize(1);
  display.setCursor(70,15);
  display.print(rtc.getDOWStr());
  display.setTextSize(1);
  display.setCursor(20,25);
  display.print("Temp: ");
  display.print(temp);
  display.print("C");
  display.display(); 
  delay(1000);
}

Credits

Keval Doshi

Keval Doshi

1 project • 15 followers
Hardware Hacker. Love going to hackathons. Enough said!
Contact

Comments

Add projectSign up / Login